7.1.5-rc1 review
Subsystems (15)
Greg Kroah-Hartman
maintainerPATCH 651/2077 bonding: 3ad: fix mux port state on oper down
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 807afc7544b865d4d09068a415fd5b71bf5665cc ]
When the bonding interface has carrier down due to the absence of usable slaves and a slave transitions from down to up, the bonding interface briefly goes carrier up, then down again, and finally up once LACP negotiates collecting and distributing on the port.
When lacp_strict mode is on, the interface should not transition to carrier up until LACP negotiation is complete.
This happens because the actor and partner port states remain in Collecting_Distributing when the port goes down. When the port comes back up, it temporarily remains in this state until LACP renegotiation occurs.
Previously this was mostly cosmetic, but since the bonding carrier state may depend on the LACP negotiation state, it causes the interface to flap.
According to IEEE 802.3ad-2000 and IEEE 802.1ax-2014, Collecting and Distributing should be reset when a port goes down:
- In the Receive state machine, port_enabled == FALSE causes a transition to the PORT_DISABLED state, which is expected to clear Partner_Oper_Port_State.Synchronization.
- In the Mux state machine, Partner_Oper_Port_State.Synchronization == FALSE causes a transition to the ATTACHED state, which disables Collecting and Distributing.
However, Partner_Oper_Port_State.Synchronization is not cleared in the PORT_DISABLED state.
Clear Partner_Oper_Port_State.Synchronization in the Receive PORT_DISABLED state.
--- drivers/net/bonding/bond_3ad.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/bond_3ad.c +1 -0
@@ -1337,6 +1337,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) fallthrough;case AD_RX_PORT_DISABLED : port->sm_vars &= ~AD_PORT_MATCHED ; + port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION ;break ;case AD_RX_LACP_DISABLED : port->sm_vars &= ~AD_PORT_SELECTED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 652/2077 ext4: fix kernel BUG in ext4_write_inline_data_end
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Prakash Srivastava <[email protected]>
[ Upstream commit ad09aa45965d3fafaf9963bc78109b73c0f9ac8d ]
When the data=journal mount option is used, the ext4_journalled_write_end() function incorrectly calls ext4_write_inline_data_end() without checking if the EXT4_STATE_MAY_INLINE_DATA flag is still set on the inode.
If a previous attempt to convert the inline data to an extent failed (e.g. due to ENOSPC), the EXT4_STATE_MAY_INLINE_DATA flag is cleared, but the EXT4_INODE_INLINE_DATA flag remains set. In this scenario, the next call to ext4_write_begin() will not prepare the inline data xattr for writing, but ext4_journalled_write_end() will incorrectly attempt to write to it, triggering a BUG_ON(pos + len > EXT4_I(inode)->i_inline_size) in ext4_write_inline_data() since i_inline_size was not expanded.
Fix this by ensuring that ext4_journalled_write_end() only calls ext4_write_inline_data_end() if the EXT4_STATE_MAY_INLINE_DATA flag is set, mirroring the behavior of ext4_write_end() and ext4_da_write_end().
--- fs/ext4/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
@@ -1560,7 +1560,8 @@ static int ext4_journalled_write_end(const struct kiocb *iocb,BUG_ON (!ext4_handle_valid (handle)); -if (ext4_has_inline_data (inode)) +if (ext4_has_inline_data (inode) && +ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ))return ext4_write_inline_data_end (inode, pos, len, copied, folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 653/2077 ext4: validate donor file superblock early in EXT4_IOC_MOVE_EXT
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit c143957520c6c9b5cd72e0de8b52b814f0c576fe ]
Reject the EXT4_IOC_MOVE_EXT ioctl early if the donor file does not belong to the same superblock as the original file. Currently, this validation is performed inside ext4_move_extents() by mext_check_validity(), but only after lock_two_nondirectories() has already acquired the inode locks. When the donor fd refers to a file on a different filesystem (e.g., overlayfs), this late validation creates a circular lock dependency:
CPU0 (overlayfs write) CPU1 (ext4 ioctl)
---- ----
inode_lock(ovl_inode)
mnt_want_write_file(filp)
sb_start_write(ext4_sb) [sb_writers]
backing_file_write_iter()
vfs_iter_write(real_file)
file_start_write(real_file)
sb_start_write(ext4_sb) [blocked by freeze]
lock_two_nondirectories()
inode_lock(ovl_inode) [blocked]
With a concurrent freeze operation holding sb_writers write side, this forms a deadlock cycle: CPU0 waits for freeze to complete, freeze waits for CPU1's sb_writers reader to exit, CPU1 waits for CPU0's inode lock.
Since EXT4_IOC_MOVE_EXT exchanges physical extents between two files, it fundamentally requires both files to reside on the same ext4 filesystem. Moving the superblock check before any lock acquisition is both semantically correct and eliminates the circular dependency by ensuring that cross-filesystem donor fds are rejected before sb_writers or inode locks are taken.
--- fs/ext4/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ext4/ioctl.c +3 -0
@@ -1656,6 +1656,9 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (!(fd_file (donor)->f_mode &FMODE_WRITE ))return -EBADF ; +if (file_inode (filp)->i_sb !=file_inode (fd_file (donor))->i_sb) +return -EXDEV ; + err =mnt_want_write_file (filp);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/2077 selftests/bpf: Fix bpf_iter/task_vma test
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 2e8ad1ff712d2a397e407c9fde60901f68d077dc ]
For selftest bpf_iter/task_vma, I got a failure like below on my qemu run:
test_task_vma_common:FAIL:compare_output unexpected compare_output:
actual
'561593546000-561593585000r--p0000000000:241256579534/root/devshare/bpf-next/tools/testing/selftests/bpf/test_progs'
!= expected
'561593546000-561593585000r--p0000000000:245551546830/root/devshare/bpf-next/tools/testing/selftests/bpf/test_progs'Further debugging found out file->f_inode->i_ino value may exceed 32bit, e.g., i_ino = 0x14c2eae35, but the format string is '%u'. This caused inode mismatch between bpf iter and proc result.
Fix the issue by using format string '%llu' to accommodate 64bit i_ino.
--- tools/testing/selftests/bpf/progs/bpf_iter_task_vmas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/bpf_iter_task_vmas.c +1 -1
@@ -52,7 +52,7 @@ SEC("iter/task_vma") int proc_maps(struct bpf_iter__task_vma *ctx)bpf_d_path (&file->f_path, d_path_buf,D_PATH_BUF_SIZE );BPF_SEQ_PRINTF (seq,"%08llx " , vma->vm_pgoff <<12 ); -BPF_SEQ_PRINTF (seq,"%02x:%02x %u" ,MAJOR (dev),MINOR (dev), +BPF_SEQ_PRINTF (seq,"%02x:%02x %llu" ,MAJOR (dev),MINOR (dev), file->f_inode->i_ino);BPF_SEQ_PRINTF (seq,"\t%s\n" , d_path_buf); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 655/2077 cxl/test: Verify cmd->size_in before accessing payload
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 71a1def165267bc0947d4236f7336f490739c379 ]
Several mock mailbox handlers access input payload fields before verifying that cmd->size_in is large enough for the corresponding structure.
To ensure invalid commands are rejected before any payload data is consumed, add missing size checks and move existing checks ahead of the first payload field access.
[dj: Updated commit log per Alison's comments. ]
--- tools/testing/cxl/test/mem.c | 39 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-)
tools/testing/cxl/test/mem.c +30 -9
@@ -312,12 +312,17 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd)static int mock_clear_event (struct device *dev,struct cxl_mbox_cmd *cmd) { -struct cxl_mbox_clear_event_payload *pl = cmd->payload_in; +struct cxl_mbox_clear_event_payload *pl;struct mock_event_log *log; -u8 log_type = pl->event_log; +u8 log_type;u16 handle;int nr; +if (cmd->size_in <sizeof (*pl)) +return -EINVAL ; + + pl = cmd->payload_in; + log_type = pl->event_log;if (log_type >=CXL_EVENT_TYPE_MAX )return -EINVAL ;
@@ -574,14 +579,19 @@ static int mock_gsl(struct cxl_mbox_cmd *cmd)static int mock_get_log (struct cxl_memdev_state *mds,struct cxl_mbox_cmd *cmd) {struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; -struct cxl_mbox_get_log *gl = cmd->payload_in; -u32 offset =le32_to_cpu (gl->offset); -u32 length =le32_to_cpu (gl->length);uuid_t uuid =DEFINE_CXL_CEL_UUID ; +struct cxl_mbox_get_log *gl;void *data = &mock_cel; +u32 offset; +u32 length;if (cmd->size_in <sizeof (*gl))return -EINVAL ; + + gl = cmd->payload_in; + offset =le32_to_cpu (gl->offset); + length =le32_to_cpu (gl->length); +if (length > cxl_mbox->payload_size)return -EINVAL ;if (offset + length >sizeof (mock_cel))
@@ -1336,10 +1346,14 @@ static int mock_fw_info(struct cxl_mockmem_data *mdata,static int mock_transfer_fw (struct cxl_mockmem_data *mdata,struct cxl_mbox_cmd *cmd) { -struct cxl_mbox_transfer_fw *transfer = cmd->payload_in; +struct cxl_mbox_transfer_fw *transfer;void *fw = mdata->fw;size_t offset, length; +if (cmd->size_in <sizeof (*transfer)) +return -EINVAL ; + + transfer = cmd->payload_in; offset =le32_to_cpu (transfer->offset) *CXL_FW_TRANSFER_ALIGNMENT ; length = cmd->size_in -sizeof (*transfer);if (offset + length >FW_SIZE )
@@ -1415,11 +1429,18 @@ static int mock_get_test_feature(struct cxl_mockmem_data *mdata, struct cxl_mbox_cmd *cmd) {struct vendor_test_feat *output = cmd->payload_out; -struct cxl_mbox_get_feat_in *input = cmd->payload_in; -u16 offset =le16_to_cpu (input->offset); -u16 count =le16_to_cpu (input->count); +struct cxl_mbox_get_feat_in *input; +u16 offset; +u16 count;u8 *ptr; +if (cmd->size_in <sizeof (*input)) +return -EINVAL ; + + input = cmd->payload_in; + offset =le16_to_cpu (input->offset); + count =le16_to_cpu (input->count); +if (offset >sizeof (*output)) { cmd->return_code =CXL_MBOX_CMD_RC_INPUT ;return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 656/2077 cxl/test: Fix integer overflow in mock LSA bounds checks
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 81eafcada109b653977c4dfbd2b6a72470025a01 ]
Pre-existing issue discovered by sashiko-bot.
mock_get_lsa() and mock_set_lsa() validate the requested LSA range with "offset + length > LSA_SIZE". Both offset and length are u32 and, in mock_get_lsa(), both are taken directly from the user-supplied payload. The addition is evaluated modulo 2^32, so a large offset combined with a small length wraps around and passes the check.
Rewrite the checks to first bound offset, then compare length against the remaining LSA size.
--- tools/testing/cxl/test/mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/cxl/test/mem.c +2 -2
@@ -1063,7 +1063,7 @@ static int mock_get_lsa(struct cxl_mockmem_data *mdata,return -EINVAL ; offset =le32_to_cpu (get_lsa->offset); length =le32_to_cpu (get_lsa->length); -if (offset + length >LSA_SIZE ) +if (offset >LSA_SIZE || length >LSA_SIZE - offset)return -EINVAL ;if (length > cmd->size_out)return -EINVAL ;
@@ -1083,7 +1083,7 @@ static int mock_set_lsa(struct cxl_mockmem_data *mdata,return -EINVAL ; offset =le32_to_cpu (set_lsa->offset); length = cmd->size_in -sizeof (*set_lsa); -if (offset + length >LSA_SIZE ) +if (offset >LSA_SIZE || length >LSA_SIZE - offset)return -EINVAL ;memcpy (lsa + offset, &set_lsa->data[0 ], length);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 657/2077 cxl/test: Zero out LSA backing memory to avoid leaking to user
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 60f065dbaf46e65830da62a0041761f0c039e086 ]
Memory through vmalloc() is not zeroed out. When this memory is copied into output payload, it leaks memory content to user. Use vzalloc() instead to zero out the memory.
--- tools/testing/cxl/test/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/cxl/test/mem.c +1 -1
@@ -1724,7 +1724,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)return -ENOMEM ;dev_set_drvdata (dev, mdata); - mdata->lsa =vmalloc (LSA_SIZE ); + mdata->lsa =vzalloc (LSA_SIZE );if (!mdata->lsa)return -ENOMEM ; mdata->fw =vmalloc (FW_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 658/2077 of: cpu: add check in __of_find_n_match_cpu_property()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Shtylyov <[email protected]>
[ Upstream commit 5901eda2ed99ba0d3661da6eb265970559323bb3 ]
In __of_find_n_match_cpu_property(), checking the variable ac for 0 won't prevent a possible overflow when multiplying it by sizeof(*cell). Besides, of_read_number() (called in the *for* loop) can't return correct result if that variable (which equals the #address-cells prop's value) exceeds 2, so additionally checking for that seems logical...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/of/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/cpu.c +1 -1
@@ -60,7 +60,7 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, cell =of_get_property (cpun, prop_name, &prop_len);if (!cell && !ac &&arch_match_cpu_phys_id (cpu,0 ))return true; -if (!cell || !ac) +if (!cell || !ac || ac >2 )return false; prop_len /=sizeof (*cell) * ac;for (tid =0 ; tid < prop_len; tid++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 659/2077 vfio/qat: fix f_pos race in qat_vf_resume_write()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giovanni Cabiddu <[email protected]>
[ Upstream commit 4ec5e932e636896e97e4c6a8205b0ac76d52421a ]
qat_vf_resume_write() checks filp->f_pos before taking migf->lock, but copies into the migration-state buffer after taking the lock and re-reading the shared file position.
Two concurrent writers could therefore pass the bounds check with the old offset, then have the second writer copy after the first advanced f_pos, writing past the end of the migration-state buffer.
Take migf->lock before doing the boundary checks.
--- drivers/vfio/pci/qat/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/vfio/pci/qat/main.c +10 -6
@@ -298,14 +298,18 @@ static ssize_t qat_vf_resume_write(struct file *filp, const char __user *buf,return -ESPIPE ; offs = &filp->f_pos; -if (*offs <0 || -check_add_overflow (len, *offs, &end)) -return -EOVERFLOW ; +mutex_lock (&migf->lock); -if (end > mig_dev->state_size) -return -ENOMEM ; +if (*offs <0 ||check_add_overflow (len, *offs, &end)) { + done = -EOVERFLOW ; + goto out_unlock; + } + +if (end > mig_dev->state_size) { + done = -ENOMEM ; + goto out_unlock; + } -mutex_lock (&migf->lock);if (migf->disabled) { done = -ENODEV ; goto out_unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 660/2077 bpf: Tighten cgroup storage cookie checks for prog arrays
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 10627ddc0167aab5c1c390a10ef461e9937aba08 ]
The fix in commit abad3d0bad72 ("bpf: Fix oob access in cgroup local storage") is still incomplete. The prog-array compatibility check treats a program with no cgroup storage as compatible with any stored storage cookie. This allows a storage-less program to bridge a tail call chain between an entry program and a storage-using callee even though cgroup local storage at runtime still follows the caller's context, that is, A -> B(no storage) -> C(storage) path.
Requiring exact cookie equality would break the legitimate case of a storage-less leaf program being tail called from a storage-using one. Instead, only accept a zero storage cookie if the program cannot perform tail calls itself. This keeps A -> B(no storage) working while rejecting the A -> B(no storage) -> C(storage) bridge.
--- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
@@ -2527,7 +2527,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, cookie = aux->cgroup_storage[i] ? aux->cgroup_storage[i]->cookie :0 ; ret = map->owner->storage_cookie[i] == cookie || - !cookie; + (!cookie && !aux->tail_call_reachable); }if (ret && map->owner->attach_func_proto != aux->attach_func_proto) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 661/2077 m68k: mcf5441x: fix clocks numbering
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Angelo Dureghello <[email protected]>
[ Upstream commit 919afb86694f5a8a9b50bff56cd8199f065b0dbb ]
Fix clocks numbering, set correct values for eport and DAC, as per RM Rev 5, 05/2018, table 9.5.
--- arch/m68k/coldfire/m5441x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/m68k/coldfire/m5441x.c +9 -9
@@ -41,9 +41,9 @@ DEFINE_CLK(0, "mcfpit.0", 32, MCF_BUSCLK);DEFINE_CLK (0 ,"mcfpit.1" ,33 ,MCF_BUSCLK );DEFINE_CLK (0 ,"mcfpit.2" ,34 ,MCF_BUSCLK );DEFINE_CLK (0 ,"mcfpit.3" ,35 ,MCF_BUSCLK ); -DEFINE_CLK (0 ,"mcfeport.0" ,37 ,MCF_CLK ); -DEFINE_CLK (0 ,"mcfadc.0" ,38 ,MCF_CLK ); -DEFINE_CLK (0 ,"mcfdac.0" ,39 ,MCF_CLK ); +DEFINE_CLK (0 ,"mcfeport.0" ,36 ,MCF_CLK ); +DEFINE_CLK (0 ,"mcfadc.0" ,37 ,MCF_CLK ); +DEFINE_CLK (0 ,"mcfdac.0" ,38 ,MCF_CLK );DEFINE_CLK (0 ,"mcfrtc.0" ,42 ,MCF_CLK );DEFINE_CLK (0 ,"mcfsim.0" ,43 ,MCF_CLK );DEFINE_CLK (0 ,"mcfusb-otg.0" ,44 ,MCF_CLK );
@@ -103,9 +103,9 @@ static struct clk_lookup m5411x_clk_lookup[] = {CLKDEV_INIT ("mcfpit.1" ,NULL , &__clk_0_33),CLKDEV_INIT ("mcfpit.2" ,NULL , &__clk_0_34),CLKDEV_INIT ("mcfpit.3" ,NULL , &__clk_0_35), -CLKDEV_INIT ("mcfeport.0" ,NULL , &__clk_0_37), -CLKDEV_INIT ("mcfadc.0" ,NULL , &__clk_0_38), -CLKDEV_INIT ("mcfdac.0" ,NULL , &__clk_0_39), +CLKDEV_INIT ("mcfeport.0" ,NULL , &__clk_0_36), +CLKDEV_INIT ("mcfadc.0" ,NULL , &__clk_0_37), +CLKDEV_INIT ("mcfdac.0" ,NULL , &__clk_0_38),CLKDEV_INIT ("mcfrtc.0" ,NULL , &__clk_0_42),CLKDEV_INIT ("mcfsim.0" ,NULL , &__clk_0_43), CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
@@ -156,7 +156,7 @@ static struct clk * const enable_clks[] __initconst = { &__clk_0_27,/* uart3 */ &__clk_0_33,/* pit.1 */ - &__clk_0_37,/* eport */ + &__clk_0_36,/* eport */ &__clk_0_48,/* pll */ &__clk_0_51, /* esdhc */
@@ -174,8 +174,8 @@ static struct clk * const disable_clks[] __initconst = { &__clk_0_32,/* pit.0 */ &__clk_0_34,/* pit.2 */ &__clk_0_35,/* pit.3 */ - &__clk_0_38,/* adc */ - &__clk_0_39,/* dac */ + &__clk_0_37,/* adc */ + &__clk_0_38,/* dac.0 */ &__clk_0_44,/* usb otg */ &__clk_0_45,/* usb host */ &__clk_0_47, /* ssi.0 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/2077 pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit eaf84ff673409fa3dfc390c6afb53b641ee5acba ]
The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.
For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.
Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.
Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.
--- drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c | 1 - drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c | 1 - 2 files changed, 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c +0 -1
@@ -26,7 +26,6 @@ static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =static struct sunxi_pinctrl_desc a523_r_pinctrl_data = { .irq_banks =ARRAY_SIZE (a523_r_irq_bank_map), .irq_bank_map = a523_r_irq_bank_map, - .irq_read_needs_mux = true, .io_bias_cfg_variant =BIAS_VOLTAGE_PIO_POW_MODE_SEL , .pin_base =PL_BASE , };
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +0 -1
@@ -26,7 +26,6 @@ static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =static struct sunxi_pinctrl_desc a523_pinctrl_data = { .irq_banks =ARRAY_SIZE (a523_irq_bank_map), .irq_bank_map = a523_irq_bank_map, - .irq_read_needs_mux = true, .io_bias_cfg_variant =BIAS_VOLTAGE_PIO_POW_MODE_SEL , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/2077 pinctrl: airoha: an7581: add missed gpio32 pin group
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit bdc95d7e8de3eefa9fc062302625259c0b79136d ]
gpio32 pin group is missed for an7581 SoC. This patch add it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -0
@@ -539,6 +539,7 @@ static const int en7581_gpio28_pins[] = { 41 };static const int en7581_gpio29_pins[] = {42 };static const int en7581_gpio30_pins[] = {43 };static const int en7581_gpio31_pins[] = {44 }; +static const int en7581_gpio32_pins[] = {45 };static const int en7581_gpio33_pins[] = {46 };static const int en7581_gpio34_pins[] = {47 };static const int en7581_gpio35_pins[] = {48 };
@@ -623,6 +624,7 @@ static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio29" , en7581_gpio29),PINCTRL_PIN_GROUP ("gpio30" , en7581_gpio30),PINCTRL_PIN_GROUP ("gpio31" , en7581_gpio31), +PINCTRL_PIN_GROUP ("gpio32" , en7581_gpio32),PINCTRL_PIN_GROUP ("gpio33" , en7581_gpio33),PINCTRL_PIN_GROUP ("gpio34" , en7581_gpio34), PINCTRL_PIN_GROUP("gpio35", en7581_gpio35),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 664/2077 pinctrl: airoha: an7583: add missed gpio32 pin group
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 81cc2285cea84e3ed8688d353e1250cf8899c80a ]
gpio32 pin group is missed for an7583 SoC. This patch add it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -0
@@ -758,6 +758,7 @@ static const int an7583_gpio28_pins[] = { 30 };static const int an7583_gpio29_pins[] = {31 };static const int an7583_gpio30_pins[] = {32 };static const int an7583_gpio31_pins[] = {33 }; +static const int an7583_gpio32_pins[] = {34 };static const int an7583_gpio33_pins[] = {35 };static const int an7583_gpio34_pins[] = {36 };static const int an7583_gpio35_pins[] = {37 };
@@ -836,6 +837,7 @@ static const struct pingroup an7583_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio29" , an7583_gpio29),PINCTRL_PIN_GROUP ("gpio30" , an7583_gpio30),PINCTRL_PIN_GROUP ("gpio31" , an7583_gpio31), +PINCTRL_PIN_GROUP ("gpio32" , an7583_gpio32),PINCTRL_PIN_GROUP ("gpio33" , an7583_gpio33),PINCTRL_PIN_GROUP ("gpio34" , an7583_gpio34), PINCTRL_PIN_GROUP("gpio35", an7583_gpio35),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 665/2077 pinctrl: airoha: an7581: fix misprint in gpio19 pinconf
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 08a39a0617ff32a7c3962bbc38a9eee41b14659a ]
Pin 32 (gpio19) duplicate pinconf settings of pin 31. Fix it using a proper bit number in the configuration register.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +4 -4
@@ -1798,7 +1798,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PU ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PU ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PU ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PU ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PU ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PU ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_PU ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_PU, BIT(22)),
@@ -1915,7 +1915,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PD ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PD ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PD ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PD ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PD ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PD ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_PD ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_PD, BIT(22)),
@@ -2032,7 +2032,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E2 ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E2 ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E2 ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E2 ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E2 ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E2 ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_E2 ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_E2, BIT(22)),
@@ -2149,7 +2149,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E4 ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E4 ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E4 ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E4 ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E4 ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E4 ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_E4 ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_E4, BIT(22)),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 666/2077 pinctrl: airoha: an7583: fix misprint in gpio19 pinconf
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a7f3e2b7730fc1d6c7431af49e0dc1ee97589795 ]
Pin 21 (gpio19) duplicate pinconf settings of pin 20. Fix it using a proper bit number in the configuration register.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +4 -4
@@ -1851,7 +1851,7 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (18 ,REG_GPIO_L_PU ,BIT (16 )),PINCTRL_CONF_DESC (19 ,REG_GPIO_L_PU ,BIT (17 )),PINCTRL_CONF_DESC (20 ,REG_GPIO_L_PU ,BIT (18 )), -PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PU ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PU ,BIT (19 )),PINCTRL_CONF_DESC (22 ,REG_GPIO_L_PU ,BIT (20 )),PINCTRL_CONF_DESC (23 ,REG_GPIO_L_PU ,BIT (21 )), PINCTRL_CONF_DESC(24, REG_GPIO_L_PU, BIT(22)),
@@ -1968,7 +1968,7 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (18 ,REG_GPIO_L_PD ,BIT (16 )),PINCTRL_CONF_DESC (19 ,REG_GPIO_L_PD ,BIT (17 )),PINCTRL_CONF_DESC (20 ,REG_GPIO_L_PD ,BIT (18 )), -PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PD ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PD ,BIT (19 )),PINCTRL_CONF_DESC (22 ,REG_GPIO_L_PD ,BIT (20 )),PINCTRL_CONF_DESC (23 ,REG_GPIO_L_PD ,BIT (21 )), PINCTRL_CONF_DESC(24, REG_GPIO_L_PD, BIT(22)),
@@ -2085,7 +2085,7 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (18 ,REG_GPIO_L_E2 ,BIT (16 )),PINCTRL_CONF_DESC (19 ,REG_GPIO_L_E2 ,BIT (17 )),PINCTRL_CONF_DESC (20 ,REG_GPIO_L_E2 ,BIT (18 )), -PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E2 ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E2 ,BIT (19 )),PINCTRL_CONF_DESC (22 ,REG_GPIO_L_E2 ,BIT (20 )),PINCTRL_CONF_DESC (23 ,REG_GPIO_L_E2 ,BIT (21 )), PINCTRL_CONF_DESC(24, REG_GPIO_L_E2, BIT(22)),
@@ -2202,7 +2202,7 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (18 ,REG_GPIO_L_E4 ,BIT (16 )),PINCTRL_CONF_DESC (19 ,REG_GPIO_L_E4 ,BIT (17 )),PINCTRL_CONF_DESC (20 ,REG_GPIO_L_E4 ,BIT (18 )), -PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E4 ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E4 ,BIT (19 )),PINCTRL_CONF_DESC (22 ,REG_GPIO_L_E4 ,BIT (20 )),PINCTRL_CONF_DESC (23 ,REG_GPIO_L_E4 ,BIT (21 )), PINCTRL_CONF_DESC(24, REG_GPIO_L_E4, BIT(22)),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 667/2077 pinctrl: airoha: an7581: fix incorrect led mapping in phy4_led1 pin function
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit e20c85c79cc2f45b87eb3dab38d4c641bbf83ed6 ]
phy4_led1 pin function maps led incorrectly. It uses the same map as phy3_led1. PHY{X} should map to LAN{N}_PHY_LED_MAP(X-1).
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +4 -4
@@ -1622,13 +1622,13 @@ static const struct airoha_pinctrl_func_group phy3_led1_func_group[] = {static const struct airoha_pinctrl_func_group phy4_led1_func_group[] = {AIROHA_PINCTRL_PHY_LED1 ("gpio43" ,GPIO_LAN0_LED1_MODE_MASK , -LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio44" ,GPIO_LAN1_LED1_MODE_MASK , -LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio45" ,GPIO_LAN2_LED1_MODE_MASK , -LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio46" ,GPIO_LAN3_LED1_MODE_MASK , -LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (3 )), };static const struct airoha_pinctrl_func_group an7583_phy1_led0_func_group[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 668/2077 pinctrl: airoha: an7583: fix incorrect led mapping in phy4_led1 pin function
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a3602577fdfc49c6dc08d67304426d5ef6d7dec6 ]
phy4_led1 pin function maps led incorrectly. It uses the same map as phy3_led1. PHY{X} should map to LAN{N}_PHY_LED_MAP(X-1).
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +4 -4
@@ -1710,13 +1710,13 @@ static const struct airoha_pinctrl_func_group an7583_phy3_led1_func_group[] = {static const struct airoha_pinctrl_func_group an7583_phy4_led1_func_group[] = {AIROHA_PINCTRL_PHY_LED1 ("gpio8" ,GPIO_LAN0_LED1_MODE_MASK , -LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio9" ,GPIO_LAN1_LED1_MODE_MASK , -LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio10" ,GPIO_LAN2_LED1_MODE_MASK , -LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (3 )),AIROHA_PINCTRL_PHY_LED1 ("gpio11" ,GPIO_LAN3_LED1_MODE_MASK , -LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (3 )), };static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 669/2077 pinctrl: airoha: fix pwm pin function for an7581 and an7583
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 08a5af468e613b6d8cd9725d284c9e6be288d364 ]
AN7581 have 47 valid GPIOs only (gpio0-gpio46), so gpio47 is a fiction. AN7583 have 49 valid GPIOs (gpio0-gpio48), so gpio48 is missed
To fix an issue
* create AN7583 specific pwm pin function,
* remove gpio47 from AN7581 pwm pin function.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 74 ++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +72 -2
@@ -906,7 +906,30 @@ static const char *const pwm_groups[] = { "gpio0", "gpio1","gpio40" ,"gpio41" ,"gpio42" ,"gpio43" ,"gpio44" ,"gpio45" , - "gpio46", "gpio47" }; + "gpio46" }; +static const char *const an7583_pwm_groups[] = {"gpio0" ,"gpio1" , +"gpio2" ,"gpio3" , +"gpio4" ,"gpio5" , +"gpio6" ,"gpio7" , +"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" , +"gpio12" ,"gpio13" , +"gpio14" ,"gpio15" , +"gpio16" ,"gpio17" , +"gpio18" ,"gpio19" , +"gpio20" ,"gpio21" , +"gpio22" ,"gpio23" , +"gpio24" ,"gpio25" , +"gpio26" ,"gpio27" , +"gpio28" ,"gpio29" , +"gpio30" ,"gpio31" , +"gpio36" ,"gpio37" , +"gpio38" ,"gpio39" , +"gpio40" ,"gpio41" , +"gpio42" ,"gpio43" , +"gpio44" ,"gpio45" , +"gpio46" ,"gpio47" , +"gpio48" };static const char *const phy1_led0_groups[] = {"gpio33" ,"gpio34" ,"gpio35" ,"gpio42" }; static const char *const phy2_led0_groups[] = { "gpio33", "gpio34",
@@ -1504,7 +1527,54 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), AIROHA_PINCTRL_PWM_EXT("gpio46", GPIO46_FLASH_MODE_CFG), +}; + +static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = { +AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio2" ,GPIO2_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio3" ,GPIO3_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio4" ,GPIO4_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio5" ,GPIO5_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio6" ,GPIO6_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio7" ,GPIO7_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio8" ,GPIO8_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio9" ,GPIO9_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio10" ,GPIO10_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio11" ,GPIO11_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio12" ,GPIO12_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio13" ,GPIO13_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio14" ,GPIO14_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio15" ,GPIO15_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio16" ,GPIO16_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio17" ,GPIO17_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio18" ,GPIO18_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio19" ,GPIO19_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio20" ,GPIO20_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio21" ,GPIO21_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio22" ,GPIO22_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio23" ,GPIO23_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio24" ,GPIO24_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio25" ,GPIO25_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio26" ,GPIO26_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio27" ,GPIO27_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio28" ,GPIO28_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio29" ,GPIO29_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio30" ,GPIO30_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio31" ,GPIO31_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG ), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
@@ -1759,7 +1829,7 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand),PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset), -PINCTRL_FUNC_DESC ("pwm" , pwm), +PINCTRL_FUNC_DESC ("pwm" , an7583_pwm),PINCTRL_FUNC_DESC ("phy1_led0" , an7583_phy1_led0),PINCTRL_FUNC_DESC ("phy2_led0" , an7583_phy2_led0), PINCTRL_FUNC_DESC("phy3_led0", an7583_phy3_led0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/2077 pinctrl: airoha: an7583: fix gpio21 pin group
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit abf92c45cc82e9a01aa581f9fbc790e78250a4d4 ]
gpio21 pin group refers to gpio22 pin, this is wrong.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +1 -1
@@ -748,7 +748,7 @@ static const int an7583_gpio17_pins[] = { 19 };static const int an7583_gpio18_pins[] = {20 };static const int an7583_gpio19_pins[] = {21 };static const int an7583_gpio20_pins[] = {22 }; -static const int an7583_gpio21_pins[] = {24 }; +static const int an7583_gpio21_pins[] = {23 };static const int an7583_gpio23_pins[] = {25 };static const int an7583_gpio24_pins[] = {26 };static const int an7583_gpio25_pins[] = {27 };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/2077 pinctrl: airoha: an7583: add missed gpio22 pin group
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 9ef86358855d5fd89db019ace33c097d2d752b9d ]
gpio22 pin group is missed, fix it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -0
@@ -749,6 +749,7 @@ static const int an7583_gpio18_pins[] = { 20 };static const int an7583_gpio19_pins[] = {21 };static const int an7583_gpio20_pins[] = {22 };static const int an7583_gpio21_pins[] = {23 }; +static const int an7583_gpio22_pins[] = {24 };static const int an7583_gpio23_pins[] = {25 };static const int an7583_gpio24_pins[] = {26 };static const int an7583_gpio25_pins[] = {27 };
@@ -828,6 +829,7 @@ static const struct pingroup an7583_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio19" , an7583_gpio19),PINCTRL_PIN_GROUP ("gpio20" , an7583_gpio20),PINCTRL_PIN_GROUP ("gpio21" , an7583_gpio21), +PINCTRL_PIN_GROUP ("gpio22" , an7583_gpio22),PINCTRL_PIN_GROUP ("gpio23" , an7583_gpio23),PINCTRL_PIN_GROUP ("gpio24" , an7583_gpio24), PINCTRL_PIN_GROUP("gpio25", an7583_gpio25),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/2077 pinctrl: airoha: an7583: fix phy1_led1 pin function
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit dbe28a2a22a3455d1adbf9fd61d3537603ac3072 ]
phy1_led1 pin function wrongly refers to gpio1 instead of gpio11. Fix it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +1 -1
@@ -1754,7 +1754,7 @@ static const struct airoha_pinctrl_func_group an7583_phy1_led1_func_group[] = { LAN1_LED_MAPPING_MASK, LAN1_PHY_LED_MAP(0)), AIROHA_PINCTRL_PHY_LED1("gpio10", GPIO_LAN2_LED1_MODE_MASK, LAN2_LED_MAPPING_MASK, LAN2_PHY_LED_MAP(0)), - AIROHA_PINCTRL_PHY_LED1("gpio1", GPIO_LAN3_LED1_MODE_MASK, + AIROHA_PINCTRL_PHY_LED1("gpio11", GPIO_LAN3_LED1_MODE_MASK, LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(0)), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/2077 pinctrl: airoha: an7583: remove undefined groups from pcm_spi pin function
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 7b87a686a5ab138b3f8ca3d7e3489d8371c02695 ]
pcm_spi_int, pcm_spi_cs2, pcm_spi_cs3, pcm_spi_cs4 pin groups are not defined, so pcm_spi function can't be applied to these groups.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -4
@@ -877,10 +877,8 @@ static const char *const pcm_spi_groups[] = { "pcm_spi", "pcm_spi_int","pcm_spi_cs2_p156" ,"pcm_spi_cs2_p128" , "pcm_spi_cs3", "pcm_spi_cs4" }; -static const char *const an7583_pcm_spi_groups[] = {"pcm_spi" ,"pcm_spi_int" , -"pcm_spi_rst" ,"pcm_spi_cs1" , -"pcm_spi_cs2" ,"pcm_spi_cs3" , -"pcm_spi_cs4" }; +static const char *const an7583_pcm_spi_groups[] = {"pcm_spi" , +"pcm_spi_rst" ,"pcm_spi_cs1" };static const char *const i2s_groups[] = {"i2s" };static const char *const emmc_groups[] = {"emmc" };static const char *const pnand_groups[] = {"pnand" };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/2077 arm64: dts: allwinner: a523: Add missing GPIO interrupt
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit 6b81aa0c8a4f038712fa549e4d44d8279eeb0440 ]
Even though the Allwinner A523 SoC implements 10 GPIO banks, it has actually registers for 11 IRQ banks, and even an interrupt assigned to the first, non-implemented IRQ bank.
Add that first interrupt to the list of GPIO interrupts, to correct the association between IRQs and GPIO banks.
This fixes GPIO IRQ operation on boards with A523 SoCs, as seen by broken SD card detect functionality, for instance.
--- arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +2 -1
@@ -128,7 +128,8 @@ gpu: gpu@1800000 { pio: pinctrl@2000000 { compatible = "allwinner,sun55i-a523-pinctrl"; reg = <0x2000000 0x800>; - interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, + interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/2077 ASoC: cs35l56: Fix possible uninitialized value in cs35l56_spi_system_reset()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 007699d278a655871b07d45a1268761260d03124 ]
In cs35l56_spi_system_reset() initialize val to zero before using it in the read_poll_timeout(). This prevents testing an uninitialized value if the regmap_read_bypassed() returns an error.
Read errors are intentionally ignored during this loop because the device is resetting (though SPI can't really detect that so shouldn't fail because of that, it's safer to ignore errors and keep polling). Because of this, val must be initialized to something in case the first read fails. The polling loop is looking for a non-zero value, so initializing val to 0 will ensure that the loop continues until a valid state is read from the device or it times out.
--- sound/soc/codecs/cs35l56-shared.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/cs35l56-shared.c +1 -0
@@ -534,6 +534,7 @@ static void cs35l56_spi_system_reset(struct cs35l56_base *cs35l56_base)* The regmap must remain in cache-only until the chip has * booted, so use a bypassed read. */ + val =0 ; ret = read_poll_timeout(regmap_read_bypassed, read_ret, (val > 0) && (val < 0xffffffff), CS35L56_HALO_STATE_POLL_US,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/2077 s390/process: Fix kernel thread function pointer type
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit d0478f5d3cba1095bfdeb43a9b063c10cdebef14 ]
In case of a kernel thread __ret_from_fork() calls the specified function indirectly. Fix the kernel thread function pointer, since kernel threads return an int instead of void.
--- arch/s390/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/process.c +1 -1
@@ -50,7 +50,7 @@ void ret_from_fork(void) asm("ret_from_fork");void __ret_from_fork (struct task_struct *prev,struct pt_regs *regs) { -void (*func)(void *arg); +int (*func)(void *arg);schedule_tail (prev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/2077 Bluetooth: hci_qca: fix NULL pointer dereference in qca_setup() for non-serdev device
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 3ec629fee178d429f01ae843e4ea888de93012bf ]
hu->serdev is NULL for hci_uart attached via non-serdev paths, but qca_setup() unconditionally calls serdev_device_get_drvdata(hu->serdev) and dereferences the result, causing a NULL pointer dereference.
Fix by guarding the dereference with a NULL check, consistent with the rest of qca_setup().
--- drivers/bluetooth/hci_qca.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/bluetooth/hci_qca.c +6 -3
@@ -1916,9 +1916,12 @@ static int qca_setup(struct hci_uart *hu)const char *rampatch_name =qca_get_rampatch_name (hu);int ret;struct qca_btsoc_version ver; -struct qca_serdev *qcadev =serdev_device_get_drvdata (hu->serdev); +struct qca_serdev *qcadev =NULL ;const char *soc_name; +if (hu->serdev) + qcadev =serdev_device_get_drvdata (hu->serdev); + ret =qca_check_speeds (hu);if (ret)return ret;
@@ -1980,7 +1983,7 @@ static int qca_setup(struct hci_uart *hu)case QCA_WCN6750 :case QCA_WCN6855 :case QCA_WCN7850 : -if (qcadev->bdaddr_property_broken) +if (qcadev && qcadev->bdaddr_property_broken)hci_set_quirk (hdev,HCI_QUIRK_BDADDR_PROPERTY_BROKEN );hci_set_aosp_capable (hdev);
@@ -2073,7 +2076,7 @@ static int qca_setup(struct hci_uart *hu)else hu->hdev->set_bdaddr = qca_set_bdaddr; -if (qcadev->support_hfp_hw_offload) +if (qcadev && qcadev->support_hfp_hw_offload)qca_configure_hfp_offload (hdev); qca->fw_version =le16_to_cpu (ver.patch_ver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/2077 Bluetooth: hci_qca: fix NULL pointer dereference in qca_dmp_hdr() for non-serdev device
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 6b8cbcf08de0db62254d1981f83db0f94681ccd9 ]
hu->serdev is NULL for hci_uart attached via non-serdev paths, but qca_dmp_hdr() unconditionally dereferences hu->serdev->dev.driver->name, causing a NULL pointer dereference.
Fix by guarding the dereference with a NULL check and falling back to "hci_ldisc_qca" for the non-serdev case.
--- drivers/bluetooth/hci_qca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +1 -1
@@ -1028,7 +1028,7 @@ static void qca_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb)skb_put_data (skb, buf,strlen (buf));snprintf (buf,sizeof (buf),"Driver: %s\n" , - hu->serdev->dev.driver->name); + hu->serdev ? hu->serdev->dev.driver->name :"hci_ldisc_qca" );skb_put_data (skb, buf,strlen (buf)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/2077 Bluetooth: eir: Fix stack OOB write when prepending the Flags AD
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 6f5fb689fdf80bdd143f22a502f9eb1f3c85e286 ]
eir_create_adv_data() builds the advertising data into a fixed-size buffer ("size", 31 for the legacy path). It may prepend a 3-byte "Flags" AD structure (LE_AD_NO_BREDR on an LE-only controller) and then copies the per-instance data without checking that it still fits:
memcpy(ptr, adv->adv_data, adv->adv_data_len);
tlv_data_max_len() only reserves those 3 bytes when the user-supplied flags carry a managed-flags bit, so an instance added with flags == 0 is accepted with adv_data_len up to the full buffer. At advertise time the flags are still prepended, and the memcpy() writes 3 + adv_data_len bytes into the size-byte buffer:
BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301) Write of size 31 at addr ffff88800a547bdc by task kworker/u9:0/65 Workqueue: hci0 hci_cmd_sync_work __asan_memcpy (mm/kasan/shadow.c:106) eir_create_adv_data (net/bluetooth/eir.c:301) hci_update_adv_data_sync (net/bluetooth/hci_sync.c:1310) hci_schedule_adv_instance_sync (net/bluetooth/hci_sync.c:1817) hci_cmd_sync_work (net/bluetooth/hci_sync.c:332) This frame has 1 object: [32, 64) 'cp'
The "Flags" structure is added by the kernel, not requested by userspace, so only prepend it when it fits together with the instance advertising data; when there is no room for both, drop the flags rather than the user-provided data.
Reachable by a local user with CAP_NET_ADMIN owning an LE-only controller on the legacy advertising path.
--- net/bluetooth/eir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/bluetooth/eir.c +5 -3
@@ -283,10 +283,12 @@ u8 eir_create_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr, u8 size)if (!flags) flags |=mgmt_get_adv_discov_flags (hdev); -/* If flags would still be empty, then there is no need to -* include the "Flags" AD field". +/* Only add the "Flags" if it fits together with the instance +* advertising data; drop it rather than overflow the buffer. */ -if (flags && (ad_len +eir_precalc_len (1 ) <= size)) { +if (flags && + (ad_len +eir_precalc_len (1 ) + + (adv ? adv->adv_data_len :0 ) <= size)) { ptr[0 ] =0x02 ; ptr[1 ] =EIR_FLAGS ; ptr[2 ] = flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 680/2077 Bluetooth: hci_event: fix simultaneous discovery stuck in FINDING
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiajia Liu <[email protected]>
[ Upstream commit 96d006ae6445679436b945593950fd465eba7e76 ]
When hci_inquiry_complete_evt is called between le_scan_disable and le_set_scan_enable_complete and no remote name needs to be resolved, the interleaved discovery with SIMULTANEOUS quirk gets stuck in DISCOVERY_FINDING. le_set_scan_enable_complete does not check inquiry state. No one sets DISCOVERY_STOPPED in this process.
Add state check in le_set_scan_enable_complete and change state if the state is DISCOVERY_FINDING. Tested with AX201 (8087:0026) in Dell Vostro 13. Discovering disabled MGMT Event below is reported when running into the above condition.
@ MGMT Command: Start Discovery (0x0023) {0x0001} [hci0] 10885.970873
Address type: 0x07
BR/EDR
LE Public
LE Random
...
< HCI Command: LE Set Extended Scan Enable #38205 [hci0] 10886.131438
Extended scan: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #38206 [hci0] 10886.133295
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
@ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 10886.133414
Address type: 0x07
BR/EDR
LE Public
LE Random
Discovery: Enabled (0x01)
< HCI Command: Inquiry (0x01|0x0001) plen 5 #38207 [hci0] 10886.133528
Access code: 0x9e8b33 (General Inquiry)
Length: 10.24s (0x08)
Num responses: 0Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4 #38208 [hci0] 10886.141333
Inquiry (0x01|0x0001) ncmd 2
Status: Success (0x00)
...
< HCI Command: LE Set Extended Scan Enable #38242 [hci0] 10896.381802
Extended scan: Disabled (0x00)
Filter duplicates: Disabled (0x00)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)Quoted 1 line
HCI Event: Inquiry Complete (
0x01) plen 1 #38243 [hci0] 10896.383419
Status: Success (0x00)
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #38244 [hci0] 10896.394378
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
@ MGMT Event: Device Found (0x0012) plen 22 {0x0001} [hci0] 10896.394497
LE Address: 88:12:AC:92:43:69
RSSI: -101 dBm (0x9b)
Flags: 0x00000004
Not Connectable
Data length: 8
Company: Xiaomi Inc. (911)
Data[0]:
16-bit Service UUIDs (complete): 1 entry
Xiaomi Inc. (0xfdaa)
@ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 10896.394506
Address type: 0x07
BR/EDR
LE Public
LE Random
Discovery: Disabled (0x00)--- net/bluetooth/hci_event.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/hci_event.c +7 -0
@@ -1769,6 +1769,13 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)hci_dev_clear_flag (hdev,HCI_LE_SCAN ); +if (hdev->discovery.type ==DISCOV_TYPE_INTERLEAVED && +hci_test_quirk (hdev,HCI_QUIRK_SIMULTANEOUS_DISCOVERY ) && + !test_bit (HCI_INQUIRY , &hdev->flags) && + hdev->discovery.state ==DISCOVERY_FINDING ) { +hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); + } +/* The HCI_LE_SCAN_INTERRUPTED flag indicates that we * interrupted scanning due to a connect request. Mark * therefore discovery as stopped.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/2077 Bluetooth: hci_core: Fix UAF in hci_unregister_dev()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordan Walters <[email protected]>
[ Upstream commit 5edcc018fa6e80b2c478454a4a8229c23d67c181 ]
hci_unregister_dev() does not disable cmd_timer and ncmd_timer before the hci_dev structure is freed. If a timeout fires during device teardown, the callback dereferences freed memory (including the hdev->reset function pointer), leading to a use-after-free.
Add disable_delayed_work_sync() calls alongside the existing disable_work_sync() calls to ensure both timers are fully quiesced before teardown proceeds.
--- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/hci_core.c +2 -0
@@ -2671,6 +2671,8 @@ void hci_unregister_dev(struct hci_dev *hdev)disable_work_sync (&hdev->tx_work);disable_work_sync (&hdev->power_on);disable_work_sync (&hdev->error_reset); +disable_delayed_work_sync (&hdev->cmd_timer); +disable_delayed_work_sync (&hdev->ncmd_timer);hci_cmd_sync_clear (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/2077 Bluetooth: btmtk: fix URB leak in alloc_mtk_intr_urb error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
[ Upstream commit f396f4005180928cd9e15e352a6512865d3bc908 ]
When btmtk_isopkt_pad() fails, the previously allocated URB is not freed, leaking the urb structure. Add usb_free_urb() before returning the error.
--- drivers/bluetooth/btmtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +3 -1
@@ -1074,8 +1074,10 @@ struct urb *alloc_mtk_intr_urb(struct hci_dev *hdev, struct sk_buff *skb,if (!urb)return ERR_PTR (-ENOMEM ); -if (btmtk_isopkt_pad (hdev, skb)) +if (btmtk_isopkt_pad (hdev, skb)) { +usb_free_urb (urb);return ERR_PTR (-EINVAL ); + } pipe =usb_sndintpipe (btmtk_data->udev, btmtk_data->isopkt_tx_ep->bEndpointAddress);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/2077 Bluetooth: btintel_pcie: Load IOSF debug regs by controller variant
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Teja Aluvala <[email protected]>
[ Upstream commit e43b33bf8d671c50a45fe5f487819927595bbd50 ]
Load the IOSF DBGC base address based on the controller hardware variant when reading DRAM buffers during a trace dump. Scorpius Peak family controllers (SCP/SCP2/SCP2F) use a different DBGC base address (0xf0d5d500) than Blazar family controllers (BZRI/BZRIW, 0xf3800300).
--- drivers/bluetooth/btintel.h | 1 + drivers/bluetooth/btintel_pcie.c | 30 ++++++++++++++++++++++++------ drivers/bluetooth/btintel_pcie.h | 4 ++++ 3 files changed, 29 insertions(+), 6 deletions(-)
drivers/bluetooth/btintel.h +1 -0
@@ -77,6 +77,7 @@ struct intel_tlv {#define BTINTEL_HWID_BZRU 0x1d/* BlazarU - Meteor Lake */ #define BTINTEL_HWID_SCP 0x1f/* Scorpius Peak - Panther Lake */ #define BTINTEL_HWID_SCP2 0x20/* Scorpius Peak2 - Nova Lake */ +#define BTINTEL_HWID_SCP2F 0x21/* Scorpius Peak2-F - Nova Lake */ #define BTINTEL_HWID_BZRIW 0x22/* BlazarIW - Wildcat Lake */ struct intel_version_tlv {
drivers/bluetooth/btintel_pcie.c +24 -6
@@ -626,9 +626,10 @@ static void *btintel_pcie_copy_tlv(void *dest, enum btintel_pcie_tlv_type type,static int btintel_pcie_read_dram_buffers (struct btintel_pcie_data *data) {u32 offset, prev_size, wr_ptr_status, dump_size, data_len; +u32 status_reg, wrap_reg;struct btintel_pcie_dbgc *dbgc = &data->dbgc;struct hci_dev *hdev = data->hdev; -u8 *pdata, *p, buf_idx; +u8 *pdata, *p, buf_idx, hw_variant;struct intel_tlv *tlv;struct timespec64 now;struct tm tm_now;
@@ -641,7 +642,28 @@ static int btintel_pcie_read_dram_buffers(struct btintel_pcie_data *data)return -EOPNOTSUPP ; - wr_ptr_status =btintel_pcie_rd_dev_mem (data,BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS ); + hw_variant =INTEL_HW_VARIANT (data->cnvi); +switch (hw_variant) { +case BTINTEL_HWID_BZRI : +case BTINTEL_HWID_BZRIW : + status_reg =BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS ; + wrap_reg =BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND ; +break ; +case BTINTEL_HWID_SCP : +case BTINTEL_HWID_SCP2 : +case BTINTEL_HWID_SCP2F : + status_reg =BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS_SCP ; + wrap_reg =BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND_SCP ; +break ; +default : +bt_dev_err (hdev,"Unsupported Intel hardware variant (0x%2.2x)" , + hw_variant); +return -EINVAL ; + } + + wr_ptr_status =btintel_pcie_rd_dev_mem (data, status_reg); + data->dmp_hdr.wrap_ctr =btintel_pcie_rd_dev_mem (data, wrap_reg); + offset = wr_ptr_status &BTINTEL_PCIE_DBG_OFFSET_BIT_MASK ; buf_idx =BTINTEL_PCIE_DBGC_DBG_BUF_IDX (wr_ptr_status);
@@ -718,10 +740,6 @@ static int btintel_pcie_read_dram_buffers(struct btintel_pcie_data *data) sizeof(data->dmp_hdr.write_ptr)); p =btintel_pcie_copy_tlv (p,BTINTEL_WRAP_CTR , &data->dmp_hdr.wrap_ctr,sizeof (data->dmp_hdr.wrap_ctr)); - - data->dmp_hdr.wrap_ctr =btintel_pcie_rd_dev_mem (data, -BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND ); - p =btintel_pcie_copy_tlv (p,BTINTEL_TRIGGER_REASON , &data->dmp_hdr.trigger_reason,sizeof (data->dmp_hdr.trigger_reason)); p = btintel_pcie_copy_tlv(p, BTINTEL_FW_SHA, &data->dmp_hdr.fw_git_sha1,
drivers/bluetooth/btintel_pcie.h +4 -0
@@ -68,6 +68,10 @@#define BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS (BTINTEL_PCIE_DBGC_BASE_ADDR + 0x1C)#define BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND (BTINTEL_PCIE_DBGC_BASE_ADDR + 0x2C) +#define BTINTEL_PCIE_DBGC_BASE_ADDR_SCP (0xf0d5d500) +#define BTINTEL_PCIE_DBGC_CUR_DBGBUFF_STATUS_SCP (BTINTEL_PCIE_DBGC_BASE_ADDR_SCP + 0x1C) +#define BTINTEL_PCIE_DBGC_DBGBUFF_WRAP_ARND_SCP (BTINTEL_PCIE_DBGC_BASE_ADDR_SCP + 0x2C) +#define BTINTEL_PCIE_DBG_IDX_BIT_MASK 0x0F#define BTINTEL_PCIE_DBGC_DBG_BUF_IDX (data) (((data) >> 24) & BTINTEL_PCIE_DBG_IDX_BIT_MASK)#define BTINTEL_PCIE_DBG_OFFSET_BIT_MASK 0xFFFFFF
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/2077 Bluetooth: hci: validate codec capability element length
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit c38fbcdc407925c7088f7e5f11c1fff73d2d35a2 ]
Read Local Codec Capabilities returns a sequence of capability elements. Each element starts with a one-byte length followed by that many payload bytes.
hci_read_codec_capabilities() checks that the skb contains the length byte, but then validates only caps->len against the remaining skb length. A malformed controller response with one remaining byte and caps->len set to one passes that check even though the element needs two bytes. The parser then records a two-byte capability and copies one byte beyond the advertised response payload into the codec list.
Validate the full element size, including the length byte, before adding it to the accumulated capability length. This preserves all well-formed capability elements and drops only truncated controller responses.
--- net/bluetooth/hci_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_codec.c +1 -1
@@ -100,7 +100,7 @@ static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport, caps = (void *)skb->data;if (skb->len <sizeof (*caps)) goto error; -if (skb->len < caps->len) +if (skb->len <sizeof (caps->len) + caps->len) goto error; len +=sizeof (caps->len) + caps->len;skb_pull (skb,sizeof (caps->len) + caps->len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/2077 Bluetooth: vhci: validate devcoredump state before side effects
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit 88c2404a3c59c3126453919388dbd5ed98ed01bd ]
The VHCI force_devcoredump debugfs hook accepts a small test record from userspace. It validates the requested terminal state only after registering, initializing and appending a Bluetooth devcoredump.
As a result, an invalid state returns -EINVAL but still leaves queued devcoredump work behind. With a non-zero timeout field, the rejected write can still emit a devcoredump after the timeout expires.
Reject unsupported states before allocating the skb or changing the HCI devcoredump state machine.
--- drivers/bluetooth/hci_vhci.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/bluetooth/hci_vhci.c +10 -0
@@ -337,7 +337,17 @@ static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,if (copy_from_user (&dump_data, user_buf, count))return -EFAULT ; +switch (dump_data.state) { +case HCI_DEVCOREDUMP_DONE : +case HCI_DEVCOREDUMP_ABORT : +case HCI_DEVCOREDUMP_TIMEOUT : +break ; +default : +return -EINVAL ; + } + data_size = count - offsetof(struct devcoredump_test_data , data); + skb =alloc_skb (data_size,GFP_ATOMIC );if (!skb)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/2077 RDMA/mlx5: Fix mkey creation error flow rollback
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit c70fcfa9881207659ad193ae10a3bd56b2ae3f8a ]
Fix the indices of mkeys destroyed in case of an error in batch mkey creation.
--- drivers/infiniband/hw/mlx5/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/mr.c +1 -1
@@ -294,7 +294,7 @@ static int mlx5r_create_mkeys(struct ib_device *device, struct ib_frmr_key *key, free_in:kfree (in);if (err) -for (; i >0 ; i--) +for (i--; i >=0 ; i--)mlx5_core_destroy_mkey (dev->mdev, handles[i]);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 687/2077 RDMA/mlx5: Fix TPH extraction in FRMR pool key
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit fe683274fee497834d2e6b54b7342642e1f21892 ]
Fix reading the PH value from the FRMR pool key by shifting the pool key to the relevant bits.
--- drivers/infiniband/hw/mlx5/mr.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +9 -7
@@ -31,6 +31,7 @@* SOFTWARE. */ +#include <linux/bitfield.h> #include <linux/kref.h> #include <linux/random.h> #include <linux/debugfs.h>
@@ -163,9 +164,8 @@ static int get_unchangeable_access_flags(struct mlx5_ib_dev *dev,#define MLX5_FRMR_POOLS_KEY_VENDOR_KEY_SUPPORTED \ MLX5_FRMR_POOLS_KEY_ACCESS_MODE_KSM_MASK -#define MLX5_FRMR_POOLS_KERNEL_KEY_PH_SHIFT 16 -#define MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK 0xFF0000 -#define MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK 0xFFFF +#define MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK GENMASK_ULL(23, 16) +#define MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK GENMASK_ULL(15, 0)static struct mlx5_ib_mr * _mlx5_frmr_pool_alloc(struct mlx5_ib_dev *dev, struct ib_umem *umem,
@@ -194,7 +194,8 @@ _mlx5_frmr_pool_alloc(struct mlx5_ib_dev *dev, struct ib_umem *umem, ph ^=MLX5_IB_NO_PH ; mr->ibmr.frmr.key.kernel_vendor_key = - st_index | (ph <<MLX5_FRMR_POOLS_KERNEL_KEY_PH_SHIFT ); +FIELD_PREP (MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK , st_index) | +FIELD_PREP (MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK , ph); err =ib_frmr_pool_pop (&dev->ib_dev, &mr->ibmr);if (err) {kfree (mr);
@@ -271,9 +272,10 @@ static int mlx5r_create_mkeys(struct ib_device *device, struct ib_frmr_key *key, get_mkc_octo_size(access_mode, key->num_dma_blocks));MLX5_SET (mkc, mkc, log_page_size,PAGE_SHIFT ); - st_index = key->kernel_vendor_key & -MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK ; - ph = key->kernel_vendor_key &MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK ; + st_index =FIELD_GET (MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK , + key->kernel_vendor_key); + ph =FIELD_GET (MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK , + key->kernel_vendor_key);if (ph) {/* Normalize ph: swap MLX5_IB_NO_PH for 0 */ if (ph ==MLX5_IB_NO_PH )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 688/2077 RDMA/core: Fix skipped usage for driver built FRMR key
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit 3d7fd88aeff73f25ee740b3a65a3b4dd38ad7783 ]
When creating FRMR handles following a netlink command to pin handles, use the key after driver callback instead of using the key passed directly from user.
--- drivers/infiniband/core/frmr_pools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/frmr_pools.c +1 -1
@@ -426,7 +426,7 @@ int ib_frmr_pools_set_pinned(struct ib_device *device, struct ib_frmr_key *key,if (!handles)return -ENOMEM ; - ret = pools->pool_ops->create_frmrs (device, key, handles, + ret = pools->pool_ops->create_frmrs (device, &driver_key, handles, needed_handles);if (ret) {kfree (handles);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 689/2077 RDMA/core: Fix FRMR aging push to queue error flow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit c6936506ed556ce3ccad36ab999baf2764dd7d25 ]
Aging pools with pinned handles requires moving handles from the active queue to a non-empty inactive queue that might fail on new page allocation, we are currently not handling the fault and leaking any mkey that fails the push.
Fix by Introducing push_queue_to_queue_locked() that fills the destination's partial tail page from the source and then splices the remaining source pages onto the destination, performing no allocation.
Replace the per-handle move loop in age_pinned_pool() and the open-coded splice in pool_aging_work() with calls to the helper. As the helper cannot fail under memory pressure, removing a class of GFP_ATOMIC allocations under the pool lock and simplifying the error flow.
--- drivers/infiniband/core/frmr_pools.c | 53 ++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-)
drivers/infiniband/core/frmr_pools.c +38 -15
@@ -97,13 +97,44 @@ static void destroy_all_handles_in_queue(struct ib_device *device, } } +/* +* Bulk-move all handles from @src into @dst without allocating new pages. +* If @dst has a partial tail page, fill it handle-by-handle from @src first +* to preserve the invariant that only the tail page is partial, then splice +* the remaining @src pages onto @dst. On return @src is empty. +* +* Caller must hold the lock protecting both queues. +*/ +static void splice_frmr_queue_locked (struct frmr_queue *dst, +struct frmr_queue *src) +{ +u32 free_in_tail = dst->ci %NUM_HANDLES_PER_PAGE ; +u32 handle; + +if (free_in_tail) { + free_in_tail =NUM_HANDLES_PER_PAGE - free_in_tail; +while (free_in_tail && src->ci) { + handle =pop_handle_from_queue_locked (src); +push_handle_to_queue_locked (dst, handle); + free_in_tail--; + } + } + +if (src->ci >0 ) { +list_splice_tail_init (&src->pages_list, &dst->pages_list); + dst->num_pages += src->num_pages; + dst->ci += src->ci; + src->num_pages =0 ; + src->ci =0 ; + } +} +static bool age_pinned_pool (struct ib_device *device,struct ib_frmr_pool *pool) {struct ib_frmr_pools *pools = device->frmr_pools;u32 total, to_destroy, destroyed =0 ;bool has_work = false;u32 *handles; -u32 handle;spin_lock (&pool->lock); total = pool->queue.ci + pool->inactive_queue.ci + pool->in_use;
@@ -112,7 +143,7 @@ static bool age_pinned_pool(struct ib_device *device, struct ib_frmr_pool *pool)return false; } - to_destroy = total - pool->pinned_handles; + to_destroy =min (total - pool->pinned_handles, pool->inactive_queue.ci); handles =kcalloc (to_destroy,sizeof (*handles),GFP_ATOMIC );if (!handles) {
@@ -121,15 +152,13 @@ static bool age_pinned_pool(struct ib_device *device, struct ib_frmr_pool *pool) }/* Destroy all excess handles in the inactive queue */ -while (pool->inactive_queue.ci && destroyed < to_destroy) { - handles[destroyed++] =pop_handle_from_queue_locked ( +for (; destroyed < to_destroy; destroyed++) + handles[destroyed] =pop_handle_from_queue_locked ( &pool->inactive_queue); - }/* Move all handles from regular queue to inactive queue */ -while (pool->queue.ci) { - handle =pop_handle_from_queue_locked (&pool->queue); -push_handle_to_queue_locked (&pool->inactive_queue, handle); +if (pool->queue.ci >0 ) { +splice_frmr_queue_locked (&pool->inactive_queue, &pool->queue); has_work = true; }
@@ -158,13 +187,7 @@ static void pool_aging_work(struct work_struct *work)/* Move all pages from regular queue to inactive queue */ spin_lock (&pool->lock);if (pool->queue.ci >0 ) { -list_splice_tail_init (&pool->queue.pages_list, - &pool->inactive_queue.pages_list); - pool->inactive_queue.num_pages = pool->queue.num_pages; - pool->inactive_queue.ci = pool->queue.ci; - - pool->queue.num_pages =0 ; - pool->queue.ci =0 ; +splice_frmr_queue_locked (&pool->inactive_queue, &pool->queue); has_work = true; }spin_unlock (&pool->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 690/2077 RDMA/core: Fix FRMR set pinned push error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit 41a707d0275cdec9ac125e826dd6836fa9623cbc ]
Add destruction of FRMR handles in case the push to the pool fails. This prevents resources leak in case pool page allocation fails.
--- drivers/infiniband/core/frmr_pools.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/core/frmr_pools.c +8 -3
@@ -461,11 +461,16 @@ int ib_frmr_pools_set_pinned(struct ib_device *device, struct ib_frmr_key *key, ret =push_handle_to_queue_locked (&pool->queue, handles[i]);if (ret) - goto end; +break ; } - -end:spin_unlock (&pool->lock); + +if (ret) { +/* Destroy handles created but never pushed to the pool. */ + pools->pool_ops->destroy_frmrs (device, &handles[i], + needed_handles - i); + } +kfree (handles); schedule_aging:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 691/2077 RDMA/core: Avoid NULL dereference on FRMR bad usage
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit 3937243095b5cfed6556bd1ea170790223f3eeb0 ]
In case a driver calls FRMR pop operation without a successful init, return after triggering a warning to avoid the NULL dereference.
--- drivers/infiniband/core/frmr_pools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/frmr_pools.c +3 -1
@@ -529,7 +529,9 @@ int ib_frmr_pool_pop(struct ib_device *device, struct ib_mr *mr)struct ib_frmr_pools *pools = device->frmr_pools;struct ib_frmr_pool *pool; -WARN_ON_ONCE (!device->frmr_pools); +if (WARN_ON_ONCE (!pools)) +return -EINVAL ; + pool =ib_frmr_pool_find (pools, &mr->frmr.key);if (!pool) { pool =create_frmr_pool (device, &mr->frmr.key);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 692/2077 RDMA/core: Fix FRMR handle leak on push failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit 8c76126b866649d8e8acc09a06f2b03b6ff88900 ]
Failure to push a handle to the pool, caused by ENOMEM on queue page allocation, will trigger missing in_use counter update, skewing pool state indefinitely.
Fix that by moving the handling of handle destruction in such case into the FRMR code, ensuring the handle is either pushed to the pool or destroyed inside the same function.
Adjust mlx5_ib call site accordingly.
--- drivers/infiniband/core/frmr_pools.c | 19 +++++++++++-------- drivers/infiniband/hw/mlx5/mr.c | 5 +++-- include/rdma/frmr_pools.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-)
drivers/infiniband/core/frmr_pools.c +11 -8
@@ -549,9 +549,8 @@ EXPORT_SYMBOL(ib_frmr_pool_pop);* @device: The device to push the FRMR handle to. * @mr: The MR containing the FRMR handle to push back to the pool. * -* Returns 0 on success, negative error code on failure. */ -int ib_frmr_pool_push (struct ib_device *device,struct ib_mr *mr) +void ib_frmr_pool_push (struct ib_device *device,struct ib_mr *mr) {struct ib_frmr_pool *pool = mr->frmr.pool;struct ib_frmr_pools *pools = device->frmr_pools;
@@ -559,19 +558,23 @@ int ib_frmr_pool_push(struct ib_device *device, struct ib_mr *mr)int ret;spin_lock (&pool->lock); + pool->in_use--; + ret =push_handle_to_queue_locked (&pool->queue, mr->frmr.handle); +/* Schedule aging every time an empty pool becomes non-empty */ -if (pool->queue.ci ==0 ) +if (!ret && pool->queue.ci ==1 ) schedule_aging = true; - ret =push_handle_to_queue_locked (&pool->queue, mr->frmr.handle); -if (ret ==0 ) - pool->in_use--;spin_unlock (&pool->lock); -if (ret ==0 && schedule_aging) +if (ret) { + pools->pool_ops->destroy_frmrs (device, &mr->frmr.handle,1 ); +return ; + } + +if (schedule_aging)queue_delayed_work (pools->aging_wq, &pool->aging_work,secs_to_jiffies (READ_ONCE (pools->aging_period_sec))); -return ret; }EXPORT_SYMBOL (ib_frmr_pool_push);
drivers/infiniband/hw/mlx5/mr.c +3 -2
@@ -1398,9 +1398,10 @@ static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr)bool is_odp =is_odp_mr (mr);int ret; -if (mr->ibmr.frmr.pool && !mlx5_umr_revoke_mr_with_lock (mr) && - !ib_frmr_pool_push (mr->ibmr.device, &mr->ibmr)) +if (mr->ibmr.frmr.pool && !mlx5_umr_revoke_mr_with_lock (mr)) { +ib_frmr_pool_push (mr->ibmr.device, &mr->ibmr);return 0 ; + }if (is_odp)mutex_lock (&to_ib_umem_odp (mr->umem)->umem_mutex);
include/rdma/frmr_pools.h +1 -1
@@ -34,6 +34,6 @@ int ib_frmr_pools_init(struct ib_device *device, const struct ib_frmr_pool_ops *pool_ops);void ib_frmr_pools_cleanup (struct ib_device *device);int ib_frmr_pool_pop (struct ib_device *device,struct ib_mr *mr); -int ib_frmr_pool_push (struct ib_device *device,struct ib_mr *mr); +void ib_frmr_pool_push (struct ib_device *device,struct ib_mr *mr);#endif /* FRMR_POOLS_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 693/2077 RDMA/core: Add ib_frmr_pool_drop for unrecoverable handles
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit ddbc251be18fb82884ee6e9af634cc9f1171a4d6 ]
A driver that has popped a handle from an FRMR pool can hit failures that leave the handle in a state where it can't safely be returned for reuse. The driver destroys the handle itself, but the pool has no way to learn about it, so the in_use counter drifts upward.
Add ib_frmr_pool_drop to balance the pool's accounting in this case. Every pop is now balanced by exactly one push or drop.
--- drivers/infiniband/core/frmr_pools.c | 15 +++++++++++++++ include/rdma/frmr_pools.h | 1 + 2 files changed, 16 insertions(+)
drivers/infiniband/core/frmr_pools.c +15 -0
@@ -578,3 +578,18 @@ void ib_frmr_pool_push(struct ib_device *device, struct ib_mr *mr) }EXPORT_SYMBOL (ib_frmr_pool_push); + +/* +* Drop a handle previously popped from the pool without returning it for +* reuse. The caller is responsible for destroying the underlying hardware +* resource. +*/ +void ib_frmr_pool_drop (struct ib_mr *mr) +{ +struct ib_frmr_pool *pool = mr->frmr.pool; + +spin_lock (&pool->lock); + pool->in_use--; +spin_unlock (&pool->lock); +} +EXPORT_SYMBOL (ib_frmr_pool_drop);
include/rdma/frmr_pools.h +1 -0
@@ -35,5 +35,6 @@ int ib_frmr_pools_init(struct ib_device *device,void ib_frmr_pools_cleanup (struct ib_device *device);int ib_frmr_pool_pop (struct ib_device *device,struct ib_mr *mr);void ib_frmr_pool_push (struct ib_device *device,struct ib_mr *mr); +void ib_frmr_pool_drop (struct ib_mr *mr);#endif /* FRMR_POOLS_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 694/2077 RDMA/mlx5: Drop FRMR pool handle on UMR revoke failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Guralnik <[email protected]>
[ Upstream commit c37d79dd967d450ea02e0ee2b6438b8534bbd044 ]
When UMR revoke fails during MR cleanup, the handle is left in an unknown state and cannot be returned to the pool. The driver already destroys the mkey via the fallback path, but the pool's in_use counter is never decremented, drifting upward over time.
Call ib_frmr_pool_drop on the revoke-failure path so the pool's accounting stays consistent with the handles it has handed out.
--- drivers/infiniband/hw/mlx5/mr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +9 -3
@@ -1398,9 +1398,11 @@ static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr)bool is_odp =is_odp_mr (mr);int ret; -if (mr->ibmr.frmr.pool && !mlx5_umr_revoke_mr_with_lock (mr)) { -ib_frmr_pool_push (mr->ibmr.device, &mr->ibmr); -return 0 ; +if (mr->ibmr.frmr.pool) { +if (!mlx5_umr_revoke_mr_with_lock (mr)) { +ib_frmr_pool_push (mr->ibmr.device, &mr->ibmr); +return 0 ; + } }if (is_odp)
@@ -1422,6 +1424,10 @@ static int mlx5r_handle_mkey_cleanup(struct mlx5_ib_mr *mr)dma_resv_unlock (to_ib_umem_dmabuf (mr->umem)->attach->dmabuf->resv); } + +if (mr->ibmr.frmr.pool && !ret) +ib_frmr_pool_drop (&mr->ibmr); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 695/2077 fs: efs: remove unneeded debug prints
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxwell Doose <[email protected]>
[ Upstream commit 89009392c80da5da00876c8334ff20028e6e3eb6 ]
The current code uses debug prints conditionally compiled with #ifdef DEBUG. However, that code, when compiled, causes compiler errors due to incompatible formatters and undefined variables, notably:
fs/efs/file.c: In function `efs_get_block':fs/efs/file.c:26:35: error: block' undeclared (first use in this function); did you mean iblock'?
26 | __func__, block, inode->i_blocks, inode->i_size);
| ^~~~~
and:
fs/efs/file.c: In function `efs_bmap':./include/linux/kern_levels.h:5:25: error: format %ld' expects argument of type long int', but argument 4 has type blkcnt_t' {aka long long unsigned int'} [-Werror=format=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~which also extends to the other formatters. As this part of the code has been dead for just about 14 years now, it has not been modernized to stay compatible with the most recent gcc compilers. Fix these issues by removing the debug prints.
--- fs/efs/file.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
fs/efs/file.c +3 -18
@@ -18,16 +18,9 @@ int efs_get_block(struct inode *inode, sector_t iblock,if (create)return error; -if (iblock >= inode->i_blocks) { -#ifdef DEBUG -/* -* i have no idea why this happens as often as it does -*/ -pr_warn ("%s(): block %d >= %ld (filesize %ld)\n" , - __func__, block, inode->i_blocks, inode->i_size); -#endif +if (iblock >= inode->i_blocks)return 0 ; - } + phys =efs_map_block (inode, iblock);if (phys)map_bh (bh_result, inode->i_sb, phys);
@@ -42,16 +35,8 @@ int efs_bmap(struct inode *inode, efs_block_t block) { }/* are we about to read past the end of a file ? */ -if (!(block < inode->i_blocks)) { -#ifdef DEBUG -/* -* i have no idea why this happens as often as it does -*/ -pr_warn ("%s(): block %d >= %ld (filesize %ld)\n" , - __func__, block, inode->i_blocks, inode->i_size); -#endif +if (!(block < inode->i_blocks))return 0 ; - }return efs_map_block (inode, block); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 696/2077 RDMA/mlx5: Remove DCT restrack tracking
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit b136a7af41f796a48665afc6a55907488a3d5500 ]
DCT restrack tracking wasn't working to begin with as it was only tracking the first DCT which was added, since at creation the DCT number isn't yet initialized because the DCT FW object is only created during modify. The following DCT additions were failing silently.
Since the fix isn't trivial and there were no users that required or complained about this issue we are dropping this for now instead of fixing.
--- drivers/infiniband/hw/mlx5/qp.c | 1 + drivers/infiniband/hw/mlx5/restrack.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -3115,6 +3115,7 @@ static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,switch (qp->type) {case MLX5_IB_QPT_DCT : +rdma_restrack_no_track (&qp->ibqp.res); err =create_dct (dev, pd, qp, params);break ;case MLX5_IB_QPT_DCI :
drivers/infiniband/hw/mlx5/restrack.c +0 -3
@@ -178,9 +178,6 @@ static int fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp) ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"REG_UMR" );break ; -case MLX5_IB_QPT_DCT : - ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"DCT" ); -break ;case MLX5_IB_QPT_DCI : ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"DCI" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 697/2077 RDMA/mlx5: Remove raw RSS QP restrack tracking
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 666031fed8f0fdfc29b20d125a628c1b0a04cdaf ]
Raw RSS QP restrack tracking wasn't working to begin with as it was only tracking the first raw RSS QP which was added, since at creation the raw RSS QP number is reserved so the QP number for this qp type was always zero.
The following raw RSS QP additions were always failing silently.
Since the fix isn't trivial and there were no users that required or complained about this issue we are dropping this for now instead of fixing.
--- drivers/infiniband/hw/mlx5/qp.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -3109,6 +3109,7 @@ static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,int err;if (params->is_rss_raw) { +rdma_restrack_no_track (&qp->ibqp.res); err =create_rss_raw_qp_tir (dev, pd, qp, params); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 698/2077 RDMA/mlx5: Fix undefined shift of user RQ WQE size
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit d881d60223aac8fdc12b227d89c76e131e92a9cd ]
set_rq_size() computes the RQ WQE size as "1 << rq_wqe_shift" based on the user-provided rq_wqe_shift, which is only checked to be greater than 32, so shifts of 32 are still accepted. A shift of 31 also overflows a signed integer, leading to undefined behavior.
Use check_shl_overflow() to compute the RQ WQE size and reject any invalid values.
--- drivers/infiniband/hw/mlx5/qp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +4 -7
@@ -451,16 +451,13 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,if (ucmd) { qp->rq.wqe_cnt = ucmd->rq_wqe_count; -if (ucmd->rq_wqe_shift >BITS_PER_BYTE *sizeof (ucmd->rq_wqe_shift)) -return -EINVAL ; qp->rq.wqe_shift = ucmd->rq_wqe_shift; -if ((1 << qp->rq.wqe_shift) / -sizeof (struct mlx5_wqe_data_seg ) < - wq_sig) +if (check_shl_overflow (1 , qp->rq.wqe_shift, &wqe_size)) +return -EINVAL ; +if (wqe_size /sizeof (struct mlx5_wqe_data_seg ) < wq_sig)return -EINVAL ; qp->rq.max_gs = - (1 << qp->rq.wqe_shift) / -sizeof (struct mlx5_wqe_data_seg ) - + wqe_size /sizeof (struct mlx5_wqe_data_seg ) - wq_sig; qp->rq.max_post = qp->rq.wqe_cnt; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 699/2077 RDMA/mlx5: Release the HW‑provided UAR index rather than the SW one
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 449ae7927152e46acbe5f19f97eafdae6d3a96b1 ]
Free the UAR index returned by the hardware.
--- drivers/infiniband/hw/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
@@ -2662,7 +2662,7 @@ static int uar_mmap(struct mlx5_ib_dev *dev, enum mlx5_ib_mmap_cmd cmd,if (!dyn_uar)return err; -mlx5_cmd_uar_dealloc (dev->mdev, idx, context->devx_uid); +mlx5_cmd_uar_dealloc (dev->mdev, uar_index, context->devx_uid); free_bfreg:mlx5_ib_free_bfreg (dev, bfregi, bfreg_dyn_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 700/2077 ASoC: cs35l56: Fix wrong error test on simple_write_to_buffer()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 3073eb1f1143deabbda6a043238ab9d99672e7c8 ]
In cs35l56_cal_data_debugfs_write() fix the if statement that checks for error return to only check for negative values.
Reported by Sashiko:
simple_write_to_buffer() returns the positive number of bytes copied on success. Since the condition returns immediately on any non-zero value, is it possible that the written calibration data is discarded and cs35l56_stash_calibration() is never called?
--- sound/soc/codecs/cs35l56-shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs35l56-shared.c +1 -1
@@ -1260,7 +1260,7 @@ ssize_t cs35l56_cal_data_debugfs_write(struct cs35l56_base *cs35l56_base,return -EMSGSIZE ; ret =simple_write_to_buffer (&cal_data,sizeof (cal_data), ppos, from, count); -if (ret) +if (ret <0 )return ret; ret =cs35l56_stash_calibration (cs35l56_base, &cal_data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 701/2077 ASoC: SOF: Intel: select SND_SOC_SDW_UTILS=y from SND_SOC_SOF_HDA_GENERIC=y
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 67805f57e5b1a8589f89bd48936c65cbbaeec300 ]
When SND_SOC_SOF_HDA_GENERIC=y but SND_SOC_SOF_INTEL_SOUNDWIRE=m, the SND_SOC_SDW_UTILS is also set to =m even though there is a direct link dependency from the hda.c:
aarch64-linux-ld: sound/soc/sof/intel/hda.o: in function `hda_machine_select':
hda.c:(.text+0x21ac): undefined reference to codec_info_list' hda.c:(.text+0x241c): undefined reference to asoc_sdw_get_dai_type' hda.c:(.text+0x25b4): undefined reference to asoc_sdw_get_codec_info_list_count' hda.c:(.text+0x25d8): undefined reference to asoc_sdw_get_codec_info_list_count'
Change this the same way as the other related 'select' statements to allow linking against it.
--- sound/soc/sof/intel/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/intel/Kconfig +1 -1
@@ -329,7 +329,7 @@ config SND_SOC_SOF_HDA_GENERIC select SND_INTEL_DSP_CONFIG select SND_SOC_SOF_HDA_LINK_BASELINE select SND_SOC_SOF_HDA_PROBES - select SND_SOC_SDW_UTILS if SND_SOC_SOF_INTEL_SOUNDWIRE + select SND_SOC_SDW_UTILS if SND_SOC_SOF_INTEL_SOUNDWIRE !=n select SND_SOC_SOF_HDA_MLINK if SND_SOC_SOF_HDA_LINK help This option is not user-selectable but automagically handled by
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 702/2077 ASoC: SOF: Intel: hda-sdw-bpt: select SND_SOF_SOF_HDA_SDW_BPT properly
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 999ec4c29d73ac85b639a31bbc85ad2ec00eb9d7 ]
When SND_SOC_SOF_INTEL_LNL is set, SND_SOF_SOF_HDA_SDW_BPT must also be enabled, in order to let the soundwire support call into it.
However, there are configurations with SND_SOF_SOF_HDA_SDW_BPT=m and SND_SOF_SOF_HDA_SDW_BPT=m but SOUNDWIRE_INTEL=y, which still lead to a link failure:
aarch64-linux-ld: drivers/soundwire/intel_ace2x.o: in function `intel_ace2x_bpt_wait':
intel_ace2x.c:(.text+0xfc8): undefined reference to `hda_sdw_bpt_wait'
aarch64-linux-ld: drivers/soundwire/intel_ace2x.o: in function `intel_ace2x_bpt_send_async':
intel_ace2x.c:(.text+0x1ff8): undefined reference to `hda_sdw_bpt_get_buf_size_alignment'
Address this by moving the 'select SND_SOF_SOF_HDA_SDW_BPT' into SND_SOC_SOF_HDA_GENERIC.
--- sound/soc/sof/intel/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/Kconfig +2 -2
@@ -266,10 +266,8 @@ config SND_SOC_SOF_METEORLAKE config SND_SOC_SOF_INTEL_LNL tristate - select SOUNDWIRE_INTEL if SND_SOC_SOF_INTEL_SOUNDWIRE != n select SND_SOC_SOF_HDA_GENERIC select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE - select SND_SOF_SOF_HDA_SDW_BPT if SND_SOC_SOF_INTEL_SOUNDWIRE != n select SND_SOC_SOF_IPC4 select SND_SOC_SOF_INTEL_MTL
@@ -331,6 +329,8 @@ config SND_SOC_SOF_HDA_GENERIC select SND_SOC_SOF_HDA_PROBES select SND_SOC_SDW_UTILS if SND_SOC_SOF_INTEL_SOUNDWIRE !=n select SND_SOC_SOF_HDA_MLINK if SND_SOC_SOF_HDA_LINK + select SND_SOF_SOF_HDA_SDW_BPT if SND_SOC_SOF_INTEL_LNL != n && \ + SND_SOC_SOF_INTEL_SOUNDWIRE !=n help This option is not user-selectable but automagically handled by 'select' statements at a higher level.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 703/2077 ASoC: codecs: hdac_hdmi: Validate written enum value
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 0b08baeccdcf52fad328ad645f5b4fbee04eea34 ]
hdac_hdmi_set_pin_port_mux() uses the written enum value to index the texts array before calling snd_soc_dapm_put_enum_double(), which validates that the value is within the enum item range.
An out-of-range value can therefore make the driver read past the texts array before the helper rejects the write. Move the lookup after the helper has accepted the value.
--- sound/soc/codecs/hdac_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/hdac_hdmi.c +3 -1
@@ -911,12 +911,14 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,struct hdac_device *hdev =dev_to_hdac_dev (dev);struct hdac_hdmi_priv *hdmi =hdev_to_hdmi_priv (hdev);struct hdac_hdmi_pcm *pcm; -const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0 ]]; +const char *cvt_name; ret =snd_soc_dapm_put_enum_double (kcontrol, ucontrol);if (ret <0 )return ret; + cvt_name = e->texts[ucontrol->value.enumerated.item[0 ]]; +if (port ==NULL )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 704/2077 ASoC: meson: aiu: Validate written enum values
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit d65adf85477247be04ac86886f8edfaa047b5d4a ]
The AIU HDMI and internal codec mux put callbacks use the written enum value with snd_soc_enum_item_to_val() before checking whether the value is valid for the enumeration.
Reject out-of-range values before converting the enum item, matching the validation already done by the G12A HDMI and internal codec mux controls.
--- sound/soc/meson/aiu-acodec-ctrl.c | 3 +++ sound/soc/meson/aiu-codec-ctrl.c | 3 +++ 2 files changed, 6 insertions(+)
sound/soc/meson/aiu-acodec-ctrl.c +3 -0
@@ -36,6 +36,9 @@ static int aiu_acodec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mux, changed; +if (ucontrol->value.enumerated.item[0 ] >= e->items) +return -EINVAL ; + mux =snd_soc_enum_item_to_val (e, ucontrol->value.enumerated.item[0 ]); changed = snd_soc_component_test_bits(component, e->reg, CTRL_DIN_LRCLK_SRC,
sound/soc/meson/aiu-codec-ctrl.c +3 -0
@@ -28,6 +28,9 @@ static int aiu_codec_ctrl_mux_put_enum(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mux, changed; +if (ucontrol->value.enumerated.item[0 ] >= e->items) +return -EINVAL ; + mux =snd_soc_enum_item_to_val (e, ucontrol->value.enumerated.item[0 ]); changed = snd_soc_component_test_bits(component, e->reg, CTRL_DATA_SEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 705/2077 ASoC: fsl: fsl_audmix: Validate written enum values
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 3cd17e4e2871114d5579fa7bc8da66faf7fc1930 ]
fsl_audmix_put_mix_clk_src() and fsl_audmix_put_out_src() convert the user-provided enum item with snd_soc_enum_item_to_val() before checking whether the item is within the enum's item count.
The generic snd_soc_put_enum_double() helper performs that validation, but these callbacks use the converted value first: the clock-source path tests it with BIT(), and the output-source path indexes the prms transition table with it.
Reject out-of-range enum items before converting them.
--- sound/soc/fsl/fsl_audmix.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/fsl/fsl_audmix.c +6 -0
@@ -117,6 +117,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol,unsigned int *item = ucontrol->value.enumerated.item;unsigned int reg_val, val, mix_clk; +if (item[0 ] >= e->items) +return -EINVAL ; +/* Get current state */ reg_val =snd_soc_component_read (comp,FSL_AUDMIX_CTR ); mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK)
@@ -157,6 +160,9 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol,unsigned int reg_val, val, mask =0 , ctr =0 ;int ret; +if (item[0 ] >= e->items) +return -EINVAL ; +/* Get current state */ reg_val =snd_soc_component_read (comp,FSL_AUDMIX_CTR );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 706/2077 ASoC: tegra: tegra210_ahub: Validate written enum value
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 1d8aabb413b5638670dfd1162169edc0ba276a2e ]
tegra_ahub_put_value_enum() reads e->values[item[0]] before checking whether item[0] is within the enum item range. The existing check therefore happens too late to prevent an out-of-range read of the values array.
Move the check before the array access.
--- sound/soc/tegra/tegra210_ahub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/tegra/tegra210_ahub.c +3 -1
@@ -62,13 +62,15 @@ static int tegra_ahub_put_value_enum(struct snd_kcontrol *kctl,struct snd_soc_dapm_update update[TEGRA_XBAR_UPDATE_MAX_REG ] = { };int val_bytes =snd_soc_component_regmap_val_bytes (cmpnt);unsigned int *item = uctl->value.enumerated.item; -unsigned int value = e->values[item[0 ]]; +unsigned int value;unsigned int i, bit_pos, reg_idx =0 , reg_val =0 ;int change =0 ;if (item[0 ] >= e->items)return -EINVAL ; + value = e->values[item[0 ]]; +if (value) {/* Get the register index and value to set */ reg_idx = (value -1 ) / (8 * val_bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 707/2077 ASoC: topology: Check PCM and DAI name strings before use
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit b7e44d1986d6671342c19b82192189ca5db5dab7 ]
Topology objects store several PCM and DAI names in fixed-size UAPI arrays. Other topology parser paths validate these fields with bounded strnlen() checks before using them as C strings, but the PCM and DAI paths still pass some fixed-size arrays directly to strlen(), devm_kstrdup(), DAI lookup, and diagnostic prints.
A malformed topology blob with a non-NUL-terminated PCM, DAI, or stream capability name can therefore make the parser read past the end of the fixed-size field.
Reject unterminated PCM and DAI name fields before consuming them as C strings.
--- sound/soc/soc-topology.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
sound/soc/soc-topology.c +34 -3
@@ -1326,9 +1326,24 @@ static int soc_tplg_dapm_complete(struct soc_tplg *tplg)return ret; } +static int soc_tplg_check_name (const char *name) +{ +if (strnlen (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) == +SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) +return -EINVAL ; + +return 0 ; +} +static int set_stream_info (struct soc_tplg *tplg,struct snd_soc_pcm_stream *stream,struct snd_soc_tplg_stream_caps *caps) { +int ret; + + ret =soc_tplg_check_name (caps->name); +if (ret) +return ret; + stream->stream_name =devm_kstrdup (tplg->dev, caps->name,GFP_KERNEL );if (!stream->stream_name)return -ENOMEM ;
@@ -1380,7 +1395,11 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,if (dai_drv ==NULL )return -ENOMEM ; -if (strlen (pcm->dai_name)) { + ret =soc_tplg_check_name (pcm->dai_name); +if (ret) + goto err; + +if (pcm->dai_name[0 ]) { dai_drv->name =devm_kstrdup (tplg->dev, pcm->dai_name,GFP_KERNEL );if (!dai_drv->name) { ret = -ENOMEM ;
@@ -1486,7 +1505,11 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,if (tplg->ops) link->dobj.unload = tplg->ops->link_unload; -if (strlen (pcm->pcm_name)) { + ret =soc_tplg_check_name (pcm->pcm_name); +if (ret) + goto err; + +if (pcm->pcm_name[0 ]) { link->name =devm_kstrdup (tplg->dev, pcm->pcm_name,GFP_KERNEL ); link->stream_name =devm_kstrdup (tplg->dev, pcm->pcm_name,GFP_KERNEL );if (!link->name || !link->stream_name) {
@@ -1496,7 +1519,11 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, } link->id =le32_to_cpu (pcm->pcm_id); -if (strlen (pcm->dai_name)) { + ret =soc_tplg_check_name (pcm->dai_name); +if (ret) + goto err; + +if (pcm->dai_name[0 ]) { link->cpus->dai_name =devm_kstrdup (tplg->dev, pcm->dai_name,GFP_KERNEL );if (!link->cpus->dai_name) { ret = -ENOMEM ;
@@ -1848,6 +1875,10 @@ static int soc_tplg_dai_config(struct soc_tplg *tplg,memset (&dai_component,0 ,sizeof (dai_component)); + ret =soc_tplg_check_name (d->dai_name); +if (ret) +return ret; + dai_component.dai_name = d->dai_name; dai =snd_soc_find_dai (&dai_component);if (!dai) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 708/2077 net: dsa: qca8k: fix led devicename when using external mdio bus
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Moussalem <[email protected]>
[ Upstream commit 0b7b378ce6cafbb948786cb6f17f406d94016c8c ]
The qca8k dsa switch can use either an external or internal mdio bus. This depends on whether the mdio node is defined under the switch node itself. Upon registering the internal mdio bus, the internal_mdio_bus of the dsa switch is assigned to this bus. When an external mdio bus is used, the driver still uses the internal_mdio_bus id which is used to create the device names of the leds.
This leads to the leds being prefixed with '(efault)' as the internal_mii_bus is null. So let's fix this by adding a null check and use the devicename of the external bus instead when an external bus is configured.
--- drivers/net/dsa/qca/qca8k-leds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/qca/qca8k-leds.c +2 -1
@@ -429,7 +429,8 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p init_data.fwnode = led; init_data.devname_mandatory = true; init_data.devicename =kasprintf (GFP_KERNEL ,"%s:0%d" , - priv->internal_mdio_bus->id, + priv->internal_mdio_bus ? + priv->internal_mdio_bus->id : priv->bus->id, port_num);if (!init_data.devicename) {fwnode_handle_put (led);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 709/2077 net/sched: cls_flow: Dont expose folded kernel pointers
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f294fc71c4a0fa4964f6428a1b4e7929c1d83125 ]
The flow classifier falls back to addr_fold() for fields that are missing from packet headers. In map mode, userspace controls mask, xor, rshift, addend and divisor, and can observe the resulting classid through class statistics. This allows a tc classifier in a user/network namespace to recover the 32-bit folded value of skb->sk, skb_dst() or skb_nfct().
Align with standard kernel practices for pointer hashing and replace the XOR folding with a keyed siphash (which is cryptographically secure)
--- net/sched/cls_flow.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/sched/cls_flow.c +9 -3
@@ -21,6 +21,7 @@#include <net/inet_sock.h> #include <net/pkt_cls.h> +#include <linux/siphash.h> #include <net/ip.h> #include <net/route.h> #include <net/flow_dissector.h>
@@ -57,11 +58,15 @@ struct flow_filter {struct rcu_work rwork; }; +static siphash_aligned_key_t flow_keys_secret__read_mostly ; +static inline u32 addr_fold (void *addr) { -unsigned long a = (unsigned long )addr; - -return (a &0xFFFFFFFF ) ^ (BITS_PER_LONG >32 ? a >>32 :0 ); +#ifdef CONFIG_64BIT +return (u32 )siphash_1u64 ((u64 )addr, &flow_keys_secret); +#else +return (u32 )siphash_1u32 ((u32 )addr, &flow_keys_secret); +#endif }static u32 flow_get_src (const struct sk_buff *skb,const struct flow_keys *flow)
@@ -596,6 +601,7 @@ static int flow_init(struct tcf_proto *tp)return -ENOBUFS ;INIT_LIST_HEAD (&head->filters);rcu_assign_pointer (tp->root, head); +net_get_random_once (&flow_keys_secret,sizeof (flow_keys_secret));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 710/2077 ipv4: fib: Dont dump dying fib_info in fib_leaf_notify().
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 06b693d2eb6651a63ad85bad8673de3b7d4edd6d ]
syzbot reported use-after-free in nsim_fib4_prepare_event(). [0]
The problem is that the following functions call fib_info_hold() / refcount_inc() while dumping fib_info under RCU, which is unsafe.
* mlxsw_sp_router_fib4_event()
* rocker_router_fib_event()
* nsim_fib4_prepare_event()
refcount_inc_not_zero() must be used, but it would be too late there.
Let's guarantee the lifetime of fib_info in fib_leaf_notify().
Note that IPv6 does not need the corresponding change since fib6_table_dump() holds fib6_table.tb6_lock.
[0]:refcount_t: addition on 0; use-after-free.
WARNING: lib/refcount.c:25 at refcount_warn_saturate+0x9f/0x110 lib/refcount.c:25, CPU#0: kworker/u8:15/3420
Modules linked in:
CPU: 0 UID: 0 PID: 3420 Comm: kworker/u8:15 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Workqueue: netns cleanup_net
RIP: 0010:refcount_warn_saturate+0x9f/0x110 lib/refcount.c:25
Code: eb 66 85 db 74 3e 83 fb 01 75 4c e8 1b f1 22 fd 48 8d 3d 84 cb f1 0a 67 48 0f b9 3a eb 4a e8 08 f1 22 fd 48 8d 3d 81 cb f1 0a <67> 48 0f b9 3a eb 37 e8 f5 f0 22 fd 48 8d 3d 7e cb f1 0a 67 48 0f
RSP: 0018:ffffc9000f2c7270 EFLAGS: 00010293
RAX: ffffffff84a18858 RBX: 0000000000000002 RCX: ffff888032ff9ec0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff8f9353e0
RBP: 0000000000000000 R08: ffff888032ff9ec0 R09: 0000000000000005
R10: 0000000000000100 R11: 0000000000000004 R12: ffff8880570cc000
R13: dffffc0000000000 R14: ffff88802b40563c R15: ffff8880570cc000
FS: 0000000000000000(0000) GS:ffff888126173000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb1f4d5d000 CR3: 000000006072a000 CR4: 00000000003526f0
Call Trace:
<TASK>
__refcount_add include/linux/refcount.h:-1 [inline]
__refcount_inc include/linux/refcount.h:366 [inline]
refcount_inc include/linux/refcount.h:383 [inline]
fib_info_hold include/net/ip_fib.h:629 [inline]
nsim_fib4_prepare_event drivers/net/netdevsim/fib.c:930 [inline]
nsim_fib_event_schedule_work drivers/net/netdevsim/fib.c:1000 [inline]
nsim_fib_event_nb+0x1055/0x1240 drivers/net/netdevsim/fib.c:1043
call_fib_notifier+0x45/0x80 net/core/fib_notifier.c:25
call_fib_entry_notifier net/ipv4/fib_trie.c:90 [inline]
fib_leaf_notify net/ipv4/fib_trie.c:2176 [inline]
fib_table_notify net/ipv4/fib_trie.c:2194 [inline]
fib_notify+0x36b/0x5e0 net/ipv4/fib_trie.c:2217
fib_net_dump net/core/fib_notifier.c:70 [inline]
register_fib_notifier+0x184/0x360 net/core/fib_notifier.c:108
nsim_fib_create+0x85d/0x9f0 drivers/net/netdevsim/fib.c:1596
nsim_dev_reload_create drivers/net/netdevsim/dev.c:1604 [inline]
nsim_dev_reload_up+0x374/0x7c0 drivers/net/netdevsim/dev.c:1058
devlink_reload+0x501/0x8d0 net/devlink/dev.c:475
devlink_pernet_pre_exit+0x1ff/0x420 net/devlink/core.c:558
ops_pre_exit_list net/core/net_namespace.c:161 [inline]
ops_undo_list+0x187/0x940 net/core/net_namespace.c:234
cleanup_net+0x56e/0x800 net/core/net_namespace.c:702
process_one_work kernel/workqueue.c:3314 [inline]
process_scheduled_works+0xb5d/0x1860 kernel/workqueue.c:3397
worker_thread+0xa53/0xfc0 kernel/workqueue.c:3478
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>--- include/net/ip_fib.h | 5 +++++ net/ipv4/fib_trie.c | 4 ++++ 2 files changed, 9 insertions(+)
include/net/ip_fib.h +5 -0
@@ -629,6 +629,11 @@ static inline void fib_info_hold(struct fib_info *fi)refcount_inc (&fi->fib_clntref); } +static inline bool fib_info_hold_safe (struct fib_info *fi) +{ +return refcount_inc_not_zero (&fi->fib_clntref); +} +static inline void fib_info_put (struct fib_info *fi) {if (refcount_dec_and_test (&fi->fib_clntref))
net/ipv4/fib_trie.c +4 -0
@@ -2172,10 +2172,14 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,if (fa->fa_slen == last_slen)continue ; +if (!fib_info_hold_safe (fa->fa_info)) +continue ; + last_slen = fa->fa_slen; err =call_fib_entry_notifier (nb,FIB_EVENT_ENTRY_REPLACE , l->key,KEYLENGTH - fa->fa_slen, fa, extack); +fib_info_put (fa->fa_info);if (err)return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 711/2077 net: fib_rules: Dont dump dying fib_rule in fib_rules_dump().
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 2821e85c058f81c9948a2fb1a634f7b47457d51c ]
rocker_router_fib_event() calls fib_rule_get() during RCU dump.
If the fib_rule is dying, refcount_inc() will complain about it.
Let's call refcount_inc_not_zero() in fib_rules_dump().
--- include/net/fib_rules.h | 5 +++++ net/core/fib_rules.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/net/fib_rules.h +5 -0
@@ -111,6 +111,11 @@ static inline void fib_rule_get(struct fib_rule *rule)refcount_inc (&rule->refcnt); } +static inline bool fib_rule_get_safe (struct fib_rule *rule) +{ +return refcount_inc_not_zero (&rule->refcnt); +} +static inline void fib_rule_put (struct fib_rule *rule) {if (refcount_dec_and_test (&rule->refcnt))
net/core/fib_rules.c +5 -1
@@ -349,7 +349,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,if (err != -EAGAIN ) {if ((arg->flags &FIB_LOOKUP_NOREF ) || -likely (refcount_inc_not_zero (&rule->refcnt))) { +likely (fib_rule_get_safe (rule))) { arg->rule = rule; goto out; }
@@ -410,8 +410,12 @@ int fib_rules_dump(struct net *net, struct notifier_block *nb, int family,if (!ops)return -EAFNOSUPPORT ;list_for_each_entry_rcu (rule, &ops->rules_list, list) { +if (!fib_rule_get_safe (rule)) +continue ; + err =call_fib_rule_notifier (nb,FIB_EVENT_RULE_ADD , rule, family, extack); +fib_rule_put (rule);if (err)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 712/2077 bridge: cfm: reject invalid CCM interval at configuration time
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit f3e02edd8322b31b8e6517faa6ba053bf29d1e26 ]
ccm_tx_work_expired() re-arms itself via queue_delayed_work() using the configured exp_interval converted by interval_to_us(). When exp_interval is BR_CFM_CCM_INTERVAL_NONE or out of range, interval_to_us() returns 0, causing the worker to fire immediately in a tight loop that allocates skbs until OOM.
Fix this by validating exp_interval at configuration time:
- Constrain IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL to the valid range [BR_CFM_CCM_INTERVAL_3_3_MS, BR_CFM_CCM_INTERVAL_10_MIN] in the netlink policy so userspace cannot set an invalid value.
- Reject starting CCM TX in br_cfm_cc_ccm_tx() when exp_interval has not yet been configured (defaults to 0 from kzalloc).
--- net/bridge/br_cfm.c | 6 ++++++ net/bridge/br_cfm_netlink.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
net/bridge/br_cfm.c +6 -0
@@ -805,6 +805,12 @@ int br_cfm_cc_ccm_tx(struct net_bridge *br, const u32 instance, goto save; } +if (!interval_to_us (mep->cc_config.exp_interval)) { +NL_SET_ERR_MSG_MOD (extack, +"Invalid CCM interval" ); +return -EINVAL ; + } +/* Start delayed work to transmit CCM frames. It is done with zero delay * to send first frame immediately */
net/bridge/br_cfm_netlink.c +3 -1
@@ -34,7 +34,9 @@ br_cfm_cc_config_policy[IFLA_BRIDGE_CFM_CC_CONFIG_MAX + 1] = { [IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC] = { .type = NLA_REJECT }, [IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE] = { .type = NLA_U32 }, [IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE] = { .type = NLA_U32 }, - [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL] = { .type = NLA_U32 }, + [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL ] = +NLA_POLICY_RANGE (NLA_U32 ,BR_CFM_CCM_INTERVAL_3_3_MS , + BR_CFM_CCM_INTERVAL_10_MIN), [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID ] = { .type = NLA_BINARY, .len = CFM_MAID_LENGTH }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 713/2077 sctp: validate embedded address parameter length
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit e9361d0ca55c4af12aac09e2572852fa91046229 ]
sctp_verify_asconf() and sctp_verify_param() only validate ADD_IP, DEL_IP, and SET_PRIMARY parameters against a fixed minimum size of sizeof(struct sctp_addip_param) + sizeof(struct sctp_paramhdr). This ensures the outer parameter is large enough to contain an embedded address parameter header, but does not verify that the embedded address parameter's declared length fits within the bounds of the outer parameter.
Later, sctp_process_param() and sctp_process_asconf_param() extract the embedded address parameter and pass it to af->from_addr_param(), which uses the address parameter length to parse the variable-length address payload. A malformed peer can therefore advertise an embedded address parameter length that exceeds the remaining bytes in the enclosing parameter.
Validate that addr_param->p.length does not exceed the space available after the sctp_addip_param header before processing the embedded address parameter. Reject malformed parameters when the embedded address length extends beyond the enclosing parameter bounds.
This prevents out-of-bounds reads when parsing malformed parameters carried in INIT or ASCONF processing paths.
--- net/sctp/sm_make_chunk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/sctp/sm_make_chunk.c +8 -2
@@ -2641,6 +2641,9 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through; addr_param = param.v +sizeof (struct sctp_addip_param ); +if (ntohs (addr_param->p.length) > +ntohs (param.p->length) -sizeof (struct sctp_addip_param )) +break ; af =sctp_get_af_specific (param_type2af (addr_param->p.type));if (!af)
@@ -3039,13 +3042,16 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,union sctp_addr addr;struct sctp_af *af; - addr_param = (void *)asconf_param +sizeof (*asconf_param); -if (asconf_param->param_hdr.type !=SCTP_PARAM_ADD_IP && asconf_param->param_hdr.type !=SCTP_PARAM_DEL_IP && asconf_param->param_hdr.type !=SCTP_PARAM_SET_PRIMARY )return SCTP_ERROR_UNKNOWN_PARAM ; + addr_param = (void *)asconf_param +sizeof (*asconf_param); +if (ntohs (addr_param->p.length) > +ntohs (asconf_param->param_hdr.length) -sizeof (*asconf_param)) +return SCTP_ERROR_PROTO_VIOLATION ; +switch (addr_param->p.type) {case SCTP_PARAM_IPV6_ADDRESS :if (!asoc->peer.ipv6_address)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 714/2077 net: pfcp: allocate per-cpu tstats for PFCP netdevs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit 24041543da8cd84eb5d8ae738c534372fff54820 ]
PFCP uses dev_get_tstats64() as its ndo_get_stats64 callback, but pfcp_link_setup() does not request NETDEV_PCPU_STAT_TSTATS. The net core therefore leaves dev->tstats NULL for PFCP devices.
Creating a PFCP rtnetlink device can immediately ask the new netdev for stats while building the RTM_NEWLINK notification. That reaches dev_get_tstats64() and dereferences the NULL dev->tstats pointer.
Set pcpu_stat_type to NETDEV_PCPU_STAT_TSTATS during PFCP link setup so the net core allocates the storage expected by dev_get_tstats64().
--- drivers/net/pfcp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/pfcp.c +1 -0
@@ -148,6 +148,7 @@ static void pfcp_link_setup(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_flags |=IFF_NO_QUEUE ; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;netif_keep_dst (dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 715/2077 net: Stop leased rxq before uninstalling its memory provider
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 37314c9dbe95b4d924c7b61aaf563cec4f4e4133 ]
netif_rxq_cleanup_unlease() tears down the memory provider that was installed on a physical RX queue through a netkit queue lease. It currently revokes the provider's DMA mappings before stopping the physical queue:
__netif_mp_uninstall_rxq(virt_rxq, p); /* DMA unmap */
__netif_mp_close_rxq(phys_rxq->dev, rxq_idx, p); /* queue stop */
This inverts the ordering used by the regular teardown paths (normal device unregister and the io_uring zcrx close path), which stop the queue before revoking the provider's mappings.
With the physical queue still live, its NAPI can keep consuming net_iov entries from the page_pool alloc cache after the __netif_mp_uninstall_rxq() has already cleared their dma_addr, opening a window for the device to DMA to a stale or zero address.
Fix it by swapping the two calls so the queue is stopped (and its NAPI quiesced) before the provider is uninstalled. No functional regression was observed across repeated runs of the nk_qlease.py HW selftest, which exercises the lease teardown path; this was tested against fbnic QEMU emulation.
--- net/core/netdev_rx_queue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/netdev_rx_queue.c +4 -4
@@ -338,12 +338,12 @@ void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq,void netif_rxq_cleanup_unlease (struct netdev_rx_queue *phys_rxq,struct netdev_rx_queue *virt_rxq) { -struct pp_memory_provider_params *p = &phys_rxq->mp_params;unsigned int rxq_idx =get_netdev_rx_queue_index (phys_rxq); +struct pp_memory_provider_params p = phys_rxq->mp_params; -if (!p->mp_ops) +if (!p.mp_ops)return ; -__netif_mp_uninstall_rxq (virt_rxq, p); -__netif_mp_close_rxq (phys_rxq->dev, rxq_idx, p); +__netif_mp_close_rxq (phys_rxq->dev, rxq_idx, &p); +__netif_mp_uninstall_rxq (virt_rxq, &p); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 716/2077 net/sched: sch_hfsc: Dont make class passive twice
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 90b662ea25f5e83bb3b8ccec5b93ced810b92fb8 ]
update_vf() is called from two places for the same class during a single dequeue when the class's child qdisc (e.g. codel/fq_codel) drops its last packets while dequeuing:
1. The child calls qdisc_tree_reduce_backlog(), which, now that the child is empty, invokes hfsc_qlen_notify() -> update_vf(cl, 0, 0) and turns the class passive (cl_nactive is decremented up the hierarchy).
2. hfsc_dequeue() then calls update_vf(cl, qdisc_pkt_len(skb), cur_time) to charge the dequeued bytes.
On the second call the class is already passive, but its child qdisc is still empty, so update_vf() arms go_passive again:
if (cl->qdisc->q.qlen == 0 && cl->cl_flags & HFSC_FSC)
go_passive = 1;The leaf is then skipped by the cl_nactive == 0 check inside the loop, which does not clear go_passive, so the stale go_passive propagates to the parent and decrements its cl_nactive a second time. A parent that still has other active children is driven to cl_nactive == 0 and removed from the vttree, even though those siblings are still backlogged. They are never dequeued again and the qdisc stalls.
Fix this by only arming go_passive when the class is actually active, so an already-passive class no longer triggers a second passive transition. The byte accounting (cl->cl_total += len) still runs for every ancestor, so dequeued bytes continue to be counted exactly once.
--- net/sched/sch_hfsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_hfsc.c +1 -1
@@ -753,7 +753,7 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time)u64 f;/* , myf_bound, delta; */ int go_passive =0 ; -if (cl->qdisc->q.qlen ==0 && cl->cl_flags &HFSC_FSC ) +if (cl->qdisc->q.qlen ==0 && cl->cl_flags &HFSC_FSC && cl->cl_nactive) go_passive =1 ;for (; cl->cl_parent !=NULL ; cl = cl->cl_parent) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 717/2077 tipc: require net admin for TIPCv2 netlink mutators
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 86b0c540e2ea397cde021eecd24145f7c16a3d4e ]
TIPCv2 registers mutating generic-netlink operations without admin permission flags. Generic netlink only checks CAP_NET_ADMIN when an operation sets GENL_ADMIN_PERM or GENL_UNS_ADMIN_PERM, so a local unprivileged process can currently change TIPC state through commands such as TIPC_NL_NET_SET, TIPC_NL_KEY_SET, TIPC_NL_KEY_FLUSH, and bearer enable/disable.
The legacy TIPC netlink API already checks netlink_net_capable(..., CAP_NET_ADMIN) for administrative commands. Give the TIPCv2 mutators the equivalent generic-netlink gate. Use GENL_UNS_ADMIN_PERM, which maps to the same namespace-aware CAP_NET_ADMIN check that netlink_net_capable() performs, so the behaviour matches the legacy path and keeps working for CAP_NET_ADMIN holders in a non-initial user namespace (containers).
A QEMU/KASAN repro run as uid/gid 65534 with zero effective capabilities previously succeeded in changing the network id and node identity, setting and flushing key material, and enabling/disabling a UDP bearer. With this patch applied the same operations fail with -EPERM.
--- net/tipc/netlink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/tipc/netlink.c +12 -0
@@ -152,11 +152,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_BEARER_DISABLE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_disable, }, { .cmd = TIPC_NL_BEARER_ENABLE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_enable, }, {
@@ -168,11 +170,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_BEARER_ADD, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_add, }, { .cmd = TIPC_NL_BEARER_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_set, }, {
@@ -197,11 +201,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_LINK_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_link, }, { .cmd = TIPC_NL_LINK_RESET_STATS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_reset_link_stats, }, {
@@ -213,6 +219,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_MEDIA_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_media_set, }, {
@@ -228,6 +235,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_NET_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_net_set, }, {
@@ -238,6 +246,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_MON_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_monitor, }, {
@@ -255,6 +264,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_PEER_REMOVE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_peer_rm, },#ifdef CONFIG_TIPC_MEDIA_UDP
@@ -269,11 +279,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_KEY_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_key, }, { .cmd = TIPC_NL_KEY_FLUSH, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_flush_key, }, #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 718/2077 tipc: prevent snt_unacked underflow on CONN_ACK
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit ab3e10b44ba5411779aac7afd2477917dd77750f ]
tipc_sk_conn_proto_rcv() subtracts the peer-supplied connection ack count from the unsigned 16-bit send counter snt_unacked without checking that it does not exceed the number of messages actually outstanding:
tsk->snt_unacked -= msg_conn_ack(hdr);
msg_conn_ack() is read straight from a received CONN_MANAGER/CONN_ACK message. If the ack count is larger than snt_unacked, the subtraction wraps to a near-maximum value, leaving tsk_conn_cong() permanently true and starving the connection of further transmits.
Validate the ACK count at the start of the CONN_ACK block and drop the message if it acknowledges more messages than are outstanding. A peer (or, for a local connection, the connected peer socket) can otherwise wedge a TIPC connection's send side by sending an oversized connection ack.
--- net/tipc/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/tipc/socket.c +3 -0
@@ -1362,6 +1362,9 @@ static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,__skb_queue_tail (xmitq, skb);return ; }else if (mtyp ==CONN_ACK ) { +if (tsk->snt_unacked <msg_conn_ack (hdr)) + goto exit; + was_cong =tsk_conn_cong (tsk);tipc_sk_push_backlog (tsk,msg_nagle_ack (hdr)); tsk->snt_unacked -=msg_conn_ack (hdr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 719/2077 tipc: reject inverted service ranges from peer bindings
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 2afb648f7b99216c687db1f89739c995e1144153 ]
tipc_update_nametbl() inserts a binding advertised by a peer node using the lower and upper service-range bounds taken directly from the wire, without checking that lower <= upper. The local bind path validates the ordering (tipc_uaddr_valid()), but the name-distribution path does not.
A binding with lower > upper is inserted at the far end of the service-range rbtree (keyed on lower) where no lookup or withdrawal can ever match it (service_range_foreach_match() requires sr->lower <= end). The publication, its service_range node and the augmented rbtree entry are then leaked for the lifetime of the namespace, and there is no per-peer cap equivalent to TIPC_MAX_PUBL on locally created bindings.
Reject inverted ranges in the network path as well. A peer node can otherwise leak unbounded binding-table memory by sending PUBLICATION items with lower > upper.
--- net/tipc/name_distr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/tipc/name_distr.c +11 -2
@@ -280,12 +280,21 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i, u32 node, u32 dtype) {struct publication *p =NULL ; +u32 lower =ntohl (i->lower); +u32 upper =ntohl (i->upper);struct tipc_socket_addr sk; -struct tipc_uaddr ua;u32 key =ntohl (i->key); +struct tipc_uaddr ua; + +/* A peer-advertised binding with lower > upper can never be matched +* or withdrawn and would leak the publication; the local bind path +* rejects such ranges, so reject ranges learned from the network too. +*/ +if (lower > upper) +return false;tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_CLUSTER_SCOPE , -ntohl (i->type),ntohl (i->lower),ntohl (i->upper)); +ntohl (i->type), lower, upper); sk.ref =ntohl (i->port); sk.node = node;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 720/2077 cxl/test: Unregister cxl_acpi in cxl_test_init() error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 50cc34be04a0ea7522b739c9c7a71367cfbc489c ]
In cxl_test_init(), Once cxl_mock_platform_device_add() succeeds, all error paths after needs to call platform_device_unregister() instead of platform_device_put() to clean up.
--- tools/testing/cxl/test/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/cxl/test/cxl.c +1 -1
@@ -1951,7 +1951,7 @@ static __init int cxl_test_init(void) err_mem:cxl_mem_exit (); err_root: -platform_device_put (cxl_acpi); +platform_device_unregister (cxl_acpi); err_rch:cxl_rch_topo_exit (); err_single:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 721/2077 cxl/test: Add check after kzalloc() memory in alloc_mock_res()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit dfe28c8592538152e9611341dae6f7be1735b3f1 ]
alloc_mock_res() calls kzalloc() without checking the return value. Add scope based resource management to deal with the allocated memory cleanly.
--- tools/testing/cxl/test/cxl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/cxl/test/cxl.c +6 -2
@@ -433,12 +433,16 @@ static void depopulate_all_mock_resources(void)static struct cxl_mock_res *alloc_mock_res (resource_size_t size,int align) { -struct cxl_mock_res *res =kzalloc (sizeof (*res),GFP_KERNEL );struct genpool_data_align data = { .align = align, };unsigned long phys; + struct cxl_mock_res *res __free(kfree) = kzalloc(sizeof(*res), +GFP_KERNEL ); +if (!res) +return NULL ; +INIT_LIST_HEAD (&res->list); phys =gen_pool_alloc_algo (cxl_mock_pool, size, gen_pool_first_fit_align, &data);
@@ -453,7 +457,7 @@ static struct cxl_mock_res *alloc_mock_res(resource_size_t size, int align)list_add (&res->list, &mock_res);mutex_unlock (&mock_res_lock); -return res; +return no_free_ptr (res); }/* Only update CFMWS0 as this is used by the auto region. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 722/2077 crypto: marvell/octeontx - fix DMA cleanup using wrong loop index
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 7891c64c0520519782470ba29bac8a5761e295d8 ]
The sg_cleanup path used list[i] instead of list[j] when unmapping DMA buffers, leaking successfully mapped entries and repeatedly unmapping the failed one.
--- drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c +2 -2
@@ -157,8 +157,8 @@ static inline int setup_sgio_components(struct pci_dev *pdev, sg_cleanup:for (j =0 ; j < i; j++) {if (list[j].dma_addr) { -dma_unmap_single (&pdev->dev, list[i].dma_addr, - list[i].size,DMA_BIDIRECTIONAL ); +dma_unmap_single (&pdev->dev, list[j].dma_addr, + list[j].size,DMA_BIDIRECTIONAL ); } list[j].dma_addr =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 723/2077 crypto: cavium/cpt - fix DMA cleanup using wrong loop index
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 9dbf173bd32d5f81b005008b682bfb50aa093455 ]
The sg_cleanup error path used list[i] instead of list[j] when unmapping DMA buffers, leaking successfully mapped entries and repeatedly unmapping the failed one.
--- drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/cavium/cpt/cptvf_reqmanager.c +2 -2
@@ -108,8 +108,8 @@ static int setup_sgio_components(struct cpt_vf *cptvf, struct buf_ptr *list, sg_cleanup:for (j =0 ; j < i; j++) {if (list[j].dma_addr) { -dma_unmap_single (&pdev->dev, list[i].dma_addr, - list[i].size,DMA_BIDIRECTIONAL ); +dma_unmap_single (&pdev->dev, list[j].dma_addr, + list[j].size,DMA_BIDIRECTIONAL ); } list[j].dma_addr =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 724/2077 crypto: rng - Free default RNG on module exit
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 606ba888b98e0d26a2c4e5c8dc0542e3ad8f0f3a ]
When the rng module is removed the default RNG will be leaked. Call crypto_del_default_rng to free it if possible.
--- crypto/rng.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
crypto/rng.c +11 -0
@@ -232,5 +232,16 @@ void crypto_unregister_rngs(struct rng_alg *algs, int count) }EXPORT_SYMBOL_GPL (crypto_unregister_rngs); +static void __exit rng_exit(void) +{ +int err; + + err =crypto_del_default_rng (); +if (err) +pr_err ("Failed delete default RNG: %d\n" , err); +} + +module_exit (rng_exit); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Random Number Generator" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 725/2077 ALSA: usb-audio: qcom: Guard sideband endpoint removal
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit 2773023abb381e36ce02d364022d901f6f7a416d ]
qmi_stop_session() conditionally looks up the cached data and sync endpoints, but removes each endpoint unconditionally.
The data endpoint is always present for an active offload stream, while the sync endpoint is optional. When no sync endpoint exists, ep still refers to the data endpoint and the code attempts to remove that endpoint a second time. The current sideband implementation rejects the duplicate removal, but the teardown path should not pass an unrelated endpoint for an absent sync endpoint.
Only look up and remove an endpoint when its cached pipe exists, check the lookup result, and clear the cached pipe after handling it. This matches the normal stream-disable path.
--- sound/usb/qcom/qc_audio_offload.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
sound/usb/qcom/qc_audio_offload.c +12 -4
@@ -794,15 +794,23 @@ static void qmi_stop_session(void)continue ; }/* Release XHCI endpoints */ -if (info->data_ep_pipe) +if (info->data_ep_pipe) { ep =usb_pipe_endpoint (uadev[pcm_card_num].udev, info->data_ep_pipe); -xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, ep); +if (ep) +xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, + ep); + info->data_ep_pipe =0 ; + } -if (info->sync_ep_pipe) +if (info->sync_ep_pipe) { ep =usb_pipe_endpoint (uadev[pcm_card_num].udev, info->sync_ep_pipe); -xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, ep); +if (ep) +xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, + ep); + info->sync_ep_pipe =0 ; + }disable_audio_stream (subs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 726/2077 ALSA: seq: Fix kernel heap address leak in bounce_error_event()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HanQuan <[email protected]>
[ Upstream commit efc86691e4d8083d9e380ea95042c2cf679f65fd ]
The comment above bounce_error_event() documents that user clients should receive SNDRV_SEQ_EVENT_BOUNCE with the original event embedded as variable-length data, while kernel clients should receive SNDRV_SEQ_EVENT_KERNEL_ERROR with a quoted kernel pointer.
However, the implementation unconditionally uses SNDRV_SEQ_EVENT_KERNEL_ERROR with data.quote.event set to the raw struct snd_seq_event pointer for all clients. When a bounce error event is delivered to a USER_CLIENT via snd_seq_read(), the kernel heap address in data.quote.event is exposed to userspace through copy_to_user() in the fixed-length branch.
This is a distinct leak path from the one addressed by commit 705dd6dcbc0e ("ALSA: seq: Clear variable event pointer on read"), which sanitizes data.ext.ptr in the variable-length branch of snd_seq_read(). The bounce_error_event() leak uses fixed-length events that take the else branch where no sanitization occurs.
Differentiate the bounce event by client type. For USER_CLIENT, send SNDRV_SEQ_EVENT_BOUNCE with SNDRV_SEQ_EVENT_LENGTH_VARIABLE and data.ext pointing to the original event. The variable-length path in snd_seq_event_dup() copies the event data into chained cells, and snd_seq_expand_var_event() copies only the content -- never the pointer -- to userspace. For KERNEL_CLIENT, keep the existing SNDRV_SEQ_EVENT_KERNEL_ERROR behavior with the quoted pointer.
--- sound/core/seq/seq_clientmgr.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
sound/core/seq/seq_clientmgr.c +27 -5
@@ -538,16 +538,38 @@ static int bounce_error_event(struct snd_seq_client *client,/* set up quoted error */ memset (&bounce_ev,0 ,sizeof (bounce_ev)); - bounce_ev.type =SNDRV_SEQ_EVENT_KERNEL_ERROR ; - bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_FIXED ; + +if (client->type ==USER_CLIENT ) { +/* +* For user clients, send SNDRV_SEQ_EVENT_BOUNCE with the +* original event embedded as variable-length data. This +* avoids exposing data.quote.event (a kernel pointer) to +* userspace. The variable-length path in snd_seq_event_dup() +* copies the event data from data.ext.ptr into chained cells, +* and snd_seq_expand_var_event() copies only the data content +* -- never the pointer -- to userspace. +*/ + bounce_ev.type =SNDRV_SEQ_EVENT_BOUNCE ; + bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_VARIABLE ; + bounce_ev.data.ext.len =sizeof (struct snd_seq_event ); + bounce_ev.data.ext.ptr = (char *)event; + }else { +/* +* For kernel clients, quote the event pointer directly. +* Kernel consumers can safely dereference the pointer. +*/ + bounce_ev.type =SNDRV_SEQ_EVENT_KERNEL_ERROR ; + bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_FIXED ; + bounce_ev.data.quote.origin = event->dest; + bounce_ev.data.quote.event = event; + bounce_ev.data.quote.value = -err;/* use positive value */ + } + bounce_ev.queue =SNDRV_SEQ_QUEUE_DIRECT ; bounce_ev.source.client =SNDRV_SEQ_CLIENT_SYSTEM ; bounce_ev.source.port =SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE ; bounce_ev.dest.client = client->number; bounce_ev.dest.port = event->source.port; - bounce_ev.data.quote.origin = event->dest; - bounce_ev.data.quote.event = event; - bounce_ev.data.quote.value = -err;/* use positive value */ result =snd_seq_deliver_single_event (NULL , &bounce_ev, atomic, hop +1 );if (result <0 ) { client->event_lost++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 727/2077 iommu/dma-iommu: Fix wrong scatterlist length assignment in P2PDMA path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit db50fb87015b955a5a0c155293b2dd40d63a3b9e ]
In iommu_dma_map_sg(), when handling PCI P2PDMA cases, the DMA length of the current scatterlist segment s is incorrectly assigned from the head entry sg->length instead of the current entry s->length.
This typo causes all P2PDMA segments in the scatterlist to inherit the length of the first segment, leading to corrupted DMA lengths for multi- segment scatterlists.
Fix this by using s->length instead of sg->length.
--- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
@@ -1465,7 +1465,7 @@ int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,*/ s->dma_address =pci_p2pdma_bus_addr_map ( p2pdma_state.mem,sg_phys (s)); -sg_dma_len (s) = sg->length; +sg_dma_len (s) = s->length;sg_dma_mark_bus_address (s);continue ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 728/2077 iommufd: Clarify IOAS_MAP_FILE dma-buf support
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Mastro <[email protected]>
[ Upstream commit 298ab7e6f1637cec44163f52e84e2030ec16ed9d ]
IOMMU_IOAS_MAP_FILE is documented as mapping a memfd, but the implementation first tries to resolve the fd as a dma-buf and has a special path for supported dma-buf exporters. In particular, VFIO PCI dma-bufs exported through VFIO_DEVICE_FEATURE_DMA_BUF can be mapped when they describe a single DMA range.
Update the UAPI comment so userspace understands that certain kinds of dma-buf are supported in addition to memfd.
--- include/uapi/linux/iommufd.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
include/uapi/linux/iommufd.h +8 -4
@@ -224,13 +224,17 @@ struct iommu_ioas_map {* @size: sizeof(struct iommu_ioas_map_file) * @flags: same as for iommu_ioas_map * @ioas_id: same as for iommu_ioas_map -* @fd: the memfd to map -* @start: byte offset from start of file to map from +* @fd: the memfd or supported dma-buf file to map +* @start: byte offset from start of the file to map from * @length: same as for iommu_ioas_map * @iova: same as for iommu_ioas_map * -* Set an IOVA mapping from a memfd file. All other arguments and semantics -* match those of IOMMU_IOAS_MAP. +* Set an IOVA mapping from a memfd file. On kernels with dma-buf support, +* supported dma-buf files may also be accepted. This is not a generic +* dma-buf import path; currently supported dma-bufs include single-range +* VFIO PCI dma-bufs exported through VFIO_DEVICE_FEATURE_DMA_BUF, and +* other dma-bufs may be rejected. All other arguments and semantics match +* those of IOMMU_IOAS_MAP. */ struct iommu_ioas_map_file {__u32 size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 729/2077 spi: xilinx: use FIFO occupancy register to determine buffer size
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars Pöschel <[email protected]>
[ Upstream commit 47f3b5365536e8c38f264824ab15fdb74454e066 ]
The method the driver uses to determine the size of the FIFO has a problem. What it currently does is this:
It stops the SPI hardware and writes to the TX FIFO register until TX FIFO FULL asserts in the status register. But the hardware does not only have the FIFO, it also has a shift register which can hold a byte. This can be seen, when writing a byte to the FIFO (while the SPI hardware is stopped,) the TX FIFO EMPTY is still empty. So, if we have a FIFO size of 16 for example, the current method returns a 17.
This is a problem, at least when using the driver in irq mode. The same size determined for the TX FIFO is also assumed for the RX FIFO. When a SPI transaction wants to write the amount of the FIFO size or more bytes, the following happens, for example with 16 bytes FIFO size:
The driver stops the SPI hardware and writes 17 bytes to the TX FIFO and starts the SPI hardware and goes sleep.
The hardware then shifts out 17 bytes (FIFO + shift register) and simultaneously reads bytes into the RX FIFO, but it only has 16 places, so it looses one byte. Then TX FIFO empty asserts, wakes the driver again, which has a fast path and reads 16 bytes from the RX FIFO, but before reading the last 17th byte (which is lost) it does this:
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
if (!(sr & XSPI_SR_RX_EMPTY_MASK)) {
xilinx_spi_rx(xspi);
rx_words--;
}It reads the status register and checks if the RX FIFO is not empty. But it is empty in our case. So this check spins in a while loop forever locking the driver.
This patch fixes the logic to determine the FIFO size.
--- drivers/spi/spi-xilinx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-xilinx.c +9 -2
@@ -371,11 +371,18 @@ static int xilinx_spi_find_buffer_size(struct xilinx_spi *xspi) xspi->regs + XIPIF_V123B_RESETR_OFFSET);/* Fill the Tx FIFO with as many words as possible */ -do { +while (1 ) { xspi->write_fn (0 , xspi->regs +XSPI_TXD_OFFSET ); sr = xspi->read_fn (xspi->regs +XSPI_SR_OFFSET ); +if (sr &XSPI_SR_TX_FULL_MASK ) +break ; + n_words++; - }while (!(sr &XSPI_SR_TX_FULL_MASK )); + } + +/* Handle the NO FIFO case separately */ +if (!n_words) +return 1 ;return n_words; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 730/2077 iommu: Avoid copying the user array twice in the full-array copy helper
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit e28bee5b445178390d63f7a93a5a219063c6434e ]
iommu_copy_struct_from_full_user_array() copies a whole user array into a kernel buffer. In the common case, where user entry_len equals destination entry size, it takes a fast path and copies the whole array with a single copy_from_user().
That fast path does not return, so it falls through into the item-by-item copy_struct_from_user() loop and copies every entry a second time. For an equal entry_len that loop is just a copy_from_user() of the same bytes, so the whole array is copied twice for no benefit.
Return right after the bulk copy. The per-item loop then runs only on the slow path, where entry_len differs and each entry needs size adaption.
--- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+)
include/linux/iommu.h +1 -0
@@ -547,6 +547,7 @@ iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size, user_array->entry_num * user_array->entry_len)) return -EFAULT; +return 0 ; }/* Copy item by item */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 731/2077 ASoC: sdw_utils: fix missing component_name for cs42l43 part_id 0x2A3B
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Lin Kao (AceLan) <[email protected]>
[ Upstream commit c429fbea6174a7dd40c4215288589a50e8a33ff6 ]
commit 87a3f5c8ac20 ("ASoC: sdw_utils: cs42l43: allow spk component names to be combined") moved spk:cs42l43-spk generation from rtd_init() into the asoc_sdw_rtd_init() generic path by adding component_name to codec_info_list entries. However, only the 0x4243 cs42l43 entry was updated; the 0x2A3B entry (vendor_id 0x01fa, Cirrus Logic cs42l43 with sidecar bridge) was missed.
Without component_name on the 0x2A3B dp6 DAI, asoc_sdw_rtd_init() never accumulates spk_components and never appends 'spk:cs42l43-spk' (or its sidecar alias 'spk:cs35l56-bridge') to card->components. The sof-soundwire UCM regex ' spk:([a-z0-9]+...)' then fails to match, causing WirePlumber to mark all HiFi profiles as unavailable=no and fall back to the Off profile — resulting in Dummy Output in GNOME.
The existing sidecar redirect in asoc_sdw_rtd_init() already handles the SOC_SDW_SIDECAR_AMPS case: when component_name is 'cs42l43-spk' and sidecar amps are active, it substitutes 'cs35l56-bridge' into card->components, which matches the existing cs35l56-bridge.conf UCM file.
--- sound/soc/sdw_utils/soc_sdw_utils.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/sdw_utils/soc_sdw_utils.c +1 -0
@@ -818,6 +818,7 @@ struct asoc_sdw_codec_info codec_info_list[] = { { .direction = {true, false}, .codec_name = "cs42l43-codec", + .component_name = "cs42l43-spk", .dai_name = "cs42l43-dp6", .dai_type = SOC_SDW_DAI_TYPE_AMP, .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 732/2077 cxl/region: Fix out-of-bounds access in cxl_cancel_auto_attach()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit cbda6a2c2bec2a5fb30a2ce85baeab15b5fc7db3 ]
In cxl_cancel_auto_attach(), it assumes cxled->pos is a valid index for accessing p->targets[]. However, cxled->pos can be set to negative errno in cxl_region_sort_targets() if cxl_calc_interleave_pos() fails. This causes the driver to use a negative index to access p->targets[], resulting in out-of-bounds access.
Fix it by walking p->targets[] instead of using cxled->pos directly.
--- drivers/cxl/core/region.c | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-)
drivers/cxl/core/region.c +19 -21
@@ -2011,8 +2011,9 @@ static int cxl_region_sort_targets(struct cxl_region *cxlr) cxled->pos =cxl_calc_interleave_pos (cxled, &cxlr->hpa_range);/* * Record that sorting failed, but still continue to calc -* cxled->pos so that follow-on code paths can reliably -* do p->targets[cxled->pos] to self-reference their entry. +* cxled->pos so that cxl_calc_interleave_pos() emits its +* dev_dbg() for every member. which is useful for auto +* discovery debug. */ if (cxled->pos <0 ) rc = -ENXIO ;
@@ -2202,18 +2203,30 @@ static int cxl_region_attach(struct cxl_region *cxlr,return 0 ; } -static int cxl_region_by_target (struct device *dev,const void *data) +static int cxl_region_remove_target (struct device *dev,void *data) { -const struct cxl_endpoint_decoder *cxled = data; +struct cxl_endpoint_decoder *cxled = data;struct cxl_region_params *p;struct cxl_region *cxlr; +int i;if (!is_cxl_region (dev))return 0 ; cxlr =to_cxl_region (dev); p = &cxlr->params; -return p->targets[cxled->pos] == cxled; +for (i =0 ; i < p->interleave_ways; i++) { +if (p->targets[i] == cxled) { + p->nr_targets--; + cxled->state =CXL_DECODER_STATE_AUTO ; + cxled->pos =-1 ; + p->targets[i] =NULL ; + +return 1 ; + } + } + +return 0 ; }/*
@@ -2222,25 +2235,10 @@ static int cxl_region_by_target(struct device *dev, const void *data)*/ static void cxl_cancel_auto_attach (struct cxl_endpoint_decoder *cxled) { -struct cxl_region_params *p; -struct cxl_region *cxlr; -int pos = cxled->pos; -if (cxled->state !=CXL_DECODER_STATE_AUTO_STAGED )return ; - struct device *dev __free(put_device) = -bus_find_device (&cxl_bus_type,NULL , cxled, cxl_region_by_target); -if (!dev) -return ; - - cxlr =to_cxl_region (dev); - p = &cxlr->params; - - p->nr_targets--; - cxled->state =CXL_DECODER_STATE_AUTO ; - cxled->pos =-1 ; - p->targets[pos] =NULL ; +bus_for_each_dev (&cxl_bus_type,NULL , cxled, cxl_region_remove_target); } static struct cxl_region *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 733/2077 cxl/region: Fill first free targets[] slot during auto-discovery
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit aa8a76711c15041ec1e42c3a74c15c2df0bd31f6 ]
Any invalid endpoint decoder pointer in the target array of an active region is not allowed by cxl driver. This means cxl driver always assumes the first p->nr_targets entries of the target array in an auto-assembly region are valid. However, there are scenarios that could leave NULL endpoint decoder pointer holes in the target array.
1. When cxl_cancel_auto_attach() removes an endpoint decoder from a target array, the target slot is set to NULL. If the removed endpoint decoder is not the last element in the target array, the target array will contain a NULL hole.
2. When a auto-assembly region removes an assigned endpoint decoder, if the removed endpoint decoder is not the last element in the target array, always remains a NULL hole in the target array.
When a NULL pointer hole exists in a region's target array, it introduces two potential problems:
1. Access an endpoint decoder via a NULL pointer. it always trigger calltrace like that.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000008: 0000 [#1] SMP KASAN PTI
RIP: 0010:cxl_calc_interleave_pos+0x26/0x810 [cxl_core]
Call Trace:
<TASK>
cxl_region_attach+0xc50/0x2140 [cxl_core]
cxl_add_to_region+0x321/0x2330 [cxl_core]
discover_region+0x92/0x150 [cxl_port]
device_for_each_child+0xf3/0x170
cxl_port_probe+0x150/0x200 [cxl_port]
cxl_bus_probe+0x4f/0xa0 [cxl_core]
really_probe+0x1c8/0x960
__driver_probe_device+0x323/0x450
driver_probe_device+0x45/0x120
__device_attach_driver+0x15d/0x280
bus_for_each_drv+0x10f/0x1902. Not having enough valid endpoint decoders attached to an auto-assembly region. if an auto-assembly region is created with lock flag or assigned endpoint decoder with lock flag, which means assigned endpoint decoder will not be reset during detaching, they could re-attach to the auto-assembly region again. But cxl region driver relies on p->nr_targets to verify whether the required number of endpoint decoders has been attached, and NULL endpoint decoder pointers are still counted in that case.
To fix above issues, adjust cxl_region_attach_auto() logic to find the first free target slot for endpoint decoder attachment, this ensures NULL holes in the target array are filled, rather than adding new endpoint decoders at the tail of the target array.
--- drivers/cxl/core/region.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/cxl/core/region.c +14 -1
@@ -1848,8 +1848,21 @@ static int cxl_region_attach_auto(struct cxl_region *cxlr,* this means that userspace can view devices in the wrong position * before the region activates, and must be careful to understand when * it might be racing region autodiscovery. +* +* The endpoint decoder will be recorded into the first free slot of +* the target array. */ - pos = p->nr_targets; +for (pos =0 ; pos < p->interleave_ways; pos++) { +if (!p->targets[pos]) +break ; + } + +if (pos == p->interleave_ways) { +dev_err (&cxlr->dev,"%s: unable to find a free target slot\n" , +dev_name (&cxled->cxld.dev)); +return -ENXIO ; + } + p->targets[pos] = cxled; cxled->pos = pos; cxled->state =CXL_DECODER_STATE_AUTO_STAGED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 734/2077 vfio: selftests: Ensure libvfio output dirs are always created
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Matlack <[email protected]>
[ Upstream commit 785562e31dbcd85ca583cf58c446e63aa8a5af08 ]
Add an explicit dependency between the output object files and the output directories that need to be created to hold those files. This ensures that the output directories are always created.
Creating the output directories at parse time (current behavior) doesn't support the scenario where someone does "make clean all". The directories will be created during parsing, deleted during "clean" and then not available for the "all" target.
Use an order-only prerequisite for the output directories, rather than a normal prerequisite, to avoid unnecessary recompilations.
--- tools/testing/selftests/vfio/lib/libvfio.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/vfio/lib/libvfio.mk +4 -2
@@ -19,11 +19,13 @@ LIBVFIO_OUTPUT := $(OUTPUT)/libvfio LIBVFIO_O := $(patsubst %.c, $(LIBVFIO_OUTPUT)/%.o, $(LIBVFIO_C)) LIBVFIO_O_DIRS := $(shell dirname $(LIBVFIO_O) | uniq) -$(shell mkdir -p $(LIBVFIO_O_DIRS)) + +$(LIBVFIO_O_DIRS): + mkdir -p $@ CFLAGS += -I$(LIBVFIO_SRCDIR)/include -$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c +$(LIBVFIO_O): $(LIBVFIO_OUTPUT)/%.o : $(LIBVFIO_SRCDIR)/%.c | $(LIBVFIO_O_DIRS) $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ EXTRA_CLEAN += $(LIBVFIO_OUTPUT)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 735/2077 ASoC: adau1372: Clear PLL_EN on failed PLL lock without reset GPIO
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 69b4141b428bcf2cf7a863950c0d6e5c5ae89ac1 ]
The PLL lock failure path in adau1372_set_power() unwinds by putting the regmap back in cache-only mode, asserting the optional power-down GPIO and disabling mclk.
adau1372_enable_pll() enables CLK_CTRL.PLL_EN before polling the PLL lock bit. If the lock fails on a board without a power-down GPIO, the error path disables mclk and returns an error, but leaves PLL_EN set in the hardware register. The normal power-off path already handles the no-GPIO case by explicitly clearing PLL_EN.
Mirror that cleanup in the PLL lock failure path and clear PLL_EN while the regmap is still live, before switching it back to cache-only mode.
--- sound/soc/codecs/adau1372.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/codecs/adau1372.c +5 -0
@@ -813,6 +813,11 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)if (adau1372->use_pll) { ret =adau1372_enable_pll (adau1372);if (ret) { +if (!adau1372->pd_gpio) +regmap_update_bits (adau1372->regmap, +ADAU1372_REG_CLK_CTRL , +ADAU1372_CLK_CTRL_PLL_EN , +0 );regcache_cache_only (adau1372->regmap, true);if (adau1372->pd_gpio)gpiod_set_value (adau1372->pd_gpio,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 736/2077 cxl/region: Block region delete during region creation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit d91feb88692e81b00cd22f0125cfcd04970b4a0b ]
Expand the range lock, rename it "regions_lock", to disable region deletion in the critical period between construct_region() and attach_target(), as well as the period between device_add() and registering the remove actions.
Otherwise, userspace can confuse the kernel. It can violate the assumption the region stays registered through the completion of cxl_add_to_region(). It can violate the assumption that devm_add_action_or_reset() is working with a live 'struct cxl_region'.
It is ok for the region to disappear outside of those windows as that mirrors device hotplug flows where the proper locks are held.
--- drivers/cxl/core/port.c | 2 +- drivers/cxl/core/region.c | 12 ++++++++++-- drivers/cxl/cxl.h | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-)
drivers/cxl/core/port.c +1 -1
@@ -2016,7 +2016,7 @@ struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port,return ERR_PTR (rc); } -mutex_init (&cxlrd->range_lock); +mutex_init (&cxlrd->regions_lock); cxld = &cxlsd->cxld; cxld->dev.type = &cxl_decoder_root_type;
drivers/cxl/core/region.c +10 -2
@@ -2790,6 +2790,10 @@ static ssize_t create_region_store(struct device *dev, const char *buf,if (rc !=1 )return -EINVAL ; +ACQUIRE (mutex_intr, regions_lock)(&cxlrd->regions_lock); +if ((rc =ACQUIRE_ERR (mutex_intr, ®ions_lock))) +return rc; + cxlr =__create_region (cxlrd, mode, id,CXL_DECODER_HOSTONLYMEM );if (IS_ERR (cxlr))return PTR_ERR (cxlr);
@@ -2849,6 +2853,11 @@ static ssize_t delete_region_store(struct device *dev,struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (dev);struct cxl_port *port =to_cxl_port (dev->parent);struct cxl_region *cxlr; +int rc; + +ACQUIRE (mutex_intr, regions_lock)(&cxlrd->regions_lock); +if ((rc =ACQUIRE_ERR (mutex_intr, ®ions_lock))) +return rc; cxlr =cxl_find_region_by_name (cxlrd, buf);if (IS_ERR (cxlr))
@@ -3787,12 +3796,11 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)* for the HPA range, one does the construction and the others * add to that. */ -mutex_lock (&cxlrd->range_lock); +guard (mutex)(&cxlrd->regions_lock); struct cxl_region *cxlr __free(put_cxl_region) =cxl_find_region_by_range (cxlrd, &ctx.hpa_range);if (!cxlr) cxlr =construct_region (cxlrd, &ctx); -mutex_unlock (&cxlrd->range_lock); rc =PTR_ERR_OR_ZERO (cxlr);if (rc)
drivers/cxl/cxl.h +2 -2
@@ -359,7 +359,7 @@ struct cxl_rd_ops {* @cache_size: extended linear cache size if exists, otherwise zero. * @region_id: region id for next region provisioning event * @platform_data: platform specific configuration data -* @range_lock: sync region autodiscovery by address range +* @regions_lock: sync region discovery, construction, and deletion * @qos_class: QoS performance class cookie * @ops: CXL root decoder operations * @cxlsd: base cxl switch decoder
@@ -369,7 +369,7 @@ struct cxl_root_decoder {resource_size_t cache_size;atomic_t region_id;void *platform_data; -struct mutex range_lock; +struct mutex regions_lock;int qos_class;struct cxl_rd_ops ops;struct cxl_switch_decoder cxlsd;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 737/2077 cxl/region: Resolve region deletion races
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit 4dd86ca99ffcc413cbf79063fd9956ef54e0ca91 ]
Sungwoo noticed that the sysfs trigger to delete a region may try to delete a region multiple times. It also has no exclusion relative to the kernel releasing the region via CXL root device teardown.
Instead of installing new cxl root devres actions per region, use the existing root decoder unregistration event to remove all remaining regions. An xarray of regions replaces a devres list of regions.
This handles 3 separate issues with the old approach:
1/ sysfs users racing to delete the same region: no longer possible now
that the regions_lock is held over the lookup and deletion.
2/ multiple actions triggering deletion of the same region: solved by
erasing regions while holding @regions_lock, and only proceeding on successful erasure.
3/ userspace racing devres_release_all() to trigger the devres not found
warning: solved by sysfs unregistration not requiring a release action
--- drivers/cxl/core/core.h | 2 ++ drivers/cxl/core/port.c | 5 ++++ drivers/cxl/core/region.c | 60 +++++++++++++++++++++------------------ drivers/cxl/cxl.h | 4 +++ 4 files changed, 44 insertions(+), 27 deletions(-)
drivers/cxl/core/core.h +2 -0
@@ -52,6 +52,7 @@ u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa);int devm_cxl_add_dax_region (struct cxl_region *cxlr);int devm_cxl_add_pmem_region (struct cxl_region *cxlr); +void kill_regions (struct cxl_root_decoder *cxlrd);#else static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
@@ -81,6 +82,7 @@ static inline int cxl_region_init(void)static inline void cxl_region_exit (void ) { } +static inline void kill_regions (struct cxl_root_decoder *cxlrd) { };#define CXL_REGION_ATTR (x) NULL#define CXL_REGION_TYPE (x) NULL#define SET_CXL_REGION_ATTR (x)
drivers/cxl/core/port.c +5 -0
@@ -458,6 +458,8 @@ static void cxl_root_decoder_release(struct device *dev)if (atomic_read (&cxlrd->region_id) >=0 )memregion_free (atomic_read (&cxlrd->region_id)); +mutex_destroy (&cxlrd->regions_lock); +xa_destroy (&cxlrd->regions);__cxl_decoder_release (&cxlrd->cxlsd.cxld);kfree (cxlrd); }
@@ -2017,6 +2019,7 @@ struct cxl_root_decoder *cxl_root_decoder_alloc(struct cxl_port *port, }mutex_init (&cxlrd->regions_lock); +xa_init (&cxlrd->regions); cxld = &cxlsd->cxld; cxld->dev.type = &cxl_decoder_root_type;
@@ -2192,6 +2195,8 @@ static void cxld_unregister(void *dev)if (is_endpoint_decoder (dev))cxl_decoder_detach (NULL ,to_cxl_endpoint_decoder (dev),-1 ,DETACH_INVALIDATE ); +if (is_root_decoder (dev)) +kill_regions (to_cxl_root_decoder (dev));device_unregister (dev); }
drivers/cxl/core/region.c +33 -27
123 lines not on this page · raw message
drivers/cxl/cxl.h +4 -0
@@ -360,6 +360,8 @@ struct cxl_rd_ops {* @region_id: region id for next region provisioning event * @platform_data: platform specific configuration data * @regions_lock: sync region discovery, construction, and deletion +* @regions: regions to remove at root decoder destruct time +* @dead: root decoder dead to region creation * @qos_class: QoS performance class cookie * @ops: CXL root decoder operations * @cxlsd: base cxl switch decoder
@@ -370,6 +372,8 @@ struct cxl_root_decoder {atomic_t region_id;void *platform_data;struct mutex regions_lock; +struct xarray regions; +bool dead;int qos_class;struct cxl_rd_ops ops;struct cxl_switch_decoder cxlsd;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 738/2077 cxl/memdev: Pin parents for entire memdev lifetime
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
[ Upstream commit bd3a6ff4b84e0fc3fca8556d338270603df13f2e ]
In order to be able to manage the driver that uses a memdev attach mechanism the parent needs to stick around for the device_release_driver(cxlmd->dev.parent) event.
--- drivers/cxl/core/memdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cxl/core/memdev.c +3 -1
@@ -25,9 +25,11 @@ static DEFINE_IDA(cxl_memdev_ida);static void cxl_memdev_release (struct device *dev) {struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct device *parent = dev->parent;ida_free (&cxl_memdev_ida, cxlmd->id);kfree (cxlmd); +put_device (parent); } static char *cxl_memdev_devnode(const struct device *dev, umode_t *mode, kuid_t *uid,
@@ -707,7 +709,7 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, dev = &cxlmd->dev;device_initialize (dev);lockdep_set_class (&dev->mutex, &cxl_memdev_key); - dev->parent = cxlds->dev; + dev->parent =get_device (cxlds->dev); dev->bus = &cxl_bus_type; dev->devt =MKDEV (cxl_mem_major, cxlmd->id); dev->type = &cxl_memdev_type;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 739/2077 power: supply: core: fix supplied_from allocations
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Tsai <[email protected]>
[ Upstream commit ba61aed9a34671222d1149acfc2f0179a9ce7e80 ]
If dts property power-supplies has multiple values, then accessing to psy->supplied_from[i-1] in __power_supply_populate_supplied_from will overrun supplied_from array.
--- drivers/power/supply/power_supply_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/power/supply/power_supply_core.c +3 -8
@@ -292,18 +292,13 @@ static int power_supply_check_supplies(struct power_supply *psy)if (cnt ==1 )return 0 ; -/* All supplies found, allocate char ** array for filling */ - psy->supplied_from =devm_kzalloc (&psy->dev,sizeof (*psy->supplied_from), +/* All supplies found, allocate char * array for filling */ + psy->supplied_from =devm_kcalloc (&psy->dev, + cnt -1 ,sizeof (*psy->supplied_from),GFP_KERNEL );if (!psy->supplied_from)return -ENOMEM ; - *psy->supplied_from =devm_kcalloc (&psy->dev, - cnt -1 ,sizeof (**psy->supplied_from), -GFP_KERNEL ); -if (!*psy->supplied_from) -return -ENOMEM ; - return power_supply_populate_supplied_from(psy); }#else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 740/2077 handshake: Require admin permission for DONE command
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 81246a65303d9635266b1334490142caaf86a11f ]
ACCEPT and DONE are the two downcalls of the handshake genl family, both intended for use by the trusted handshake agent (tlshd). ACCEPT already requires GENL_ADMIN_PERM; DONE has no privilege check at all.
The fd-lookup in handshake_nl_done_doit() only confirms that some pending handshake request exists for the supplied sockfd; it does not authenticate the sender. An unprivileged process that guesses or observes a valid sockfd can therefore submit a DONE with HANDSHAKE_A_DONE_STATUS == 0, leaving the kernel consumer to proceed as if the handshake succeeded. A non-zero status on a forged DONE tears down a legitimate in-flight handshake before tlshd can report its real result.
--- Documentation/netlink/specs/handshake.yaml | 1 + net/handshake/genl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Documentation/netlink/specs/handshake.yaml +1 -0
@@ -125,6 +125,7 @@ operations: name: done doc: Handler reports handshake completion attribute-set: done + flags: [admin-perm] do: request: attributes:
net/handshake/genl.c +1 -1
@@ -38,7 +38,7 @@ static const struct genl_split_ops handshake_nl_ops[] = { .doit = handshake_nl_done_doit, .policy = handshake_done_nl_policy, .maxattr = HANDSHAKE_A_DONE_REMOTE_AUTH, - .flags = GENL_CMD_CAP_DO, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 741/2077 bnxt: fix head underflow on XDP head-grow
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
[ Upstream commit e26657fe3b85c068b01f42bb0c602f242d643ba9 ]
The xdp.py test test_xdp_native_adjst_head_grow_data crashes when run on a bnxt machine (and also crashes in NIPA).
It seems that the bug is an underflow in bnxt_rx_multi_page_skb, which builds the skb head:
napi_build_skb(data_ptr - bp->rx_offset, rxr->rx_page_size);
The problem with this expression is that in page mode, rx_offset is:
bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM;
Which evaluates (at least on x86_64) to 258.
The test test_xdp_native_adjst_head_grow_data tests a case where the head is adjusted by -256.
When this test runs, data_ptr is shifted to frag_start + 2 (where frag_start = page_address(page) + offset).
Then, bnxt_rx_multi_page_skb is invoked and the napi_build_skb expression subtracts 258, landing at an address before frag_start. This could be either the previous fragment or the previous physical page when the offset is < 256 (e.g. if the fragment started at offset 0).
When the skb is freed, the page pool fragment reference is dropped on either the wrong page or the wrong frag of the right page. In either case, the corrupted reference count can lead to the page being prematurely recycled while still in use. Once (incorrectly) recycled, it can be handed out again and on driver teardown this would result in a double free.
The commit under fixes updated this code to handle the case where the native page size is >= 64k, but it unintentionally broke the head grow case.
To fix this, add an offset field to struct bnxt_sw_rx_bd, mirroring the existing offset field in struct bnxt_sw_rx_agg_bd. Populate it on allocation and preserve it on reuse.
In bnxt_rx_multi_page_skb, use the newly added offset field to compute the fragment start and pass that to napi_build_skb. Adjust the layout with skb_reserve.
There are two cases, the non-adjustment case and the adjustment case.
In both cases, the skb is built at page_address(page) + offset to account for the case where the native page size >= 64K and skb_reserve is called with data_ptr - (page_address(page) + offset). That difference equals bp->rx_offset when data_ptr was not moved, or bp->rx_offset + xdp_adjust when XDP adjusted the head.
Re-running the failing test with this commit applied causes the test to run successfully to completion.
The other rx_skb_func implementations don't have this issue.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -2
@@ -1011,6 +1011,7 @@ int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, mapping += bp->rx_dma_offset; rx_buf->data = page; rx_buf->data_ptr =page_address (page) + offset + bp->rx_offset; + rx_buf->offset = offset; }else {u8 *data =__bnxt_alloc_rx_frag (bp, &mapping, rxr, gfp);
@@ -1019,6 +1020,7 @@ int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, rx_buf->data = data; rx_buf->data_ptr = data + bp->rx_offset; + rx_buf->offset =0 ; } rx_buf->mapping = mapping;
@@ -1040,6 +1042,7 @@ void bnxt_reuse_rx_data(struct bnxt_rx_ring_info *rxr, u16 cons, void *data) prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; prod_rx_buf->mapping = cons_rx_buf->mapping; + prod_rx_buf->offset = cons_rx_buf->offset; prod_bd = &rxr->rx_desc_ring[RX_RING (bp, prod)][RX_IDX (prod)]; cons_bd = &rxr->rx_desc_ring[RX_RING (bp, cons)][RX_IDX (cons)];
@@ -1175,8 +1178,11 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct bnxt *bp,struct page *page = data;u16 prod = rxr->rx_prod;struct sk_buff *skb; +void *frag_start;int err; + frag_start =page_address (page) + rxr->rx_buf_ring[cons].offset; + err =bnxt_alloc_rx_data (bp, rxr, prod,GFP_ATOMIC );if (unlikely (err)) {bnxt_reuse_rx_data (rxr, cons, data);
@@ -1185,13 +1191,13 @@ static struct sk_buff *bnxt_rx_multi_page_skb(struct bnxt *bp, dma_addr -= bp->rx_dma_offset;dma_sync_single_for_cpu (&bp->pdev->dev, dma_addr, rxr->rx_page_size, bp->rx_dir); - skb =napi_build_skb (data_ptr - bp->rx_offset, rxr->rx_page_size); + skb =napi_build_skb (frag_start, rxr->rx_page_size);if (!skb) {page_pool_recycle_direct (rxr->page_pool, page);return NULL ; }skb_mark_for_recycle (skb); -skb_reserve (skb, bp->rx_offset); +skb_reserve (skb, data_ptr - (u8 *)frag_start);__skb_put (skb, len);return skb;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -911,6 +911,7 @@ struct bnxt_sw_rx_bd {void *data;u8 *data_ptr;dma_addr_t mapping; +unsigned int offset; };struct bnxt_sw_rx_agg_bd {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 742/2077 tcp: clear sock_ops cb flags before force-closing a child socket
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit 990348e5bb457697c2f1f7f7b65154a3334d9d2b ]
A child socket inherits the listener's bpf_sock_ops_cb_flags via sk_clone_lock(). If its setup fails in tcp_v4_syn_recv_sock() / tcp_v6_syn_recv_sock(), the child is freed through put_and_exit, where inet_csk_prepare_forced_close() drops the socket lock and tcp_done() runs without it.
If BPF_SOCK_OPS_STATE_CB_FLAG was inherited, tcp_done() -> tcp_set_state() calls tcp_call_bpf(), which expects the lock and trips sock_owned_by_me():
WARNING: include/net/sock.h:1799 at tcp_set_state+0x433/0x550 RIP: 0010:tcp_set_state+0x433/0x550 include/net/sock.h:1799 Call Trace: <IRQ> tcp_done+0xba/0x250 net/ipv4/tcp.c:5095 tcp_v4_syn_recv_sock+0x850/0xa50 net/ipv4/tcp_ipv4.c:1787 tcp_check_req+0xf30/0x1360 net/ipv4/tcp_minisocks.c:926 tcp_v4_rcv+0x1047/0x1b50 net/ipv4/tcp_ipv4.c:2164 </IRQ>
The child is freed before it is ever established, so it should run no sock_ops callback. Clear its cb flags in inet_csk_prepare_for_destroy_sock(), the common point for the IPv4, IPv6 and chtls forced-close paths and for the MPTCP ->syn_recv_sock() failure path (dispose_child), which reaches tcp_done() on a child that was never established too.
--- include/net/tcp.h | 9 +++++++++ net/ipv4/inet_connection_sock.c | 1 + 2 files changed, 10 insertions(+)
include/net/tcp.h +9 -0
@@ -2942,6 +2942,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return tcp_call_bpf(sk, op, 3, args); } +static inline void tcp_clear_sock_ops_cb_flags (struct sock *sk) +{ +tcp_sk (sk)->bpf_sock_ops_cb_flags =0 ; +} +#else static inline int tcp_call_bpf (struct sock *sk,int op,u32 nargs,u32 *args) {
@@ -2959,6 +2964,10 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return -EPERM; } +static inline void tcp_clear_sock_ops_cb_flags (struct sock *sk) +{ +} +#endif static inline u32 tcp_timeout_init (struct sock *sk)
net/ipv4/inet_connection_sock.c +1 -0
@@ -1285,6 +1285,7 @@ EXPORT_SYMBOL(inet_csk_destroy_sock);void inet_csk_prepare_for_destroy_sock (struct sock *sk) {/* The below has to be done to allow calling inet_csk_destroy_sock */ +tcp_clear_sock_ops_cb_flags (sk);sock_set_flag (sk,SOCK_DEAD );tcp_orphan_count_inc (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 743/2077 virtio_net: do not allow tunnel csum offload for non GSO packets
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 86c51f0f23136ea5ef5541f607287e07150cd23f ]
Fiona reports broken connectivity for virtio net setup using UDP tunnel inside the guest and NIC with not UDP tunnel TSO support in the host.
Currently the virtio_net driver exposes csum offload for UDP-tunneled, TCP non GSO packets. Such packet reach the host as CSUM_PARTIAL ones with the 'encapsulation' flag cleared, as the virtio specification do not support this specific kind of offload.
HW NICs with UDP tunnel TSO support - and those drivers directly accessing skb->csum_start/csum_offset - are still capable of computing the needed csum correctly, but otherwise the packets reach the wire with bad csum on both the inner and outer transport header.
Address the issue explicitly disabling csum offload for UDP tunneled, non GSO packets via the ndo_features_check op.
--- drivers/net/virtio_net.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/virtio_net.c +14 -1
@@ -6222,6 +6222,19 @@ static void virtnet_free_irq_moder(struct virtnet_info *vi)rtnl_unlock (); } +static netdev_features_t virtnet_features_check (struct sk_buff *skb, +struct net_device *dev, +netdev_features_t features) +{ +/* Inner csum offload is only available for GSO packets. */ +if (skb->encapsulation && + (!skb_is_gso (skb) ||netif_needs_gso (skb, features))) +return features & ~NETIF_F_CSUM_MASK ; + +/* Passthru. */ +return features; +} +static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -6235,7 +6248,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_bpf = virtnet_xdp, .ndo_xdp_xmit = virtnet_xdp_xmit, .ndo_xsk_wakeup = virtnet_xsk_wakeup, - .ndo_features_check = passthru_features_check, + .ndo_features_check = virtnet_features_check, .ndo_get_phys_port_name = virtnet_get_phys_port_name, .ndo_set_features = virtnet_set_features, .ndo_tx_timeout = virtnet_tx_timeout,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 744/2077 net/sched: sch_fq_codel: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 097f6fc7b1ae362dd7a9444b2572162fda73b284 ]
Whenever fq_codel drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though fq_codel still has 1 packet on the queue and, thus, will mistakenly deactivate the parent's class causing issues like a recent report [1] and a wild memory access in qfq:
[ 29.371146][ T360] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000024: 0000 [#1] SMP KASAN NOPTI [ 29.371666][ T360] KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127] [ 29.371987][ T360] CPU: 6 UID: 0 PID: 360 Comm: tc Not tainted 7.1.0-rc5-00285-gc530e5b2dbc6-dirty #82 PREEMPT(full) [ 29.372384][ T360] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 29.372620][ T360] RIP: 0010:qfq_deactivate_agg (include/linux/list.h:1029 (discriminator 2) include/linux/list.h:1043 (discriminator 2) net/sched/sch_qfq.c:1369 (discriminator 2) net/sched/sch_qfq.c:1395 (discriminator 2)) sch_qfq [ 29.373544][ T360] RSP: 0018:ffff888102417370 EFLAGS: 00010216 [ 29.373800][ T360] RAX: 0000000000000000 RBX: ffff88811224d568 RCX: dffffc0000000000 [ 29.374079][ T360] RDX: 1ffff11021fe1543 RSI: ffff88810ff0aa00 RDI: dffffc0000000000 [ 29.374368][ T360] RBP: ffff88811224c280 R08: dead000000000122 R09: 1bd5a00000000024 [ 29.374649][ T360] R10: fffffbfff7940329 R11: fffffbfff7940329 R12: 0000000000000000 [ 29.374926][ T360] R13: dead000000000100 R14: ffff88811224d580 R15: ffff88811224d578 [ 29.375207][ T360] FS: 00007f5b794e5780(0000) GS:ffff88815d1e9000(0000) knlGS:0000000000000000 [ 29.375545][ T360] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.375823][ T360] CR2: 000055ffb091f000 CR3: 000000010a305000 CR4: 0000000000750ef0 [ 29.376103][ T360] PKRU: 55555554 [ 29.376258][ T360] Call Trace: [ 29.376401][ T360] <TASK> ... [ 29.376885][ T360] qfq_reset_qdisc (net/sched/sch_qfq.c:357 net/sched/sch_qfq.c:1487) sch_qfq [ 29.377074][ T360] qdisc_reset (net/sched/sch_generic.c:1057) [ 29.377414][ T360] __qdisc_destroy (net/sched/sch_generic.c:1096) [ 29.377600][ T360] qdisc_graft (net/sched/sch_api.c:1062 net/sched/sch_api.c:1053 net/sched/sch_api.c:1159) [ 29.378593][ T360] tc_get_qdisc (net/sched/sch_api.c:1528 net/sched/sch_api.c:1556)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
[1] http://lore.kernel.org/netdev/CAN2cbVe79oj0O9==m4+4x3v+O+qzRagA=2=wkrp9i9=CqYvyZA@mail.gmail.com/
--- net/sched/sch_fq_codel.c | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +39 -2
@@ -281,7 +281,7 @@ static void drop_func(struct sk_buff *skb, void *ctx)qdisc_qstats_drop (sch); } -static struct sk_buff *fq_codel_dequeue (struct Qdisc *sch) +static struct sk_buff *__fq_codel_dequeue (struct Qdisc *sch) {struct fq_codel_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -318,12 +318,49 @@ static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch)qdisc_bstats_update (sch, skb);WRITE_ONCE (flow->deficit, flow->deficit -qdisc_pkt_len (skb)); +return skb; +} + +static void fq_codel_dequeue_drop (struct Qdisc *sch) +{ +struct fq_codel_sched_data *q =qdisc_priv (sch); +if (q->cstats.drop_count) {qdisc_tree_reduce_backlog (sch, q->cstats.drop_count, q->cstats.drop_len); q->cstats.drop_count =0 ; q->cstats.drop_len =0 ; } +} + +static struct sk_buff *fq_codel_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__fq_codel_dequeue (sch); + +fq_codel_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *fq_codel_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__fq_codel_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +fq_codel_dequeue_drop (sch); + } +return skb; }
@@ -726,7 +763,7 @@ static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fq_codel_sched_data), .enqueue = fq_codel_enqueue, .dequeue = fq_codel_dequeue, - .peek = qdisc_peek_dequeued, + .peek = fq_codel_peek, .init = fq_codel_init, .reset = fq_codel_reset, .destroy = fq_codel_destroy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 745/2077 net/sched: sch_codel: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 52f1da34c9f4d5bdc1e8b44242da5c7ba8db85f3 ]
Whenever codel drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though codel still has 1 packet on the queue and, thus, will mistakenly deactivate the parent's class causing issues like a wild memory access when qfq has codel as a child:
[ 36.339843][ T370] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000024: 0000 [#1] SMP KASAN NOPTI [ 36.340408][ T370] KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127] [ 36.340737][ T370] CPU: 2 UID: 0 PID: 370 Comm: tc Not tainted 7.1.0-rc5-00287-g66e13b626592 #87 PREEMPT(full) [ 36.341113][ T370] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 36.341357][ T370] RIP: 0010:qfq_deactivate_agg (include/linux/list.h:1029 (discriminator 2) include/linux/list.h:1043 (discriminator 2) net/sched/sch_qfq.c:1369 (discriminator 2) net/sched/sch_qfq.c:1395 (discriminator 2)) sch_qfq [ 36.342221][ T370] RSP: 0018:ffff8881100ef370 EFLAGS: 00010216 [ 36.342422][ T370] RAX: 0000000000000000 RBX: ffff8881058a9568 RCX: dffffc0000000000 [ 36.342664][ T370] RDX: 1ffff11021064dc3 RSI: ffff888108326e00 RDI: dffffc0000000000 [ 36.342905][ T370] RBP: ffff8881058a8280 R08: dead000000000122 R09: 1bd5a00000000024 [ 36.343140][ T370] R10: fffffbfff2940329 R11: fffffbfff2940329 R12: 0000000000000000 [ 36.343383][ T370] R13: dead000000000100 R14: ffff8881058a9580 R15: ffff8881058a9578 [ 36.343631][ T370] FS: 00007fc04b0ca780(0000) GS:ffff888184fef000(0000) knlGS:0000000000000000 [ 36.343911][ T370] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.344116][ T370] CR2: 0000557c02c02000 CR3: 000000010e0ba000 CR4: 0000000000750ef0 [ 36.344359][ T370] PKRU: 55555554 [ 36.344481][ T370] Call Trace: ... [ 36.345054][ T370] qfq_reset_qdisc (net/sched/sch_qfq.c:357 net/sched/sch_qfq.c:1487) sch_qfq [ 36.345222][ T370] qdisc_reset (net/sched/sch_generic.c:1057) [ 36.345503][ T370] __qdisc_destroy (net/sched/sch_generic.c:1096) [ 36.345677][ T370] qdisc_graft (net/sched/sch_api.c:1062 net/sched/sch_api.c:1053 net/sched/sch_api.c:1159) [ 36.346335][ T370] tc_get_qdisc (net/sched/sch_api.c:1528 net/sched/sch_api.c:1556)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
--- net/sched/sch_codel.c | 48 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-)
net/sched/sch_codel.c +43 -5
@@ -56,7 +56,7 @@ static void drop_func(struct sk_buff *skb, void *ctx)qdisc_qstats_drop (sch); } -static struct sk_buff *codel_qdisc_dequeue (struct Qdisc *sch) +static struct sk_buff *__codel_qdisc_dequeue (struct Qdisc *sch) {struct codel_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -65,13 +65,51 @@ static struct sk_buff *codel_qdisc_dequeue(struct Qdisc *sch) &q->stats, qdisc_pkt_len, codel_get_enqueue_time, drop_func, dequeue_func); +if (skb) +qdisc_bstats_update (sch, skb); +return skb; +} + +static void codel_dequeue_drop (struct Qdisc *sch) +{ +struct codel_sched_data *q =qdisc_priv (sch); +if (q->stats.drop_count) { -qdisc_tree_reduce_backlog (sch, q->stats.drop_count, q->stats.drop_len); +qdisc_tree_reduce_backlog (sch, q->stats.drop_count, + q->stats.drop_len); q->stats.drop_count =0 ; q->stats.drop_len =0 ; } -if (skb) -qdisc_bstats_update (sch, skb); +} + +static struct sk_buff *codel_qdisc_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__codel_qdisc_dequeue (sch); + +codel_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *codel_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__codel_qdisc_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +codel_dequeue_drop (sch); + } +return skb; }
@@ -257,7 +295,7 @@ static struct Qdisc_ops codel_qdisc_ops __read_mostly = { .enqueue = codel_qdisc_enqueue, .dequeue = codel_qdisc_dequeue, - .peek = qdisc_peek_dequeued, + .peek = codel_peek, .init = codel_init, .reset = codel_reset, .change = codel_change,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 746/2077 net/sched: sch_dualpi2: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 15cd0c93bf4f892d66bc7a93667e2357b5673365 ]
Whenever dualpi2 drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though dualpi2 still has 1 packet on the queue and, thus, mistakenly deactivates the parent's class which leads to a null-ptr-deref:
[ 101.427314][ T599] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000009: 0000 [#1] SMP KASAN NOPTI [ 101.427755][ T599] KASAN: null-ptr-deref in range [0x0000000000000048-0x000000000000004f] [ 101.428048][ T599] CPU: 2 UID: 0 PID: 599 Comm: ping Not tainted 7.1.0-rc5-00284-gbce53c430ed7 #102 PREEMPT(full) [ 101.428400][ T599] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 101.428608][ T599] RIP: 0010:qfq_dequeue (net/sched/sch_qfq.c:1150) sch_qfq [ 101.428821][ T599] Code: 00 fc ff df 80 3c 02 00 0f 85 46 0c 00 00 4c 8d 73 48 48 89 9d b8 02 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 f2 48 c1 ea 03 <80> 3c 02 00 0f 85 2d 0c 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b All code [ 101.429348][ T599] RSP: 0018:ffff8881110df4f0 EFLAGS: 00010216 [ 101.429541][ T599] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: dffffc0000000000 [ 101.429763][ T599] RDX: 0000000000000009 RSI: 00000024c0000000 RDI: ffff88811436c2b0 [ 101.429985][ T599] RBP: ffff88811436c000 R08: ffff88811436c280 R09: 1ffff11021277523 [ 101.430206][ T599] R10: 1ffff11021277526 R11: 1ffff11021277527 R12: 00000024c0000000 [ 101.430423][ T599] R13: ffff88811436c2b8 R14: 0000000000000048 R15: 0000000020000000 [ 101.430642][ T599] FS: 00007f61813e1c40(0000) GS:ffff8881691ef000(0000) knlGS:0000000000000000 [ 101.430913][ T599] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 101.431100][ T599] CR2: 00005651650850a8 CR3: 000000010ca0b000 CR4: 0000000000750ef0 [ 101.431320][ T599] PKRU: 55555554 [ 101.431433][ T599] Call Trace: [ 101.431544][ T599] <TASK> [ 101.431628][ T599] __qdisc_run (net/sched/sch_generic.c:322 net/sched/sch_generic.c:427 net/sched/sch_generic.c:445) [ 101.431792][ T599] ? dev_qdisc_enqueue (./include/trace/events/qdisc.h:49 (discriminator 22) net/core/dev.c:4176 (discriminator 22)) [ 101.431941][ T599] __dev_queue_xmit (./include/net/pkt_sched.h:120 ./include/net/pkt_sched.h:117 net/core/dev.c:4292 net/core/dev.c:4831)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
--- net/sched/sch_dualpi2.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
net/sched/sch_dualpi2.c +39 -2
@@ -577,7 +577,7 @@ static void drop_and_retry(struct dualpi2_sched_data *q, struct sk_buff *skb,qdisc_qstats_drop (sch); } -static struct sk_buff *dualpi2_qdisc_dequeue (struct Qdisc *sch) +static struct sk_buff *__dualpi2_qdisc_dequeue (struct Qdisc *sch) {struct dualpi2_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -604,12 +604,49 @@ static struct sk_buff *dualpi2_qdisc_dequeue(struct Qdisc *sch)break ; } +return skb; +} + +static void dualpi2_dequeue_drop (struct Qdisc *sch) +{ +struct dualpi2_sched_data *q =qdisc_priv (sch); +if (q->deferred_drops_cnt) {qdisc_tree_reduce_backlog (sch, q->deferred_drops_cnt, q->deferred_drops_len); q->deferred_drops_cnt =0 ; q->deferred_drops_len =0 ; } +} + +static struct sk_buff *dualpi2_qdisc_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__dualpi2_qdisc_dequeue (sch); + +dualpi2_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *dualpi2_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__dualpi2_qdisc_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +dualpi2_dequeue_drop (sch); + } +return skb; }
@@ -1164,7 +1201,7 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .priv_size = sizeof(struct dualpi2_sched_data), .enqueue = dualpi2_qdisc_enqueue, .dequeue = dualpi2_qdisc_dequeue, - .peek = qdisc_peek_dequeued, + .peek = dualpi2_peek, .init = dualpi2_init, .destroy = dualpi2_destroy, .reset = dualpi2_reset,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 747/2077 net: mana: initialize gdma queue id to INVALID_QUEUE_ID
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Garg <[email protected]>
[ Upstream commit 5985474e1cb4034680fac2145497a94b0860be50 ]
mana_gd_create_mana_wq_cq() leaves queue->id as 0 (from kzalloc_obj()) until mana_create_wq_obj() assigns the firmware-returned id. If creation fails before that, cleanup calls mana_gd_destroy_cq() with id 0, NULLing gc->cq_table[0] and silently breaking whichever real CQ owns that slot.
Initialize queue->id to INVALID_QUEUE_ID right after allocation, matching mana_gd_create_eq(). The existing (id >= max_num_cqs) guard then short-circuits cleanly.
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/microsoft/mana/gdma_main.c +2 -0
@@ -1192,6 +1192,8 @@ int mana_gd_create_mana_wq_cq(struct gdma_dev *gd,if (!queue)return -ENOMEM ; + queue->id =INVALID_QUEUE_ID ; + gmi = &queue->mem_info; err =mana_gd_alloc_memory (gc, spec->queue_size, gmi);if (err) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 748/2077 net: mana: guard TX wq object destroy with INVALID_MANA_HANDLE check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Garg <[email protected]>
[ Upstream commit f8fd56977eeea3d6939b1a9cd8bd36f1779b3ad0 ]
mana_create_txq() has several error paths (after mana_alloc_queues() or mana_create_wq_obj() failure) where tx_qp[i].tx_object stays as the INVALID_MANA_HANDLE sentinel set at allocation. mana_destroy_txq() then unconditionally calls mana_destroy_wq_obj() with (u64)-1, which firmware rejects and logs an error.
Mirror the RX-side pattern in mana_destroy_rxq() and skip the destroy when the handle is still INVALID_MANA_HANDLE.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -1
@@ -2334,7 +2334,8 @@ static void mana_destroy_txq(struct mana_port_context *apc)netif_napi_del_locked (napi); apc->tx_qp[i].txq.napi_initialized = false; } -mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object); +if (apc->tx_qp[i].tx_object !=INVALID_MANA_HANDLE ) +mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object);mana_deinit_cq (apc, &apc->tx_qp[i].tx_cq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 749/2077 net: watchdog: fix refcount tracking races
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8eed5519e496b7a07f441a0f579cb228a33189f7 ]
Blamed commit converted the untracked dev_hold()/dev_put() calls in the watchdog code to use the tracked dev_hold_track()/dev_put_track() (which were later renamed/interfaced to netdev_hold() and netdev_put()).
By introducing dev->watchdog_dev_tracker to store the reference tracking information without adding synchronization between netdev_watchdog_up() and dev_watchdog(), it enabled the race condition where this pointer could be overwritten or freed concurrently, leading to the list corruption crash syzbot reported:
list_del corruption, ffff888114a18c00->next is NULL
kernel BUG at lib/list_debug.c:52 !
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 1 UID: 0 PID: 91 Comm: kworker/u8:5 Not tainted syzkaller #0 PREEMPT(lazy) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 Workqueue: events_unbound linkwatch_event RIP: 0010:__list_del_entry_valid_or_report.cold+0x22/0x2a lib/list_debug.c:52 Call Trace: <TASK> __list_del_entry_valid include/linux/list.h:132 [inline] __list_del_entry include/linux/list.h:246 [inline] list_move_tail include/linux/list.h:341 [inline] ref_tracker_free+0x1a7/0x6c0 lib/ref_tracker.c:329 netdev_tracker_free include/linux/netdevice.h:4491 [inline] netdev_put include/linux/netdevice.h:4508 [inline] netdev_put include/linux/netdevice.h:4504 [inline] netdev_watchdog_down net/sched/sch_generic.c:600 [inline] dev_deactivate_many+0x28c/0xfe0 net/sched/sch_generic.c:1363 dev_deactivate+0x109/0x1d0 net/sched/sch_generic.c:1397 linkwatch_do_dev net/core/link_watch.c:184 [inline] linkwatch_do_dev+0xd3/0x120 net/core/link_watch.c:166 __linkwatch_run_queue+0x3a5/0x810 net/core/link_watch.c:240 linkwatch_event+0x8f/0xc0 net/core/link_watch.c:314 process_one_work+0xa0e/0x1980 kernel/workqueue.c:3314 process_scheduled_works kernel/workqueue.c:3397 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3478 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x69a/0xc80 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
This patch has three coordinated parts:
1) Add dev->watchdog_lock and dev->watchdog_ref_held to serialize watchdog operations.
2) Remove netdev_watchdog_up() call from netif_carrier_on():
This ensures netdev_watchdog_up() is only called from process/BH context (via linkwatch workqueue dev_activate()), allowing us to use spin_lock_bh() for synchronization.
3) Synchronize watchdog up and watchdog timer:
Protect netdev_watchdog_up() with tx_global_lock and watchdog_lock. Only allocate a new tracker in netdev_watchdog_up() if one is not already present.
In dev_watchdog(), ensure we don't release the tracker if the timer was rescheduled either by dev_watchdog() itself or concurrently by netdev_watchdog_up().
--- include/linux/netdevice.h | 4 ++++ net/core/dev.c | 3 ++- net/sched/sch_generic.c | 44 +++++++++++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 12 deletions(-)
include/linux/netdevice.h +4 -0
@@ -1980,6 +1980,8 @@ enum netdev_reg_state {* @qdisc_hash: qdisc hash table * @watchdog_timeo: Represents the timeout that is used by * the watchdog (see dev_watchdog()) +* @watchdog_lock: protect watchdog_ref_held +* @watchdog_ref_held: True if the watchdog device ref is taken. * @watchdog_timer: List of timers * * @proto_down_reason: reason a netdev interface is held down
@@ -2392,6 +2394,8 @@ struct net_device {/* These may be needed for future network-power-down code. */ struct timer_list watchdog_timer;int watchdog_timeo; +spinlock_t watchdog_lock; +bool watchdog_ref_held;u32 proto_down_reason;
net/core/dev.c +2 -1
@@ -11217,7 +11217,8 @@ static int netif_alloc_netdev_queues(struct net_device *dev)netdev_for_each_tx_queue (dev, netdev_init_one_queue,NULL );spin_lock_init (&dev->tx_global_lock); - +spin_lock_init (&dev->watchdog_lock); + dev->watchdog_ref_held = false;return 0 ; }
net/sched/sch_generic.c +33 -11
75 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 750/2077 net: ethernet: mtk_wed: fix loading WO firmware for MT7986
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhi-Jun You <[email protected]>
[ Upstream commit 9192a18f6de2f5e3eb3813ecd2895ac0f5c008a9 ]
MT7986 requires a different mask for second WO firmware. Without this, WO would timeout after loading FW.
The correct mask was removed when adding WED for MT7988. Add it back and add a WED version check to fix it.
This can be reproduced with a MT7986 + MT7916 board.
--- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +6 -2
@@ -367,8 +367,12 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)/* wo firmware reset */ wo_w32 (MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR ,0xc00 ); - val =wo_r32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ) | -MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ; + val =wo_r32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ); + +if (!mtk_wed_is_v3_or_greater (wo->hw) && wo->hw->index) + val |=MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK ; +else + val |=MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ;wo_w32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR , val); out:release_firmware (fw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 751/2077 net/sched: sch_dualpi2: Add missing module alias
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit ee1ba0add3fbd5a28fa5423be373acd147f1e344 ]
When a qdisc is added by name, the kernel tries to autoload its module via request_qdisc_module(), which calls:
request_module(NET_SCH_ALIAS_PREFIX "%s", name);
i.e. it asks modprobe to resolve the "net-sch-<kind>" alias (e.g. "net-sch-dualpi2") rather than the module's file name. Since dualpi2 was shipped without this alias, the autoload fails:
tc qdisc add dev lo root handle 1: dualpi2
Error: Specified qdisc kind is unknown.
Fix this by adding the missing alias so the qdisc is autoloaded on demand like the others.
--- net/sched/sch_dualpi2.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_dualpi2.c +1 -0
@@ -1210,6 +1210,7 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .dump_stats = dualpi2_dump_stats, .owner = THIS_MODULE, }; +MODULE_ALIAS_NET_SCH ("dualpi2" );static int __init dualpi2_module_init (void ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 752/2077 bpf: Run generic devmap egress prog on private skb
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sun Jian <[email protected]>
[ Upstream commit 6001896f00984d317fb75160ba05c4a885fbe2a0 ]
Generic XDP devmap multi redirect uses skb_clone() for intermediate destinations and sends the last destination with the original skb. This can leave multiple destinations sharing the same packet data.
This becomes visible after generic devmap egress-program support was
added: a devmap egress program may mutate packet data, and another destination sharing the same data can observe that mutation.
Native XDP broadcast redirect does not have this issue because xdpf_clone() copies the frame data for each destination. Generic XDP should provide the same per-destination isolation before running a devmap egress program.
Fix this by making cloned skbs private before running the generic devmap egress program. Use skb_copy() instead of skb_unshare() so allocation failure does not consume the skb and the existing caller error paths keep their ownership semantics.
--- kernel/bpf/devmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
kernel/bpf/devmap.c +12 -0
@@ -710,6 +710,18 @@ int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,if (unlikely (err))return err; +if (dst->xdp_prog &&skb_cloned (skb)) { +struct sk_buff *nskb; + + nskb =skb_copy (skb,GFP_ATOMIC ); +if (!nskb) +return -ENOMEM ; + + nskb->mac_len = skb->mac_len; +consume_skb (skb); + skb = nskb; + } +/* Redirect has already succeeded semantically at this point, so we just * return 0 even if packet is dropped. Helper below takes care of * freeing skb.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 753/2077 net/mlx5: Check max_macs devlink param value against max capability
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Tatulea <[email protected]>
[ Upstream commit d7b0413b35715d7b32cb12d4d424613eff85ed2b ]
The max_macs devlink param is checked against the FW max value only at param register time (driver load) and inside the validate callback (devlink param set). The stored DRIVERINIT value persists across FW resets and devlink reloads without any further checks against the max.
If the FW link type changes from Ethernet to IB and a FW reset happens, the MAX cap for log_max_current_uc_list will become zero, but the previously stored max_macs value remains and is unconditionally programmed into the HCA caps in handle_hca_cap(). FW will then return a syndrome during SET_HCA_CAP:
mlx5_cmd_out_err:839:(pid 3831): SET_HCA_CAP(0x109) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x537801), err(-22) set_hca_cap:907:(pid 3831): handle_hca_cap failed
This results in a failure to register the RDMA device.
This patch skips programming log_max_current_uc_list when the MAX capability is 0 (in case of IB).
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +7 -5
@@ -527,7 +527,6 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx) {struct mlx5_profile *prof = &dev->profile;void *set_hca_cap; -int max_uc_list;int err; err =mlx5_core_get_caps (dev,MLX5_CAP_GENERAL );
@@ -610,10 +609,13 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)MLX5_SET (cmd_hca_cap, set_hca_cap, roce,mlx5_is_roce_on (dev)); - max_uc_list =max_uc_list_get_devlink_param (dev); -if (max_uc_list >0 ) -MLX5_SET (cmd_hca_cap, set_hca_cap, log_max_current_uc_list, -ilog2 (max_uc_list)); +if (MLX5_CAP_GEN_MAX (dev, log_max_current_uc_list)) { +int max_uc_list =max_uc_list_get_devlink_param (dev); + +if (max_uc_list >0 ) +MLX5_SET (cmd_hca_cap, set_hca_cap, + log_max_current_uc_list,ilog2 (max_uc_list)); + }/* enable absolute native port num */ if (MLX5_CAP_GEN_MAX (dev, abs_native_port_num))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 754/2077 bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Kuohai <[email protected]>
[ Upstream commit 4c71303c837449158815c521fcee4ec3b8721dbd ]
When a cgroup BPF program exits with 0, bpf_prog_run_array_cg() sets the hook return value to -EPERM if it is not a valid errno. This is correct for errno-based hooks, which return 0 on success and negative errno on failure, but wrong for boolean and void LSM hooks. Boolean LSM hooks should only return true or false, and void LSM hooks have no return value at all.
Fix it by skipping setting -EPERM for hooks not returning errno.
--- include/linux/bpf_lsm.h | 6 ++++++ kernel/bpf/bpf_lsm.c | 20 ++++++++++++++++++ kernel/bpf/cgroup.c | 47 +++++++++++++++++++++++++++++------------ 3 files changed, 60 insertions(+), 13 deletions(-)
include/linux/bpf_lsm.h +6 -0
@@ -54,6 +54,7 @@ int bpf_set_dentry_xattr_locked(struct dentry *dentry, const char *name__str, const struct bpf_dynptr *value_p, int flags);int bpf_remove_dentry_xattr_locked (struct dentry *dentry,const char *name__str);bool bpf_lsm_has_d_inode_locked (const struct bpf_prog *prog); +bool bpf_lsm_hook_returns_errno (u32 btf_id);#else /* !CONFIG_BPF_LSM */
@@ -108,6 +109,11 @@ static inline bool bpf_lsm_has_d_inode_locked(const struct bpf_prog *prog) {return false; } + +static inline bool bpf_lsm_hook_returns_errno (u32 btf_id) +{ +return true; +}#endif /* CONFIG_BPF_LSM */ #endif /* _LINUX_BPF_LSM_H */
kernel/bpf/bpf_lsm.c +20 -0
@@ -427,6 +427,26 @@ BTF_ID(func, bpf_lsm_audit_rule_known) BTF_ID(func, bpf_lsm_inode_xattr_skipcap)BTF_SET_END (bool_lsm_hooks) +/* hooks returning void */ +#define LSM_HOOK_void (DEFAULT ,NAME , ...) BTF_ID(func, bpf_lsm_##NAME) +#define LSM_HOOK_int (DEFAULT ,NAME , ...)/* nothing */ +#define LSM_HOOK (RET ,DEFAULT ,NAME , ...) LSM_HOOK_##RET(DEFAULT, NAME, __VA_ARGS__) +BTF_SET_START(void_lsm_hooks) +#include <linux/lsm_hook_defs.h> +#undef LSM_HOOK +#undef LSM_HOOK_void +#undef LSM_HOOK_int +BTF_SET_END (void_lsm_hooks) + +bool bpf_lsm_hook_returns_errno(u32 btf_id) +{ +if (btf_id_set_contains (&bool_lsm_hooks, btf_id)) +return false; +if (btf_id_set_contains (&void_lsm_hooks, btf_id)) +return false; +return true; +} +int bpf_lsm_get_retval_range (const struct bpf_prog *prog,struct bpf_retval_range *retval_range) {
kernel/bpf/cgroup.c +34 -13
78 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 755/2077 octeontx2-af: npc: Fix size of entry2cntr_map
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit f9cd6fabe0e7c7f6fc30c6c192c7ed72aba37232 ]
KASAN prints below splat. This is caused by allocating counter for reserved mcam entry for cpt 2nd pass entry. But mcam->entry2cntr_map is not allocated for reserved entries.
BUG: KASAN: slab-out-of-bounds in npc_map_mcam_entry_and_cntr+0xb0/0x1a0 Write of size 2 at addr ffff0001033e7ffe by task kworker/0:1/14 CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 6.1.67 #1 Hardware name: Marvell CN106XX board (DT) Workqueue: events work_for_cpu_fn Call trace: dump_backtrace.part.0+0xe4/0xf0 show_stack+0x18/0x30 dump_stack_lvl+0x88/0xb4 print_report+0x154/0x458 kasan_report+0xb8/0x194 __asan_store2+0x7c/0xa0 npc_map_mcam_entry_and_cntr+0xb0/0x1a0 rvu_mbox_handler_npc_mcam_write_entry+0x268/0x280 npc_install_flow+0x840/0xfe0 rvu_npc_install_cpt_pass2_entry+0x138/0x190 rvu_nix_init+0x148c/0x2880 rvu_probe+0x1800/0x30b0 local_pci_probe+0x78/0xe0 work_for_cpu_fn+0x30/0x50 process_one_work+0x4cc/0x97c worker_thread+0x360/0x630 kthread+0x1a0/0x1b0 ret_from_fork+0x10/0x20
--- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +15 -25
@@ -2181,7 +2181,7 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)/* Alloc memory for MCAM entry to counter mapping and for tracking * counter's reference count. */ - mcam->entry2cntr_map =kcalloc (mcam->bmap_entries,sizeof (u16), + mcam->entry2cntr_map =kcalloc (mcam->total_entries,sizeof (u16),GFP_KERNEL );if (!mcam->entry2cntr_map) goto free_cntr_map;
@@ -2197,10 +2197,11 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)if (!mcam->entry2target_pffunc) goto free_cntr_refcnt; -for (index =0 ; index < mcam->bmap_entries; index++) { +for (index =0 ; index < mcam->bmap_entries; index++) mcam->entry2pfvf_map[index] =NPC_MCAM_INVALID_MAP ; + +for (index =0 ; index < mcam->total_entries; index++) mcam->entry2cntr_map[index] =NPC_MCAM_INVALID_MAP ; - }for (cntr =0 ; cntr < mcam->counters.max; cntr++) mcam->cntr2pfvf_map[cntr] =NPC_MCAM_INVALID_MAP ;
@@ -3531,7 +3532,7 @@ static int __npc_mcam_free_counter(struct rvu *rvu, struct msg_rsp *rsp) {struct npc_mcam *mcam = &rvu->hw->mcam; -u16 index, entry =0 ; +u16 index;int blkaddr, err; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );
@@ -3547,20 +3548,16 @@ static int __npc_mcam_free_counter(struct rvu *rvu, mcam->cntr2pfvf_map[req->cntr] =NPC_MCAM_INVALID_MAP ;rvu_free_rsrc (&mcam->counters, req->cntr); -/* Disable all MCAM entry's stats which are using this counter */ -while (entry < mcam->bmap_entries) { +/* Disable all MCAM entry's stats which are using this counter. +* Scan the full MCAM index range: AF-reserved rules (e.g. CPT pass-2) +*/ +for (index =0 ; index < mcam->total_entries; index++) {if (!mcam->cntr_refcnt[req->cntr])break ; - - index =find_next_bit (mcam->bmap, mcam->bmap_entries, entry); -if (index >= mcam->bmap_entries) -break ; - entry = index +1 ;if (mcam->entry2cntr_map[index] != req->cntr)continue ; - -npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, - index, req->cntr); +npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, index, + req->cntr); }return 0 ;
@@ -3631,7 +3628,7 @@ int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu, struct npc_mcam_unmap_counter_req *req, struct msg_rsp *rsp) { struct npc_mcam *mcam = &rvu->hw->mcam; -u16 index, entry =0 ; +u16 index;int blkaddr, rc;/* Counter is not supported for CN20K */
@@ -3658,20 +3655,13 @@ int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu, }/* Disable all MCAM entry's stats which are using this counter */ -while (entry < mcam->bmap_entries) { +for (index =0 ; index < mcam->total_entries; index++) {if (!mcam->cntr_refcnt[req->cntr])break ; - - index =find_next_bit (mcam->bmap, mcam->bmap_entries, entry); -if (index >= mcam->bmap_entries) -break ; - entry = index +1 ; -if (mcam->entry2cntr_map[index] != req->cntr)continue ; - -npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, - index, req->cntr); +npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, index, + req->cntr); } exit:mutex_unlock (&mcam->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 756/2077 net: airoha: Fix error handling in airoha_ppe_flush_sram_entries()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit d7d81b00301398fcd38cf5b5869f0fdb674472ef ]
In airoha_ppe_flush_sram_entries(), the outer "err" variable was never updated when the inner loop variable shadowed it, causing the function to always return 0 even when airoha_ppe_foe_commit_sram_entry() fails.
Drop the outer "err" variable and return directly on error, propagating the error code from airoha_ppe_foe_commit_sram_entry() correctly.
--- drivers/net/ethernet/airoha/airoha_ppe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/airoha/airoha_ppe.c +3 -3
@@ -1330,7 +1330,7 @@ static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe) {u32 sram_num_entries =airoha_ppe_get_total_sram_num_entries (ppe);struct airoha_foe_entry *hwe = ppe->foe; -int i, err =0 ; +int i;for (i =0 ; i < sram_num_entries; i++) {int err;
@@ -1338,10 +1338,10 @@ static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe)memset (&hwe[i],0 ,sizeof (*hwe)); err =airoha_ppe_foe_commit_sram_entry (ppe, i);if (err) -break ; +return err; } -return err; +return 0 ; }static struct airoha_npu *airoha_ppe_npu_get (struct airoha_eth *eth)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 757/2077 net: ethernet: mtk_wed: debugfs: correct index in wed_amsdu_show()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Guan <[email protected]>
[ Upstream commit 14a8bc41ce9edae42d56466063a7f2c84a16c45c ]
WED_MON_AMSDU_ENG_CNT point to different entry by 'base+n*offset' mode, correct the wed amsdu entry number in wed_amsdu_show().
--- drivers/net/ethernet/mediatek/mtk_wed_debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c +3 -3
@@ -310,9 +310,9 @@ wed_amsdu_show(struct seq_file *s, void *data) WED_AMSDU_ENG_MAX_QGPP_CNT),DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_CUR_ENTRY ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (2 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_MAX_BUF_MERGED ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (2 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_MAX_MSDU_MERGED ), DUMP_STR("WED AMDSU ENG2 INFO"),
@@ -414,7 +414,7 @@ wed_amsdu_show(struct seq_file *s, void *data) WED_AMSDU_ENG_CUR_ENTRY),DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (7 ),WED_AMSDU_ENG_MAX_BUF_MERGED ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (4 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (7 ),WED_AMSDU_ENG_MAX_MSDU_MERGED ), DUMP_STR("WED AMDSU ENG8 INFO"),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 758/2077 net: wwan: t7xx: check skb_clone in control TX
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 05f789fa90d95d5771230e78453cedff2486039d ]
t7xx_port_ctrl_tx() clones each skb fragment before passing it to the port transmit path. The clone is used immediately to set cloned->len, so an skb_clone() failure results in a NULL pointer dereference.
Check the clone before using it. If previous fragments were already queued, preserve the driver's existing partial-write behavior by returning the number of bytes submitted so far.
--- drivers/net/wwan/t7xx/t7xx_port_wwan.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wwan/t7xx/t7xx_port_wwan.c +2 -0
@@ -106,6 +106,8 @@ static int t7xx_port_ctrl_tx(struct t7xx_port *port, struct sk_buff *skb)while (cur) { cloned =skb_clone (cur,GFP_KERNEL ); +if (!cloned) +return cnt ? cnt : -ENOMEM ; cloned->len =skb_headlen (cur); ret =t7xx_port_send_skb (port, cloned,0 ,0 );if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 759/2077 dpll: fix stale iteration in dpll_pin_on_pin_unregister()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 32239d600236a986c8e6d16aa814d3d91066b244 ]
Neither parent->dpll_refs nor pin->dpll_refs on its own is a correct iteration target at unregister time:
- pin->dpll_refs includes DPLLs the child was registered against via a different parent or directly; blind unregister WARNs on the cookie miss in dpll_xa_ref_pin_del().
- parent->dpll_refs reflects the parent's current attachments, not those at child-register time. Another driver may have (un)reg'd the parent against additional DPLLs in the meantime, so we miss registrations that exist and visit DPLLs that have none.
Walk pin->dpll_refs and use dpll_pin_registration_find() to filter to entries whose cookie is this parent. Symmetric with dpll_pin_on_pin_register(), correct under any subsequent change to parent->dpll_refs.
--- drivers/dpll/dpll_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/dpll/dpll_core.c +6 -1
@@ -1018,14 +1018,19 @@ EXPORT_SYMBOL_GPL(dpll_pin_on_pin_register);void dpll_pin_on_pin_unregister (struct dpll_pin *parent,struct dpll_pin *pin,const struct dpll_pin_ops *ops,void *priv) { +struct dpll_pin_registration *reg;struct dpll_pin_ref *ref;unsigned long i;mutex_lock (&dpll_lock);dpll_pin_delete_ntf (pin);dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); -xa_for_each (&pin->dpll_refs, i, ref) +xa_for_each (&pin->dpll_refs, i, ref) { + reg =dpll_pin_registration_find (ref, ops, priv, parent); +if (!reg) +continue ;__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); + }mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 760/2077 dpll: send delete notification before unregister in on-pin rollback
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit e83b403eb142be18d223fc599c0ac45519053671 ]
The rollback path in dpll_pin_on_pin_register() called __dpll_pin_unregister() before dpll_pin_delete_ntf(). When the unregister dropped the pin's last DPLL reference it cleared the DPLL_REGISTERED mark in dpll_pin_xa, so the subsequent dpll_pin_event_send() failed dpll_pin_available() and aborted with -ENODEV. As a result userspace was never notified of the rollback deletion and remained out of sync with the kernel.
Send the delete notification first, matching the order used by dpll_pin_unregister() and dpll_pin_on_pin_unregister().
--- drivers/dpll/dpll_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dpll/dpll_core.c +1 -1
@@ -994,9 +994,9 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin, dpll_unregister:xa_for_each (&parent->dpll_refs, i, ref)if (i < stop) { +dpll_pin_delete_ntf (pin);__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); -dpll_pin_delete_ntf (pin); }dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 761/2077 dpll: emit per-dpll delete notifications in dpll_pin_on_pin_unregister()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit df0ba51ccf873e533669578104981109217d8201 ]
dpll_pin_on_pin_register() emits a creation notification for every parent->dpll_refs entry, but dpll_pin_on_pin_unregister() emitted only one deletion notification outside the loop. When a pin is registered against multiple parent dplls, userspace sees N creates but a single delete and leaks per-dpll state.
Move dpll_pin_delete_ntf() into the loop and call it before __dpll_pin_unregister() so the DPLL_REGISTERED mark is still set when dpll_pin_available() is consulted.
--- drivers/dpll/dpll_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_core.c +2 -2
@@ -1023,14 +1023,14 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,unsigned long i;mutex_lock (&dpll_lock); -dpll_pin_delete_ntf (pin); -dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin);xa_for_each (&pin->dpll_refs, i, ref) { reg =dpll_pin_registration_find (ref, ops, priv, parent);if (!reg)continue ; +dpll_pin_delete_ntf (pin);__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); } +dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin);mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 762/2077 dpll: guard sync-pair removal on full pin unregister
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 0a5c720a7d57d2287d5566c4ad93ee26b7c06845 ]
__dpll_pin_unregister() wiped the global sync-pair state on every (dpll, ops, priv, cookie) tuple removed from a pin. When a pin is registered multiple times and only one registration is being torn down, this dropped sync-pair pairings still in use by the surviving registrations.
Move dpll_pin_ref_sync_pair_del() inside the xa_empty(&pin->dpll_refs) branch so it only runs when the last registration is gone, alongside clearing the DPLL_REGISTERED mark.
--- drivers/dpll/dpll_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dpll/dpll_core.c +3 -2
@@ -913,11 +913,12 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, const struct dpll_pin_ops *ops, void *priv, void *cookie) {ASSERT_DPLL_PIN_REGISTERED (pin ); -dpll_pin_ref_sync_pair_del (pin->id);dpll_xa_ref_pin_del (&dpll->pin_refs, pin, ops, priv, cookie);dpll_xa_ref_dpll_del (&pin->dpll_refs, dpll, ops, priv, cookie); -if (xa_empty (&pin->dpll_refs)) +if (xa_empty (&pin->dpll_refs)) { +dpll_pin_ref_sync_pair_del (pin->id);xa_clear_mark (&dpll_pin_xa, pin->id,DPLL_REGISTERED ); + } }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 763/2077 dpll: balance create/delete notifications in __dpll_pin_(un)register
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 1a2292101c0dc422466c673031de03d2e871adbe ]
__dpll_pin_register() emits dpll_pin_create_ntf() internally, but __dpll_pin_unregister() left the matching delete to its callers. The counts then diverge on dpll_pin_on_pin_register() rollback and on dpll_pin_on_pin_unregister(), leaking stale notifications.
Emit dpll_pin_delete_ntf() inside __dpll_pin_unregister() and drop the now-redundant call in dpll_pin_unregister().
--- drivers/dpll/dpll_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dpll/dpll_core.c +1 -1
@@ -913,6 +913,7 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, const struct dpll_pin_ops *ops, void *priv, void *cookie) {ASSERT_DPLL_PIN_REGISTERED (pin ); +dpll_pin_delete_ntf (pin);dpll_xa_ref_pin_del (&dpll->pin_refs, pin, ops, priv, cookie);dpll_xa_ref_dpll_del (&pin->dpll_refs, dpll, ops, priv, cookie);if (xa_empty (&pin->dpll_refs)) {
@@ -940,7 +941,6 @@ void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,return ;mutex_lock (&dpll_lock); -dpll_pin_delete_ntf (pin);__dpll_pin_unregister (dpll, pin, ops, priv,NULL );mutex_unlock (&dpll_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 764/2077 landlock: Fix unmarked concurrent access to socket family
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Buffet <[email protected]>
[ Upstream commit 0ce4243509d1580349dd0d50624036d6b097e958 ]
Socket family is read (twice) in a context where the socket is not locked, so another thread can setsockopt(IPV6_ADDRFORM) to write it concurrently. Add needed READ_ONCE() annotation.
Use the proper macro to access __sk_common.skc_family like everywhere else.
[mic: Squash two patches, move variable to ease backport, fix comment formatting]
--- security/landlock/net.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
security/landlock/net.c +9 -2
@@ -46,6 +46,7 @@ static int current_check_access_socket(struct socket *const sock,const int addrlen, access_mask_t access_request) { + unsigned short sock_family;__be16 port;struct layer_access_masks layer_masks = {};const struct landlock_rule *rule;
@@ -66,6 +67,12 @@ static int current_check_access_socket(struct socket *const sock,if (addrlen <offsetofend (typeof (*address), sa_family))return -EINVAL ; +/* +* The socket is not locked, so sk_family can change concurrently due to +* e.g. setsockopt(IPV6_ADDRFORM). +*/ + sock_family =READ_ONCE (sock->sk->sk_family); +switch (address->sa_family) {case AF_UNSPEC :if (access_request ==LANDLOCK_ACCESS_NET_CONNECT_TCP ) {
@@ -102,7 +109,7 @@ static int current_check_access_socket(struct socket *const sock,* these checks, but it is safer to return a proper * error and test consistency thanks to kselftest. */ -if (sock->sk->__sk_common.skc_family ==AF_INET ) { +if (sock_family ==AF_INET ) {const struct sockaddr_in *const sockaddr = (struct sockaddr_in *)address;
@@ -180,7 +187,7 @@ static int current_check_access_socket(struct socket *const sock,* check, but it is safer to return a proper error and test * consistency thanks to kselftest. */ -if (address->sa_family != sock->sk->__sk_common.skc_family && +if (address->sa_family != sock_family && address->sa_family !=AF_UNSPEC )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 765/2077 net: bcmgenet: Use weighted round-robin TX DMA arbitration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit fd615abd53110f0f815984e99e7cc51ca6b7d979 ]
Under heavy network traffic, we observed sporadic TX queue timeouts on the Raspberry Pi 4. The timeouts can be reproduced by stress testing the TX path with multiple concurrent iperf UDP streams:
iperf3 -c <ip> -u -b0 -P16 -t60
NETDEV WATCHDOG: CPU: 0: transmit queue 0 timed out 2044 ms NETDEV WATCHDOG: CPU: 3: transmit queue 0 timed out 2004 ms
Investigation showed that the timeouts are caused by the priority-based arbiter. Under heavy load the highest priority queue starves the lower priority ones, causing timeouts. The TX strict priority arbiter is not suitable for the default use case where all the traffic gets spread across all the TX queues.
Therefore, to fix this, switch the TX DMA arbiter to Weighted Round-Robin, which services all queues, so they do not stall. The weights were chosen to follow the existing priority scheme: q0 gets the smallest weight, while q1-4 get the bulk of the TX bandwidth.
--- .../net/ethernet/broadcom/genet/bcmgenet.c | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -15
@@ -40,9 +40,8 @@#include "bcmgenet.h" -/* Default highest priority queue for multi queue support */ -#define GENET_Q1_PRIORITY 0 -#define GENET_Q0_PRIORITY 1 +#define GENET_Q0_WEIGHT 1 +#define GENET_Q1_WEIGHT 4#define GENET_Q0_RX_BD_CNT \ (TOTAL_DESC - priv->hw_params->rx_queues * priv->hw_params->rx_bds_per_q)
@@ -2129,13 +2128,6 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)int i; index =skb_get_queue_mapping (skb); -/* Mapping strategy: -* queue_mapping = 0, unclassified, packet xmited through ring 0 -* queue_mapping = 1, goes to ring 1. (highest priority queue) -* queue_mapping = 2, goes to ring 2. -* queue_mapping = 3, goes to ring 3. -* queue_mapping = 4, goes to ring 4. -*/ ring = &priv->tx_rings[index]; txq =netdev_get_tx_queue (dev, index);
@@ -2881,8 +2873,9 @@ static int bcmgenet_rdma_disable(struct bcmgenet_priv *priv)/* Initialize Tx queues * -* Queues 1-4 are priority-based, each one has 32 descriptors, -* with queue 1 being the highest priority queue. +* Queues 1-4 are the priority queues, each one has 32 descriptors. +* The weighted round-robin arbiter gives them a larger share of TX +* bandwidth than the default queue 0. * * Queue 0 is the default Tx queue with * GENET_Q0_TX_BD_CNT = 256 - 4 * 32 = 128 descriptors.
@@ -2900,8 +2893,8 @@ static void bcmgenet_init_tx_queues(struct net_device *dev)unsigned int start =0 , end =GENET_Q0_TX_BD_CNT ;u32 i, ring_mask, dma_priority[3 ] = {0 ,0 ,0 }; -/* Enable strict priority arbiter mode */ -bcmgenet_tdma_writel (priv,DMA_ARBITER_SP ,DMA_ARB_CTRL ); +/* Enable Weighted Round-Robin arbiter mode */ +bcmgenet_tdma_writel (priv,DMA_ARBITER_WRR ,DMA_ARB_CTRL );/* Initialize Tx priority queues */ for (i =0 ; i <= priv->hw_params->tx_queues; i++) {
@@ -2909,7 +2902,7 @@ static void bcmgenet_init_tx_queues(struct net_device *dev) start = end; end += priv->hw_params->tx_bds_per_q; dma_priority[DMA_PRIO_REG_INDEX (i)] |= - (i ?GENET_Q1_PRIORITY :GENET_Q0_PRIORITY ) + (i ?GENET_Q1_WEIGHT :GENET_Q0_WEIGHT ) <<DMA_PRIO_REG_SHIFT (i); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 766/2077 octeontx2-af: fix NPC mailbox codes in mbox.h
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit 925551c944a1de3058dc3fb55a517eea7749835d ]
Several NPC mailbox command IDs in the 0x601x range were assigned out of order. Renumber and reorder the M() definitions so each opcode matches the stable contract expected by userspace tools and applications.
--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +15 -16
@@ -283,31 +283,30 @@ M(NPC_GET_FIELD_HASH_INFO, 0x6013, npc_get_field_hash_info,M (NPC_GET_FIELD_STATUS ,0x6014 , npc_get_field_status, \ npc_get_field_status_req, \ npc_get_field_status_rsp) \ -M (NPC_CN20K_MCAM_GET_FREE_COUNT ,0x6015 , npc_cn20k_get_fcnt, \ - msg_req, npc_cn20k_get_fcnt_rsp) \ -M (NPC_CN20K_GET_KEX_CFG ,0x6016 , npc_cn20k_get_kex_cfg, \ +M (NPC_MCAM_DEFRAG ,0x6016 , npc_defrag, \ + msg_req, \ + msg_rsp) \ +M (NPC_CN20K_GET_KEX_CFG ,0x6017 , npc_cn20k_get_kex_cfg, \ msg_req, npc_cn20k_get_kex_cfg_rsp) \ -M (NPC_CN20K_MCAM_WRITE_ENTRY ,0x6017 , npc_cn20k_mcam_write_entry, \ - npc_cn20k_mcam_write_entry_req, msg_rsp) \ -M (NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY ,0x6018 , \ -npc_cn20k_mcam_alloc_and_write_entry, \ +M (NPC_CN20K_MCAM_GET_FREE_COUNT ,0x6018 , npc_cn20k_get_fcnt, \ + msg_req, npc_cn20k_get_fcnt_rsp) \ +M (NPC_CN20K_MCAM_WRITE_ENTRY ,0x6019 , npc_cn20k_mcam_write_entry, \ + npc_cn20k_mcam_write_entry_req, msg_rsp) \ +M (NPC_CN20K_MCAM_ALLOC_AND_WRITE_ENTRY ,0x601a , npc_cn20k_mcam_alloc_and_write_entry, \ npc_cn20k_mcam_alloc_and_write_entry_req, \ npc_mcam_alloc_and_write_entry_rsp) \ -M (NPC_CN20K_MCAM_READ_ENTRY ,0x6019 , npc_cn20k_mcam_read_entry, \ +M (NPC_CN20K_MCAM_READ_ENTRY ,0x601b , npc_cn20k_mcam_read_entry, \ npc_mcam_read_entry_req, \ npc_cn20k_mcam_read_entry_rsp) \ -M (NPC_CN20K_MCAM_READ_BASE_RULE ,0x601a , npc_cn20k_read_base_steer_rule, \ - msg_req, npc_cn20k_mcam_read_base_rule_rsp) \ -M (NPC_MCAM_DEFRAG ,0x601b , npc_defrag, \ - msg_req, \ - msg_rsp) \ -M (NPC_MCAM_GET_NUM_KWS ,0x601c , npc_get_num_kws, \ +M (NPC_CN20K_MCAM_READ_BASE_RULE ,0x601c , npc_cn20k_read_base_steer_rule, \ + msg_req, npc_cn20k_mcam_read_base_rule_rsp) \ +M (NPC_MCAM_GET_NUM_KWS ,0x601d , npc_get_num_kws, \ npc_get_num_kws_req, \ npc_get_num_kws_rsp) \ -M (NPC_MCAM_GET_DFT_RL_IDXS ,0x601d , npc_get_dft_rl_idxs, \ +M (NPC_MCAM_GET_DFT_RL_IDXS ,0x601e , npc_get_dft_rl_idxs, \ msg_req, \ npc_get_dft_rl_idxs_rsp)\ -M (NPC_MCAM_GET_NPC_PFL_INFO ,0x601e , npc_get_pfl_info, \ +M (NPC_MCAM_GET_NPC_PFL_INFO ,0x601f , npc_get_pfl_info, \ msg_req, \ npc_get_pfl_info_rsp) \/* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 767/2077 net: airoha: Fix register index for Tx-fwd counter configuration
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit 1402ecccf5630a0b7fa4749d7d2e72abc3f3d73d ]
In airoha_qdma_init_qos_stats(), the Tx-fwd counter configuration register uses the same index (i << 1) as the Tx-cpu counter, which overwrites the Tx-cpu configuration. The Tx-fwd counter value register correctly uses (i << 1) + 1, so the configuration register should use the same index.
Fix the REG_CNTR_CFG index from (i << 1) to ((i << 1) + 1) so that the Tx-fwd counter is properly configured instead of clobbering the Tx-cpu counter config.
--- drivers/net/ethernet/airoha/airoha_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/airoha/airoha_eth.c +1 -1
@@ -1256,7 +1256,7 @@ static void airoha_qdma_init_qos_stats(struct airoha_qdma *qdma) FIELD_PREP(CNTR_CHAN_MASK, i));/* Tx-fwd transferred count */ airoha_qdma_wr (qdma,REG_CNTR_VAL ((i <<1 ) +1 ),0 ); - airoha_qdma_wr(qdma, REG_CNTR_CFG(i << 1), + airoha_qdma_wr(qdma, REG_CNTR_CFG((i << 1) + 1), CNTR_EN_MASK | CNTR_ALL_QUEUE_EN_MASK | CNTR_ALL_DSCP_RING_EN_MASK | FIELD_PREP(CNTR_SRC_MASK, 1) |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 768/2077 net: airoha: Fix debugfs new-tuple display for IPv4 ROUTE entries
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit 1c3a77471afbb3981af28f7f7c8b2487558e4b00 ]
In airoha_ppe_debugfs_foe_show(), the second switch statement falls through from PPE_PKT_TYPE_IPV4_HNAPT/DSLITE to PPE_PKT_TYPE_IPV4_ROUTE, accessing hwe->ipv4.new_tuple for all three types. However, IPv4 ROUTE (3-tuple) entries do not contain a valid new_tuple — this field is only meaningful for NATted flows (HNAPT/DSLITE). For ROUTE entries, the memory at the new_tuple offset holds routing information, not NAT data, so displaying "new=" produces garbage output.
Display new_tuple only for HNAPT and DSLITE, and let IPV4_ROUTE fall through to the default case.
--- drivers/net/ethernet/airoha/airoha_ppe_debugfs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/airoha/airoha_ppe_debugfs.c +0 -2
@@ -121,8 +121,6 @@ static int airoha_ppe_debugfs_foe_show(struct seq_file *m, void *private,case PPE_PKT_TYPE_IPV4_DSLITE : src_port = &hwe->ipv4.new_tuple.src_port; dest_port = &hwe->ipv4.new_tuple.dest_port; - fallthrough; -case PPE_PKT_TYPE_IPV4_ROUTE : src_addr = &hwe->ipv4.new_tuple.src_ip; dest_addr = &hwe->ipv4.new_tuple.dest_ip;seq_puts (m," new=" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 769/2077 kcm: use WRITE_ONCE() when changing lower socket callbacks
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 47186409c092cd7dd70350999186c700233e854d ]
kcm_attach() replaces a live lower TCP socket's sk_data_ready and sk_write_space callbacks with KCM handlers, and kcm_unattach() restores them later. Those callback-pointer updates are still plain stores even though the same fields can be read and invoked concurrently on other CPUs.
If another CPU observes an older callback snapshot after the live field has already been restored, callback execution can run with a mismatched target and sk_user_data state, leading to stale or misdirected wakeups.
Use WRITE_ONCE() for the callback replacement and restore operations so these shared callback fields follow the same visibility contract already established by the earlier 4022 fixes.
--- net/kcm/kcmsock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/kcm/kcmsock.c +4 -4
@@ -1304,8 +1304,8 @@ static int kcm_attach(struct socket *sock, struct socket *csock, psock->save_write_space = csk->sk_write_space; psock->save_state_change = csk->sk_state_change; csk->sk_user_data = psock; - csk->sk_data_ready = psock_data_ready; - csk->sk_write_space = psock_write_space; +WRITE_ONCE (csk->sk_data_ready, psock_data_ready); +WRITE_ONCE (csk->sk_write_space, psock_write_space); csk->sk_state_change = psock_state_change;write_unlock_bh (&csk->sk_callback_lock);
@@ -1381,8 +1381,8 @@ static void kcm_unattach(struct kcm_psock *psock)*/ write_lock_bh (&csk->sk_callback_lock); csk->sk_user_data =NULL ; - csk->sk_data_ready = psock->save_data_ready; - csk->sk_write_space = psock->save_write_space; +WRITE_ONCE (csk->sk_data_ready, psock->save_data_ready); +WRITE_ONCE (csk->sk_write_space, psock->save_write_space); csk->sk_state_change = psock->save_state_change;strp_stop (&psock->strp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 770/2077 ALSA: seq: oss: Serialize readq reset state with q->lock
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 49ce92d207820f588b0406add82f053decfbe5d9 ]
snd_seq_oss_readq_clear() resets qlen, head, and tail without q->lock even though the normal reader and producer paths serialize the same ring state under that spinlock. A reset can therefore race snd_seq_oss_readq_free() or snd_seq_oss_readq_put_event() and leave stale records in the queue, drop freshly queued ones, or report the wrong readiness after wakeup. KCSAN reports a data race between snd_seq_oss_readq_clear() and snd_seq_oss_readq_free().
Take q->lock while clearing the ring and resetting input_time. Factor the enqueue logic into a caller-locked helper so snd_seq_oss_readq_put_timestamp() updates its suppression state under the same lock instead of racing the reset path.
The buggy scenario involves two paths, with each column showing the order within that path:
reset path: locked readq updater:
1. snd_seq_oss_reset() or 1. A reader or callback producer
release reaches takes q->lock on the same queue.
snd_seq_oss_readq_clear().
2. snd_seq_oss_readq_clear() 2. The updater tests or modifies
resets qlen, head, tail, qlen, head, and tail.
and input_time.
3. snd_seq_oss_readq_clear() 3. The updater completes its
wakes sleepers on read-modify-write sequence.
q->midi_sleep.
4. Without q->lock, the reset 4. The resulting ring state drives
can overlap the locked later reads and readiness.
update.
KCSAN reports:
BUG: KCSAN: data-race in snd_seq_oss_readq_clear /
snd_seq_oss_readq_free
write to 0xffff8881069fe608 of 4 bytes by task 120516 on cpu 0:
snd_seq_oss_readq_free+0x6c/0x80 snd_seq_oss_read+0xcb/0x250 odev_read+0x38/0x60 vfs_read+0xff/0x600 ksys_read+0xb4/0x140 __x64_sys_read+0x46/0x60 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
read to 0xffff8881069fe608 of 4 bytes by task 120517 on cpu 1:
snd_seq_oss_readq_clear+0x1f/0x90 snd_seq_oss_reset+0xa7/0xf0 snd_seq_oss_ioctl+0x6f6/0x7e0 odev_ioctl+0x56/0xc0 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
value changed: 0x00000001 -> 0x00000000
--- sound/core/seq/oss/seq_oss_readq.c | 77 ++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 25 deletions(-)
sound/core/seq/oss/seq_oss_readq.c +52 -25
@@ -73,13 +73,17 @@ snd_seq_oss_readq_delete(struct seq_oss_readq *q)void snd_seq_oss_readq_clear (struct seq_oss_readq *q) { -if (q->qlen) { - q->qlen =0 ; - q->head = q->tail =0 ; + scoped_guard(spinlock_irqsave, &q->lock) { +if (q->qlen) { + q->qlen =0 ; + q->head =0 ; + q->tail =0 ; + } + q->input_time = (unsigned long )-1 ; } +/* if someone sleeping, wake'em up */ wake_up (&q->midi_sleep); - q->input_time = (unsigned long )-1 ; }/*
@@ -136,11 +140,11 @@ int snd_seq_oss_readq_sysex(struct seq_oss_readq *q, int dev,/* * copy an event to input queue: * return zero if enqueued +* caller must hold lock */ -int -snd_seq_oss_readq_put_event (struct seq_oss_readq *q,union evrec *ev) +static int snd_seq_oss_readq_put_event_locked (struct seq_oss_readq *q, +union evrec *ev) { -guard (spinlock_irqsave)(&q->lock);if (q->qlen >= q->maxlen -1 )return -ENOMEM ;
@@ -148,12 +152,27 @@ snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev) q->tail = (q->tail +1 ) % q->maxlen; q->qlen++; -/* wake up sleeper */ -wake_up (&q->midi_sleep); -return 0 ; } +/* +* copy an event to input queue: +* return zero if enqueued +*/ +int +snd_seq_oss_readq_put_event (struct seq_oss_readq *q,union evrec *ev) +{ +int rc; + + scoped_guard(spinlock_irqsave, &q->lock) { + rc =snd_seq_oss_readq_put_event_locked (q, ev); +if (!rc) +wake_up (&q->midi_sleep); + } + +return rc; +} +/* * pop queue
@@ -209,23 +228,31 @@ snd_seq_oss_readq_poll(struct seq_oss_readq *q, struct file *file, poll_table *wint snd_seq_oss_readq_put_timestamp (struct seq_oss_readq *q,unsigned long curt,int seq_mode) { -if (curt != q->input_time) { -union evrec rec; -memset (&rec,0 ,sizeof (rec)); -switch (seq_mode) { -case SNDRV_SEQ_OSS_MODE_SYNTH : - rec.echo = (curt <<8 ) |SEQ_WAIT ; -snd_seq_oss_readq_put_event (q, &rec); -break ; -case SNDRV_SEQ_OSS_MODE_MUSIC : - rec.t.code =EV_TIMING ; - rec.t.cmd =TMR_WAIT_ABS ; - rec.t.time = curt; -snd_seq_oss_readq_put_event (q, &rec); -break ; +int queued =0 ; + + scoped_guard(spinlock_irqsave, &q->lock) { +if (curt != q->input_time) { +union evrec rec; + +memset (&rec,0 ,sizeof (rec)); +switch (seq_mode) { +case SNDRV_SEQ_OSS_MODE_SYNTH : + rec.echo = (curt <<8 ) |SEQ_WAIT ; + queued = !snd_seq_oss_readq_put_event_locked (q, &rec); +break ; +case SNDRV_SEQ_OSS_MODE_MUSIC : + rec.t.code =EV_TIMING ; + rec.t.cmd =TMR_WAIT_ABS ; + rec.t.time = curt; + queued = !snd_seq_oss_readq_put_event_locked (q, &rec); +break ; + } + q->input_time = curt; } - q->input_time = curt; } +if (queued) +wake_up (&q->midi_sleep); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 771/2077 ALSA: seq: avoid stale FIFO cells during resize
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit e546128291f8d688dcb931827e2efd2aa6c0734d ]
snd_seq_fifo_resize() still needs to publish the replacement pool before it waits for FIFO users. A blocking snd_seq_read() holds f->use_lock while it sleeps, so concurrent senders must be able to queue to the new pool and wake that reader instead of failing against a closing old pool.
However, snd_seq_fifo_event_in() duplicates an event before it takes f->lock, and snd_seq_read() can dequeue a cell and later call snd_seq_fifo_cell_putback() if copy_to_user() or snd_seq_expand_var_event() fails. If resize swaps f->pool and detaches oldhead in between, either path can relink an old-pool cell after the snapshot. That stale cell sits outside the drained oldhead list, keeps oldpool->counter elevated, and can leave snd_seq_pool_delete() waiting for the retired pool to drain.
Keep the existing swap-before-wait ordering in snd_seq_fifo_resize(), but reject stale cells before any FIFO relink. Revalidate event-in cells under f->lock and retry them against the published replacement pool, and free stale putback cells instead of linking them back into the FIFO.
The buggy scenario involves two paths, with each column showing the order within that path:
resize path: relink path:
1. Allocate newpool. 1. Take f->use_lock.
2. Swap f->pool to newpool and 2. Duplicate or dequeue an old-pool
detach oldhead. cell before oldpool closes.
3. Mark oldpool closing and 3. Reach a later relink point after
wait for FIFO users. resize published newpool.
4. Free oldhead and delete 4. Relink the old-pool cell after
oldpool. resize detached oldhead.
5. Drop f->use_lock.
The reproducer reports a resize ioctl blocked in the expected pool teardown path:
signal: resize iteration=98 target_pool=4 exceeded 250ms
(elapsed=251ms) diagnostic: resize_tid=651 wchan=snd_seq_pool_done diagnostic: resize_tid=651 stack= snd_seq_pool_done+0x5b/0x140 snd_seq_pool_delete+0x7a/0x90 snd_seq_fifo_resize+0x193/0x1e0 snd_seq_ioctl_set_client_pool+0x214/0x260 snd_seq_ioctl+0x119/0x540 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
A second run with larger pools hit the same target path:
signal: resize iteration=32 target_pool=64 exceeded 250ms
(elapsed=251ms) diagnostic: resize_tid=663 wchan=snd_seq_pool_done diagnostic: resize_tid=663 stack= snd_seq_pool_done+0x5b/0x140 snd_seq_pool_delete+0x7a/0x90 snd_seq_fifo_resize+0x193/0x1e0 snd_seq_ioctl_set_client_pool+0x214/0x260 snd_seq_ioctl+0x119/0x540 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- sound/core/seq/seq_fifo.c | 52 ++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-)
sound/core/seq/seq_fifo.c +37 -15
@@ -101,13 +101,17 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event) {struct snd_seq_event_cell *cell; +struct snd_seq_pool *pool; +bool linked;int err;if (snd_BUG_ON (!f))return -EINVAL ;guard (snd_seq_fifo)(f); - err =snd_seq_event_dup (f->pool, event, &cell,1 ,NULL ,NULL );/* always non-blocking */ +retry: + pool =READ_ONCE (f->pool); + err =snd_seq_event_dup (pool, event, &cell,1 ,NULL ,NULL );/* always non-blocking */ if (err <0 ) {if ((err == -ENOMEM ) || (err == -EAGAIN ))atomic_inc (&f->overflow);
@@ -115,14 +119,24 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, }/* append new cells to fifo */ + linked = false; scoped_guard(spinlock_irqsave, &f->lock) { -if (f->tail !=NULL ) - f->tail->next = cell; - f->tail = cell; -if (f->head ==NULL ) - f->head = cell; - cell->next =NULL ; - f->cells++; +if (cell->pool == f->pool) { +if (f->tail) + f->tail->next = cell; + f->tail = cell; +if (!f->head) + f->head = cell; + cell->next =NULL ; + f->cells++; + linked = true; + } + } + +if (!linked) { +/* Retry against the replacement pool after resize publishes it. */ +snd_seq_cell_free (cell); + goto retry; }/* wakeup client */
@@ -194,13 +208,21 @@ int snd_seq_fifo_cell_out(struct snd_seq_fifo *f,void snd_seq_fifo_cell_putback (struct snd_seq_fifo *f,struct snd_seq_event_cell *cell) { +bool linked = false; +if (cell) { -guard (spinlock_irqsave)(&f->lock); - cell->next = f->head; - f->head = cell; -if (!f->tail) - f->tail = cell; - f->cells++; + scoped_guard(spinlock_irqsave, &f->lock) { +if (cell->pool == f->pool) { + cell->next = f->head; + f->head = cell; +if (!f->tail) + f->tail = cell; + f->cells++; + linked = true; + } + } +if (!linked) +snd_seq_cell_free (cell); } }
@@ -237,7 +259,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) oldpool = f->pool; oldhead = f->head;/* exchange pools */ - f->pool = newpool; +WRITE_ONCE (f->pool, newpool); f->head =NULL ; f->tail =NULL ; f->cells =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 772/2077 netfilter: nf_conncount: callers must hold rcu read lock
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 64d7d5abe2160bba369b4a8f06bdf5630573bab0 ]
rcu_derefence_raw() should not have been used here, it concealed this bug. Its used because struct rb_node lacks __rcu annotated pointers, so plain rcu_derefence causes sparse warnings.
The major tradeoff is that rcu_derefence_raw() doesn't warn when the caller isn't in a rcu read section.
Extend the rcu read lock scope accordingly and cause sparse warnings, those warnings are the lesser evil.
--- net/netfilter/nf_conncount.c | 6 +++--- net/openvswitch/conntrack.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conncount.c +3 -3
@@ -499,7 +499,7 @@ count_tree(struct net *net, hash =jhash2 (key, data->keylen, conncount_rnd) %CONNCOUNT_SLOTS ; root = &data->root[hash]; - parent =rcu_dereference_raw (root->rb_node); + parent =rcu_dereference (root->rb_node);while (parent) {int diff;
@@ -507,9 +507,9 @@ count_tree(struct net *net, diff =key_diff (key, rbconn->key, data->keylen);if (diff <0 ) { - parent =rcu_dereference_raw (parent->rb_left); + parent =rcu_dereference (parent->rb_left); }else if (diff >0 ) { - parent =rcu_dereference_raw (parent->rb_right); + parent =rcu_dereference (parent->rb_right); }else {int ret;
net/openvswitch/conntrack.c +1 -1
@@ -1797,10 +1797,10 @@ static int ovs_ct_limit_get_zone_limit(struct net *net, }else {rcu_read_lock (); limit =ct_limit_get (info, zone); -rcu_read_unlock (); err =__ovs_ct_limit_get_zone_limit ( net, info->data, zone, limit, reply); +rcu_read_unlock ();if (err)return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 773/2077 netfilter: nf_dup_netdev: add nf_dev_xmit_recursion*() helpers and use them
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 2354e975932dabb06fad239f07a3b68fd1809737 ]
Update nft_dup and nft_fwd to use the nf_dev_xmit_recursion() helpers. This patch also disables BH when transmitting the skb to address a possible migration to different CPU leading to imbalanced decrementation of the recursion counters.
This is modeled after Florian Westphal's dev_xmit_recursion*() API available since commit 97cdcf37b57e ("net: place xmit recursion in softnet data") according to its current state in the tree.
--- include/net/netfilter/nf_dup_netdev.h | 34 +++++++++++++++++++++++---- net/netfilter/nf_dup_netdev.c | 15 ++++++------ net/netfilter/nft_fwd_netdev.c | 17 ++++++++------ 3 files changed, 47 insertions(+), 19 deletions(-)
include/net/netfilter/nf_dup_netdev.h +29 -5
@@ -11,15 +11,39 @@ void nf_fwd_netdev_egress(const struct nft_pktinfo *pkt, int oif);#define NF_RECURSION_LIMIT 2 -static inline u8 *nf_get_nf_dup_skb_recursion (void ) -{#ifndef CONFIG_PREEMPT_RT -return this_cpu_ptr (&softnet_data.xmit.nf_dup_skb_recursion); +static inline bool nf_dev_xmit_recursion (void ) +{ +return unlikely (__this_cpu_read (softnet_data.xmit.nf_dup_skb_recursion) > +NF_RECURSION_LIMIT ); +} + +static inline void nf_dev_xmit_recursion_inc (void ) +{ +__this_cpu_inc (softnet_data.xmit.nf_dup_skb_recursion); +} + +static inline void nf_dev_xmit_recursion_dec (void ) +{ +__this_cpu_dec (softnet_data.xmit.nf_dup_skb_recursion); +}#else -return ¤t->net_xmit.nf_dup_skb_recursion; -#endif +static inline bool nf_dev_xmit_recursion (void ) +{ +return unlikely (current->net_xmit.nf_dup_skb_recursion >NF_RECURSION_LIMIT ); +} + +static inline void nf_dev_xmit_recursion_inc (void ) +{ + current->net_xmit.nf_dup_skb_recursion++; } +static inline void nf_dev_xmit_recursion_dec (void ) +{ + current->net_xmit.nf_dup_skb_recursion--; +} +#endif +struct nft_offload_ctx ;struct nft_flow_rule ;
net/netfilter/nf_dup_netdev.c +8 -7
@@ -16,11 +16,6 @@static void nf_do_netdev_egress (struct sk_buff *skb,struct net_device *dev,enum nf_dev_hooks hook) { -u8 *nf_dup_skb_recursion =nf_get_nf_dup_skb_recursion (); - -if (*nf_dup_skb_recursion >NF_RECURSION_LIMIT ) - goto err; -if (hook ==NF_NETDEV_INGRESS &&skb_mac_header_was_set (skb)) {if (skb_cow_head (skb, skb->mac_len)) goto err;
@@ -30,9 +25,15 @@ static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev, skb->dev = dev;skb_clear_tstamp (skb); - (*nf_dup_skb_recursion)++; +local_bh_disable (); +if (nf_dev_xmit_recursion ()) { +local_bh_enable (); + goto err; + } +nf_dev_xmit_recursion_inc ();dev_queue_xmit (skb); - (*nf_dup_skb_recursion)--; +nf_dev_xmit_recursion_dec (); +local_bh_enable ();return ; err:kfree_skb (skb);
net/netfilter/nft_fwd_netdev.c +10 -7
@@ -95,7 +95,6 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,struct nft_regs *regs, const struct nft_pktinfo *pkt) { - u8 *nf_dup_skb_recursion = nf_get_nf_dup_skb_recursion(); struct nft_fwd_neigh *priv = nft_expr_priv(expr);void *addr = ®s->data[priv->sreg_addr];int oif = regs->data[priv->sreg_dev];
@@ -154,13 +153,15 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr, goto out; } -if (*nf_dup_skb_recursion >NF_RECURSION_LIMIT ) { + dev =dev_get_by_index_rcu (nft_net (pkt), oif); +if (!dev) { verdict =NF_DROP ; goto out; } - dev =dev_get_by_index_rcu (nft_net (pkt), oif); -if (dev ==NULL ) { +local_bh_disable (); +if (nf_dev_xmit_recursion ()) { +local_bh_enable (); verdict =NF_DROP ; goto out; }
@@ -169,16 +170,18 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,if (unlikely (skb_headroom (skb) < hh_len && dev->header_ops)) { skb =skb_expand_head (skb, hh_len);if (!skb) { - verdict =NF_STOLEN ; +local_bh_enable (); goto out; } } skb->dev = dev;skb_clear_tstamp (skb); - (*nf_dup_skb_recursion)++; + +nf_dev_xmit_recursion_inc ();neigh_xmit (neigh_table, dev, addr, skb); - (*nf_dup_skb_recursion)--; +nf_dev_xmit_recursion_dec (); +local_bh_enable (); out: regs->verdict.code = verdict; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 774/2077 geneve: Fix off-by-one comparing with GRO_LEGACY_MAX_SIZE
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Mikityanska <[email protected]>
[ Upstream commit 2319688890d97c63da423a3c57c23b4ab5952dfc ]
GRO_LEGACY_MAX_SIZE = 65536; total_len being 65536 is too big to fit into a u16. As can be seen in skb_gro_receive, packets bigger or equal to gro_max_size (or GRO_LEGACY_MAX_SIZE) are dropped with -E2BIG. Apply the same boundary to geneve_post_decap_hint to avoid writing 65536 to a 16-bit iph->tot_len field with an overflow.
--- drivers/net/geneve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/geneve.c +1 -1
@@ -603,7 +603,7 @@ static int geneve_post_decap_hint(const struct sock *sk, struct sk_buff *skb, ipv6h = (void *)skb->data + gro_hint->nested_nh_offset; iph = (struct iphdr *)ipv6h; total_len = skb->len - gro_hint->nested_nh_offset; -if (total_len >GRO_LEGACY_MAX_SIZE ) +if (total_len >=GRO_LEGACY_MAX_SIZE )return -E2BIG ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 775/2077 ALSA: core: Fix unintuitive behavior of snd_power_ref_and_wait()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b113a891252c3fa4fab11ec8c2894a22ecaf278c ]
snd_power_ref_and_wait() takes the power refcount and doesn't leave it no matter whether it returns an error or not. However, the majority of callers don't expect but just returns without unreferencing in the caller side upon errors.
For addressing the potential refcount unbalance, rather correct the behavior of snd_power_ref_wait() to unreference upon returning an error.
Note that the problem above is likely negligible; the function returns an error only when the sound card is being shutdown, hence it doesn't matter about the power refcount any longer at such a state.
--- sound/core/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
sound/core/init.c +8 -3
@@ -1139,7 +1139,7 @@ EXPORT_SYMBOL(snd_card_file_remove);* typically around calling control ops. * * The caller needs to pull down the refcount via snd_power_unref() later -* no matter whether the error is returned from this function or not. +* when this function returns 0. * * Return: Zero if successful, or a negative error code. */
@@ -1152,7 +1152,11 @@ int snd_power_ref_and_wait(struct snd_card *card) card->shutdown ||snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , snd_power_unref(card), snd_power_ref(card)); -return card->shutdown ? -ENODEV :0 ; +if (card->shutdown) { +snd_power_unref (card); +return -ENODEV ; + } +return 0 ; }EXPORT_SYMBOL_GPL (snd_power_ref_and_wait);
@@ -1169,7 +1173,8 @@ int snd_power_wait(struct snd_card *card)int ret; ret =snd_power_ref_and_wait (card); -snd_power_unref (card); +if (!ret) +snd_power_unref (card);return ret; }EXPORT_SYMBOL (snd_power_wait);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 776/2077 smb: client: fix conflicting option validation for new mount API
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrique Carvalho <[email protected]>
[ Upstream commit 10ce03879f935f756bc8a386b3fa3a1c7264d950 ]
Apply conflicting option validation consistently across all the new mount API paths, for both mount and remount.
Some checks were only applied during initial mount validation, while others were handled during option parsing, causing mount and remount/reconfigure to behave differently.
Move the conflicting option checks into smb3_handle_conflicting_options() and call it from the common validation paths, including for multichannel/max_channels handling.
--- fs/smb/client/fs_context.c | 102 +++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 49 deletions(-)
fs/smb/client/fs_context.c +53 -49
@@ -693,6 +693,41 @@ static int smb3_handle_conflicting_options(struct fs_context *fc) {struct smb3_fs_context *ctx =smb3_fc2context (fc); +if (ctx->rdma && ctx->vals->protocol_id <SMB30_PROT_ID ) { +cifs_errorf (fc,"SMB Direct requires Version >=3.0\n" ); +return -EOPNOTSUPP ; + } + +if (ctx->multiuser && !IS_ENABLED (CONFIG_KEYS )) { +cifs_errorf (fc,"Multiuser mounts require kernels with CONFIG_KEYS enabled\n" ); +return -EOPNOTSUPP ; + } + +if (ctx->multiuser && ctx->upcall_target ==UPTARGET_MOUNT ) { +cifs_errorf (fc,"multiuser mount option not supported with upcalltarget set as 'mount'\n" ); +return -EINVAL ; + } + +if (ctx->uid_specified && !ctx->forceuid_specified) { + ctx->override_uid =1 ; +pr_notice ("enabling forceuid mount option implicitly because uid= option is specified\n" ); + } + +if (ctx->gid_specified && !ctx->forcegid_specified) { + ctx->override_gid =1 ; +pr_notice ("enabling forcegid mount option implicitly because gid= option is specified\n" ); + } + +if (ctx->override_uid && !ctx->uid_specified) { + ctx->override_uid =0 ; +pr_notice ("ignoring forceuid mount option specified with no uid= option\n" ); + } + +if (ctx->override_gid && !ctx->gid_specified) { + ctx->override_gid =0 ; +pr_notice ("ignoring forcegid mount option specified with no gid= option\n" ); + } +if (ctx->multichannel_specified) {if (ctx->multichannel) {if (!ctx->max_channels_specified) {
@@ -711,19 +746,14 @@ static int smb3_handle_conflicting_options(struct fs_context *fc)return -EINVAL ; } } - }else { -if (ctx->max_channels_specified) { -if (ctx->max_channels >1 ) - ctx->multichannel = true; -else - ctx->multichannel = false; - }else { + }else if (ctx->max_channels_specified) { +if (ctx->max_channels >1 ) + ctx->multichannel = true; +else ctx->multichannel = false; - ctx->max_channels =1 ; - } } -//resetting default values as remount doesn't initialize fs_context again +/* clear parse-time latches so they don't persist across remounts */ ctx->multichannel_specified = false; ctx->max_channels_specified = false;
@@ -804,28 +834,23 @@ static int smb3_fs_context_parse_monolithic(struct fs_context *fc,if (ret <0 )break ; } -return ret ?:smb3_handle_conflicting_options (fc); +return ret; }/* -* Validate the preparsed information in the config. +* smb3_fs_context_validate - check initial-mount-only constraints: +* UNC presence, address resolution, dialect warnings +* +* @fc: generic mount context */ static int smb3_fs_context_validate (struct fs_context *fc) {struct smb3_fs_context *ctx =smb3_fc2context (fc); +int rc; -if (ctx->rdma && ctx->vals->protocol_id <SMB30_PROT_ID ) { -cifs_errorf (fc,"SMB Direct requires Version >=3.0\n" ); -return -EOPNOTSUPP ; - } - -#ifndef CONFIG_KEYS -/* Muliuser mounts require CONFIG_KEYS support */ -if (ctx->multiuser) { -cifs_errorf (fc,"Multiuser mounts require kernels with CONFIG_KEYS enabled\n" ); -return -1 ; - } -#endif + rc =smb3_handle_conflicting_options (fc); +if (rc) +return rc;if (ctx->got_version == false)pr_warn_once ("No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3.1.1), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3.1.1 (or even SMB3 or SMB2.1) specify vers=1.0 on mount.\n" );
@@ -860,26 +885,6 @@ static int smb3_fs_context_validate(struct fs_context *fc)/* set the port that we got earlier */ cifs_set_port ((struct sockaddr *)&ctx->dstaddr, ctx->port); -if (ctx->uid_specified && !ctx->forceuid_specified) { - ctx->override_uid =1 ; -pr_notice ("enabling forceuid mount option implicitly because uid= option is specified\n" ); - } - -if (ctx->gid_specified && !ctx->forcegid_specified) { - ctx->override_gid =1 ; -pr_notice ("enabling forcegid mount option implicitly because gid= option is specified\n" ); - } - -if (ctx->override_uid && !ctx->uid_specified) { - ctx->override_uid =0 ; -pr_notice ("ignoring forceuid mount option specified with no uid= option\n" ); - } - -if (ctx->override_gid && !ctx->gid_specified) { - ctx->override_gid =0 ; -pr_notice ("ignoring forcegid mount option specified with no gid= option\n" ); - } -return 0 ; }
@@ -1078,6 +1083,10 @@ static int smb3_reconfigure(struct fs_context *fc)if (rc)return rc; + rc =smb3_handle_conflicting_options (fc); +if (rc) +return rc; + old_ctx =kzalloc_obj (*old_ctx);if (!old_ctx)return -ENOMEM ;
@@ -1933,11 +1942,6 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, }/* case Opt_ignore: - is ignored as expected ... */ -if (ctx->multiuser && ctx->upcall_target ==UPTARGET_MOUNT ) { -cifs_errorf (fc,"multiuser mount option not supported with upcalltarget set as 'mount'\n" ); - goto cifs_parse_mount_err; - } -return 0 ; cifs_parse_mount_err:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 777/2077 cifs: remove all cifs files before kill super
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Zhang <[email protected]>
[ Upstream commit 6d9a4aaaa8b2612b5ef9d581e2f286a458b71ee1 ]
Cifs files may be put into fileinfo_put_wq during umounting cifs. After umount done, cifsFileInfo_put_final is called, which cause following BUG:
BUG: kernel NULL pointer dereference, address: 0000000000000000 ... [ 134.222152] list_lru_add+0x64/0x1a0 [ 134.222399] ? cifs_put_tcon+0x171/0x340 [cifs] [ 134.222772] d_lru_add+0x44/0x60 [ 134.222997] dput+0x1fc/0x210 [ 134.223213] cifsFileInfo_put_final+0x11a/0x140 [cifs] [ 134.223576] process_one_work+0x17c/0x320 [ 134.223843] worker_thread+0x188/0x280 [ 134.224084] ? __pfx_worker_thread+0x10/0x10 [ 134.224366] kthread+0xcc/0x100 [ 134.224576] ? __pfx_kthread+0x10/0x10 [ 134.224827] ret_from_fork+0x30/0x50 [ 134.225063] ? __pfx_kthread+0x10/0x10 [ 134.225328] ret_from_fork_asm+0x1b/0x30
This can be reproduce by following:
unshare -n bash -c "
mkdir -p ${CIFS_MNT}
ip netns attach root 1
ip link add eth0 type veth peer veth0 netns root
ip link set eth0 up
ip -n root link set veth0 up
ip addr add 192.168.0.2/24 dev eth0
ip -n root addr add 192.168.0.1/24 dev veth0
ip route add default via 192.168.0.1 dev eth0
ip netns exec root sysctl net.ipv4.ip_forward=1
ip netns exec root iptables -t nat -A POSTROUTING -s 192.168.0.2 -o
${DEV} -j MASQUERADE
mount -t cifs ${CIFS_PATH} ${CIFS_MNT} -o vers=3.0,sec=ntlmssp,credentials=${CIFS_CRED},rsize=65536,wsize=65536,cache=none,echo_interval=1 touch ${CIFS_MNT}/a.txt
ip netns exec root iptables -t nat -D POSTROUTING -s 192.168.0.2 -o
${DEV} -j MASQUERADE
"
umount ${CIFS_MNT}
--- fs/smb/client/connect.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/connect.c +3 -0
@@ -3996,6 +3996,9 @@ cifs_umount(struct cifs_sb_info *cifs_sb) }spin_unlock (&cifs_sb->tlink_tree_lock); +flush_workqueue (serverclose_wq); +flush_workqueue (fileinfo_put_wq); +kfree (cifs_sb->prepath);call_rcu (&cifs_sb->rcu, delayed_free); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 778/2077 smb/client: always return a value for FS_IOC_GETFLAGS
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huiwen He <[email protected]>
[ Upstream commit 7acbaa16b99edaf8ef432229d4b7a6f3b666767d ]
Currently, repeated lsattr calls on a regular CIFS file without the compressed attribute may show random flags:
$ touch test.bin $ lsattr test.bin s-S-ia-A-EjI---------m test.bin $ lsattr test.bin ------d-cEjI---------m test.bin
The lsattr reproducer depends on the previous contents of its userspace buffer, so it may not reproduce on every setup. A deterministic reproducer is to initialize the ioctl argument before FS_IOC_GETFLAGS on a file without the compressed attribute:
int flags = 0x7fffffff;
ioctl(fd, FS_IOC_GETFLAGS, &flags);On an affected kernel, flags remains 0x7fffffff. With the fix, it is set to 0.
This happens because when the cached inode does not have the compressed bit set, the CIFS fallback path in FS_IOC_GETFLAGS returns success without calling put_user() to write the zero flags value into the user buffer. As a result, the caller observes stale contents from its own buffer.
Fix this by always writing the visible flags value back to the user buffer before returning success, even when the value is zero.
--- fs/smb/client/ioctl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
fs/smb/client/ioctl.c +5 -7
@@ -392,13 +392,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) }#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ #endif /* CONFIG_CIFS_POSIX */ - rc =0 ; -if (CIFS_I (inode)->cifsAttrs &ATTR_COMPRESSED ) { -/* add in the compressed bit */ - ExtAttrBits =FS_COMPR_FL ; - rc =put_user (ExtAttrBits &FS_FL_USER_VISIBLE , - (int __user *)arg); - } +if (CIFS_I (inode)->cifsAttrs &FILE_ATTRIBUTE_COMPRESSED ) + ExtAttrBits |=FS_COMPR_FL ; + + rc =put_user (ExtAttrBits &FS_FL_USER_VISIBLE , + (int __user *)arg);break ;case FS_IOC_SETFLAGS :if (pSMBFile ==NULL )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 779/2077 btrfs: Drop WQ_PERCPU from ordered_flags in btrfs_init_workqueues()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit c7703f05d85f71153f5e241184397bc34da305e3 ]
After commit 21c05ca88a54 ("workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present"), there is a warning from the btrfs-qgroup-rescan workqueue at run time:
workqueue: btrfs-qgroup-rescan uses both WQ_PERCPU and WQ_UNBOUND. Dropped WQ_PERCPU, keeping WQ_UNBOUND.
WQ_PERCPU is included in ordered_flags after commit 69635d7f4b34 ("fs:WQ_PERCPU added to alloc_workqueue users") and WQ_UNBOUND is set in alloc_ordered_workqueue(), which btrfs_alloc_ordered_workqueue() calls.
Drop WQ_PERCPU from ordered_flags, as alloc_ordered_workqueue() notes that only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful.
--- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/disk-io.c +1 -1
@@ -1928,7 +1928,7 @@ static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info) {u32 max_active = fs_info->thread_pool_size;unsigned int flags =WQ_MEM_RECLAIM |WQ_FREEZABLE |WQ_UNBOUND ; -unsigned int ordered_flags =WQ_MEM_RECLAIM |WQ_FREEZABLE |WQ_PERCPU ; +unsigned int ordered_flags =WQ_MEM_RECLAIM |WQ_FREEZABLE ; fs_info->workers =btrfs_alloc_workqueue (fs_info,"worker" , flags, max_active,16 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 780/2077 bpf: Guard __get_user acesss with access_ok for uprobe_multi data
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 4d87a251d45b4a95eb4c0abcfab809c9f231258a ]
As reported by sashiko [1] we need to use access_ok to check the user space data bounds before we use __get-user to get it.
[1] https://lore.kernel.org/bpf/[email protected]/
--- kernel/trace/bpf_trace.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/trace/bpf_trace.c +11 -0
@@ -3180,6 +3180,7 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prunsigned long __user *uoffsets;u64 __user *ucookies;void __user *upath; +unsigned long size;u32 flags, cnt, i;struct path path;char *name;
@@ -3217,6 +3218,16 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr uref_ctr_offsets =u64_to_user_ptr (attr->link_create.uprobe_multi.ref_ctr_offsets); ucookies =u64_to_user_ptr (attr->link_create.uprobe_multi.cookies); +/* +* All uoffsets/uref_ctr_offsets/ucookies arrays have the same value +* size, we need to check their address range is safe for __get_user +* calls. +*/ + size =sizeof (*uoffsets) * cnt; +if (!access_ok (uoffsets, size) || !access_ok (uref_ctr_offsets, size) || + !access_ok (ucookies, size)) +return -EFAULT ; + name =strndup_user (upath,PATH_MAX );if (IS_ERR (name)) { err =PTR_ERR (name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 781/2077 selftests/bpf: Fix typo in verify_umulti_link_info
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit df29003c55115737a8fb4f8a60c6c2bba4c4a484 ]
We verify info.uprobe_multi.flags against wrong kprobe-multi flag (BPF_F_KPROBE_MULTI_RETURN). It's the same value as the correct flag (BPF_F_UPROBE_MULTI_RETURN), so there's not functional change.
--- tools/testing/selftests/bpf/prog_tests/fill_link_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/fill_link_info.c +1 -1
@@ -469,7 +469,7 @@ verify_umulti_link_info(int fd, bool retprobe, __u64 *offsets,ASSERT_EQ (info.uprobe_multi.pid,getpid (),"info.uprobe_multi.pid" );ASSERT_EQ (info.uprobe_multi.count,3 ,"info.uprobe_multi.count" ); -ASSERT_EQ (info.uprobe_multi.flags &BPF_F_KPROBE_MULTI_RETURN , +ASSERT_EQ (info.uprobe_multi.flags &BPF_F_UPROBE_MULTI_RETURN , retprobe,"info.uprobe_multi.flags.retprobe" );ASSERT_EQ (info.uprobe_multi.path_size,strlen (path) +1 ,"info.uprobe_multi.path_size" );ASSERT_STREQ (path_buf, path,"info.uprobe_multi.path" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 782/2077 selftests/bpf: Initialize operation name before use
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 55ffbe8a15b1254f44d56952fb425a10e3f15c31 ]
ASAN reports stack-buffer-overflow due to the uninitialized op_name.
Initialize it to fix the issue.
--- tools/testing/selftests/bpf/prog_tests/verifier_log.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/verifier_log.c +1 -0
@@ -317,6 +317,7 @@ static void verif_btf_log_subtest(bool bad_btf) res =load_btf (&opts, true);ASSERT_EQ (res, -ENOSPC ,"half_log_fd" );ASSERT_EQ (strlen (logs.buf),24 ,"log_fixed_25" ); +strscpy (op_name,"log_fixed" ,sizeof (op_name));ASSERT_STRNEQ (logs.buf, logs.reference,24 , op_name);/* validate rolling verifier log logic: try all variations of log buf
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 783/2077 bpf: Fix bpf_get/setsockopt to tos for ipv4-mapped ipv6 socket
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit ca0f587c029afa66227f7b932450b1c417403394 ]
When TCP over IPv4 via INET6 API, bpf_get/setsockopt with ipv4 will fail, because sk->sk_family is AF_INET6. With ipv6 will success, not take effect, because inet_csk(sk)->icsk_af_ops is ipv6_mapped and use ip_queue_xmit, inet_sk(sk)->tos.
To relax this restriction, allow getting/setting tos for those possible ipv4-mapped ipv6 sockets.
--- net/core/filter.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/core/filter.c +14 -1
@@ -5571,11 +5571,24 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, KERNEL_SOCKPTR(optval), *optlen); } +static bool sk_allows_sol_ip_sockopt (struct sock *sk) +{ +switch (sk->sk_family) { +case AF_INET : +return true; +case AF_INET6 : +/* Allow getting/setting sockopt for possible ipv4-mapped ipv6 socket. */ +return sk->sk_type !=SOCK_RAW && !ipv6_only_sock (sk); +default : +return false; + } +} +static int sol_ip_sockopt (struct sock *sk,int optname,char *optval,int *optlen,bool getopt) { -if (sk->sk_family !=AF_INET ) +if (!sk_allows_sol_ip_sockopt (sk))return -EINVAL ;switch (optname) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 784/2077 udf: fix nls leak on udf_fill_super() failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 462bdd08fbdf41db223c6117d907c8fd68d666ea ]
On all failure exits that go to error_out there we have already moved the nls reference from uopt->nls_map to sbi->s_nls_map, leaving NULL behind.
--- fs/udf/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/udf/super.c +1 -1
@@ -2330,7 +2330,7 @@ static int udf_fill_super(struct super_block *sb, struct fs_context *fc) error_out:iput (sbi->s_vat_inode); -unload_nls (uopt->nls_map); +unload_nls (sbi->s_nls_map);if (lvid_open)udf_close_lvid (sb);brelse (sbi->s_lvid_bh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 785/2077 bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 0c0a8ed85349dae298712d79cb276acfeb794d82 ]
When the scatterlist ring is full or nearly full, bpf_msg_push_data() enters a copy fallback path and computes copy + len for the page allocation size. Since len comes from BPF with arg3_type = ARG_ANYTHING and both are u32, a crafted len can wrap the sum to a small value, causing an undersized allocation followed by an out-of-bounds memcpy.
BUG: unable to handle page fault for address: ffffed104089a402 Oops: Oops: 0000 [#1] SMP KASAN NOPTI Call Trace: __asan_memcpy (mm/kasan/shadow.c:105) bpf_msg_push_data (net/core/filter.c:2852 net/core/filter.c:2788) bpf_prog_9ed8b5711920a7d7+0x2e/0x36 sk_psock_msg_verdict (net/core/skmsg.c:934) tcp_bpf_sendmsg (net/ipv4/tcp_bpf.c:421 net/ipv4/tcp_bpf.c:584) __sys_sendto (net/socket.c:2206) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
Add an overflow check before the allocation.
--- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
@@ -2834,6 +2834,9 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,if (!space || (space ==1 && start != offset)) copy = msg->sg.data[i].length; +if (unlikely (copy + len < copy)) +return -EINVAL ; + page =alloc_pages (__GFP_NOWARN |GFP_ATOMIC | __GFP_COMP,get_order (copy + len));if (unlikely (!page))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 786/2077 sockmap: Fix use-after-free in udp_bpf_recvmsg()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit c010995b29c8939c6aa69e3cb26f8dbee163d156 ]
syzbot reported use-after-free of struct sk_msg in sk_msg_recvmsg(). [0]
sk_msg_recvmsg() peeks sk_msg from psock->ingress_msg under a lock, but its processing is lockless.
Thus, sk_msg_recvmsg() must be serialised by callers, otherwise multiple threads could touch the same sk_msg.
For example, TCP uses lock_sock(), and AF_UNIX uses unix_sk(sk)->iolock.
Initially, udp_bpf_recvmsg() had used lock_sock(), but the cited commit removed it.
Let's serialise sk_msg_recvmsg() with lock_sock() in udp_bpf_recvmsg().
Note that holding spin_lock_bh(&sk->sk_receive_queue.lock) is not an option due to copy_page_to_iter() in sk_msg_recvmsg().
[0]:
BUG: KASAN: slab-use-after-free in sk_msg_recvmsg+0xb54/0xc30 net/core/skmsg.c:428 Read of size 4 at addr ffff88814cdcf000 by task syz.0.24/6020 CPU: 1 UID: 0 PID: 6020 Comm: syz.0.24 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xba/0x230 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 sk_msg_recvmsg+0xb54/0xc30 net/core/skmsg.c:428 udp_bpf_recvmsg+0x4bd/0xe00 net/ipv4/udp_bpf.c:84 inet_recvmsg+0x260/0x270 net/ipv4/af_inet.c:891 sock_recvmsg_nosec net/socket.c:1078 [inline] sock_recvmsg+0x1a8/0x270 net/socket.c:1100 ____sys_recvmsg+0x1e6/0x4a0 net/socket.c:2812 ___sys_recvmsg+0x215/0x590 net/socket.c:2854 do_recvmmsg+0x334/0x800 net/socket.c:2949 __sys_recvmmsg net/socket.c:3023 [inline] __do_sys_recvmmsg net/socket.c:3046 [inline] __se_sys_recvmmsg net/socket.c:3039 [inline] __x64_sys_recvmmsg+0x198/0x250 net/socket.c:3039 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb319f9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb31ad97028 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00007fb31a216090 RCX: 00007fb319f9aeb9 RDX: 0000000000000001 RSI: 0000200000000400 RDI: 0000000000000004 RBP: 00007fb31a008c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000040000021 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fb31a216128 R14: 00007fb31a216090 R15: 00007ffe21dd0a98 </TASK> Allocated by task 6019: kasan_save_stack mm/kasan/common.c:57 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __kmalloc_cache_noprof+0x3d1/0x6e0 mm/slub.c:5780 kmalloc_noprof include/linux/slab.h:957 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] alloc_sk_msg net/core/skmsg.c:510 [inline] sk_psock_skb_ingress_self+0x60/0x350 net/core/skmsg.c:612 sk_psock_verdict_apply net/core/skmsg.c:1038 [inline] sk_psock_verdict_recv+0x7d9/0x8d0 net/core/skmsg.c:1236 udp_read_skb+0x73e/0x7e0 net/ipv4/udp.c:2045 sk_psock_verdict_data_ready+0x12d/0x550 net/core/skmsg.c:1257 __udp_enqueue_schedule_skb+0xc54/0x10b0 net/ipv4/udp.c:1789 __udp_queue_rcv_skb net/ipv4/udp.c:2346 [inline] udp_queue_rcv_one_skb+0xac5/0x19c0 net/ipv4/udp.c:2475 __udp4_lib_mcast_deliver+0xc06/0xcf0 net/ipv4/udp.c:2585 __udp4_lib_rcv+0x10f6/0x2620 net/ipv4/udp.c:2724 ip_protocol_deliver_rcu+0x282/0x440 net/ipv4/ip_input.c:207 ip_local_deliver_finish+0x3bb/0x6f0 net/ipv4/ip_input.c:241 NF_HOOK+0x336/0x3c0 include/linux/netfilter.h:318 dst_input include/net/dst.h:474 [inline] ip_sublist_rcv_finish+0x221/0x2a0 net/ipv4/ip_input.c:584 ip_list_rcv_finish net/ipv4/ip_input.c:628 [inline] ip_sublist_rcv+0x5c6/0xa70 net/ipv4/ip_input.c:644 ip_list_rcv+0x3f1/0x450 net/ipv4/ip_input.c:678 __netif_receive_skb_list_ptype net/core/dev.c:6195 [inline] __netif_receive_skb_list_core+0x7e5/0x810 net/core/dev.c:6242 __netif_receive_skb_list net/core/dev.c:6294 [inline] netif_receive_skb_list_internal+0x995/0xcf0 net/core/dev.c:6385 netif_receive_skb_list+0x54/0x410 net/core/dev.c:6437 xdp_recv_frames net/bpf/test_run.c:269 [inline] xdp_test_run_batch net/bpf/test_run.c:350 [inline] bpf_test_run_xdp_live+0x1946/0x1cf0 net/bpf/test_run.c:379 bpf_prog_test_run_xdp+0x81c/0x1160 net/bpf/test_run.c:1396 bpf_prog_test_run+0x2c7/0x340 kernel/bpf/syscall.c:4703 __sys_bpf+0x5cb/0x920 kernel/bpf/syscall.c:6182 __do_sys_bpf kernel/bpf/syscall.c:6274 [inline] __se_sys_bpf kernel/bpf/syscall.c:6272 [inline] __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:6272 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 6021: kasan_save_stack mm/kasan/common.c:57 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:78 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:253 [inline] __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2540 [inline] slab_free mm/slub.c:6674 [inline] kfree+0x1be/0x650 mm/slub.c:6882 kfree_sk_msg include/linux/skmsg.h:385 [inline] sk_msg_recvmsg+0xaa8/0xc30 net/core/skmsg.c:483 udp_bpf_recvmsg+0x4bd/0xe00 net/ipv4/udp_bpf.c:84 inet_recvmsg+0x260/0x270 net/ipv4/af_inet.c:891 sock_recvmsg_nosec net/socket.c:1078 [inline] sock_recvmsg+0x1a8/0x270 net/socket.c:1100 ____sys_recvmsg+0x1e6/0x4a0 net/socket.c:2812 ___sys_recvmsg+0x215/0x590 net/socket.c:2854 do_recvmmsg+0x334/0x800 net/socket.c:2949 __sys_recvmmsg net/socket.c:3023 [inline] __do_sys_recvmmsg net/socket.c:3046 [inline] __se_sys_recvmmsg net/socket.c:3039 [inline] __x64_sys_recvmmsg+0x198/0x250 net/socket.c:3039 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- net/ipv4/udp_bpf.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/ipv4/udp_bpf.c +9 -0
@@ -50,7 +50,9 @@ static int udp_msg_wait_data(struct sock *sk, struct sk_psock *psock,sk_set_bit (SOCKWQ_ASYNC_WAITDATA , sk); ret =udp_msg_has_data (sk, psock);if (!ret) { +release_sock (sk);wait_woken (&wait,TASK_INTERRUPTIBLE , timeo); +lock_sock (sk); ret =udp_msg_has_data (sk, psock); }sk_clear_bit (SOCKWQ_ASYNC_WAITDATA , sk);
@@ -79,6 +81,7 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, goto out; } +lock_sock (sk); msg_bytes_ready: copied =sk_msg_recvmsg (sk, psock, msg, len, flags);if (!copied) {
@@ -90,11 +93,17 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,if (data) {if (psock_has_data (psock)) goto msg_bytes_ready; + +release_sock (sk); + ret =sk_udp_recvmsg (sk, msg, len, flags); goto out; } copied = -EAGAIN ; } + +release_sock (sk); + ret = copied; out:sk_psock_put (sk, psock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 787/2077 bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit a48802fb2cd2d1e23651989f8ff4d15e9d5dad54 ]
start and len are u32, so
u64 last = start + len;
evaluates start + len in 32-bit and wraps before storing it in last. The bounds check
if (start >= offset + l || last > msg->sg.size) return -EINVAL;
can then be passed with an out-of-range start/len, after which the pop loop runs off the end of the scatterlist and sk_msg_shift_left() calls put_page() on the empty msg->sg.end slot:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] RIP: 0010:sk_msg_shift_left net/core/filter.c:2957 [inline] RIP: 0010:____bpf_msg_pop_data net/core/filter.c:3103 [inline] RIP: 0010:bpf_msg_pop_data+0x753/0x1a10 net/core/filter.c:2984 Call Trace: <TASK> bpf_prog_4cc92c278f4d5d56+0x1b1/0x1e8 bpf_prog_run_pin_on_cpu+0x107/0x320 include/linux/filter.h:746 sk_psock_msg_verdict+0x357/0x7f0 net/core/skmsg.c:934 tcp_bpf_send_verdict net/ipv4/tcp_bpf.c:420 [inline] tcp_bpf_sendmsg+0x766/0x1ae0 net/ipv4/tcp_bpf.c:583 __sock_sendmsg+0x153/0x1c0 net/socket.c:802 __sys_sendto+0x326/0x430 net/socket.c:2265 __x64_sys_sendto+0xe3/0x100 net/socket.c:2268 do_syscall_64+0x14c/0x480 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
Widen the addition with a (u64) cast so the bound is evaluated in 64-bit and a len near U32_MAX no longer wraps below msg->sg.size.
While here, change pop from int to u32. It counts bytes against the unsigned scatterlist lengths and can never be negative, so the signed type only invites sign-confusion in the pop loop.
--- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/filter.c +2 -2
@@ -3000,8 +3000,8 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_msg *, msg, u32, start, u32, len, u64, flags) {u32 i =0 , l =0 , space, offset =0 ; -u64 last = start + len; -int pop; +u64 last = (u64 )start + len; +u32 pop;if (unlikely (flags))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 788/2077 MIPS: mm: Fix out-of-bounds write in maar_res_walk()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yadan Fan <[email protected]>
[ Upstream commit 1b001b16bc88f3f7817e228acfd91ee01bdcfcce ]
maar_res_walk() uses wi->num_cfg as the index into the fixed-size wi->cfg array, but checks whether the array is full only after it has filled the selected entry. If walk_system_ram_range() reports more than 16 memory ranges, the overflow call writes one struct maar_config past the end of the array before WARN_ON() prevents num_cfg from advancing.
Move the full-array check before taking the array slot and return non-zero when the scratch array is full, so walk_system_ram_range() terminates the walk instead of invoking the callback for further ranges.
--- arch/mips/mm/init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/mips/mm/init.c +8 -4
@@ -272,9 +272,15 @@ static int maar_res_walk(unsigned long start_pfn, unsigned long nr_pages, void *data) {struct maar_walk_info *wi = data; -struct maar_config *cfg = &wi->cfg[wi->num_cfg]; +struct maar_config *cfg;unsigned int maar_align; +/* Ensure we don't overflow the cfg array */ +if (WARN_ON (wi->num_cfg >=ARRAY_SIZE (wi->cfg))) +return -1 ; + + cfg = &wi->cfg[wi->num_cfg]; +/* MAAR registers hold physical addresses right shifted by 4 bits */ maar_align =BIT (MIPS_MAAR_ADDR_SHIFT +4 );
@@ -283,9 +289,7 @@ static int maar_res_walk(unsigned long start_pfn, unsigned long nr_pages, cfg->upper =ALIGN_DOWN (PFN_PHYS (start_pfn + nr_pages), maar_align) -1 ; cfg->attrs =MIPS_MAAR_S ; -/* Ensure we don't overflow the cfg array */ -if (!WARN_ON (wi->num_cfg >=ARRAY_SIZE (wi->cfg))) - wi->num_cfg++; + wi->num_cfg++;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 789/2077 powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aboorva Devarajan <[email protected]>
[ Upstream commit 81e3a86030462824a67d697739cf3f387f4ba350 ]
fsl_emb_pmu_del() unconditionally calls put_cpu_var(cpu_hw_events) at the 'out:' label, but only calls the matching get_cpu_var() after the 'i < 0' early-return check. When event->hw.idx is negative the function jumps to 'out:' without having taken get_cpu_var(), and the trailing put_cpu_var() then issues an unmatched preempt_enable(), underflowing preempt_count.
On a CONFIG_PREEMPT=y kernel preempt_count would underflow and eventually present as a 'scheduling while atomic' BUG.
Move put_cpu_var() to pair with get_cpu_var() so the percpu access is correctly bracketed and the 'out:' label only handles perf_pmu_enable.
--- arch/powerpc/perf/core-fsl-emb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/perf/core-fsl-emb.c +2 -1
@@ -366,9 +366,10 @@ static void fsl_emb_pmu_del(struct perf_event *event, int flags) cpuhw->n_events--; +put_cpu_var (cpu_hw_events); + out:perf_pmu_enable (event->pmu); -put_cpu_var (cpu_hw_events); }static void fsl_emb_pmu_start (struct perf_event *event,int ef_flags)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 790/2077 powerpc/powernv: fix preempt count leak in pnv_kexec_wait_secondaries_down
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aboorva Devarajan <[email protected]>
[ Upstream commit 0ecd26e93e698c8327521910fc6296f5b84a4b92 ]
pnv_kexec_wait_secondaries_down() calls get_cpu() to obtain the current CPU id but never calls the matching put_cpu(), leaking one preempt_disable() nesting level on every invocation.
In practice the imbalance does not trigger a visible splat because the kexec teardown path is a one-way trip: IRQs are already disabled, no schedule() occurs after the leak, and default_machine_kexec() overwrites preempt_count with HARDIRQ_OFFSET before jumping into kexec_sequence() which never returns. However the bookkeeping is still wrong.
The function only needs the current CPU id, and this path runs with interrupts disabled and the CPU pinned, so the preempt_disable() side-effect of get_cpu() is unnecessary. Replace it with raw_smp_processor_id().
--- arch/powerpc/platforms/powernv/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/setup.c +2 -1
@@ -396,7 +396,8 @@ static void pnv_kexec_wait_secondaries_down(void) {int my_cpu, i, notified =-1 ; - my_cpu =get_cpu (); +/* Called with interrupts disabled, so the CPU is pinned. */ + my_cpu =raw_smp_processor_id ();for_each_online_cpu (i) {uint8_t status;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 791/2077 powerpc/kexec: fix double get_cpu() imbalance in kexec_prepare_cpus
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aboorva Devarajan <[email protected]>
[ Upstream commit 5c86f1c1f972761a04bf22f4c0618d1aa714185b ]
kexec_prepare_cpus_wait() calls get_cpu() internally to obtain the current CPU id. kexec_prepare_cpus() calls kexec_prepare_cpus_wait() twice -- once for KEXEC_STATE_IRQS_OFF and once for KEXEC_STATE_REAL_MODE -- but only issues a single put_cpu() at the end, leaving preempt_count elevated by one extra nesting level.
In practice the imbalance does not trigger a 'scheduling while atomic' splat because the kexec path is a one-way trip: IRQs are already disabled, no schedule() occurs after the leak, and default_machine_kexec() overwrites preempt_count with HARDIRQ_OFFSET before jumping into kexec_sequence() which never returns. However the bookkeeping is still wrong.
kexec_prepare_cpus() calls local_irq_disable()/hard_irq_disable() before invoking kexec_prepare_cpus_wait(), so the CPU is already pinned and the get_cpu()/put_cpu() preempt_disable() bracketing is unnecessary. Only the current CPU id is needed, so replace get_cpu() with raw_smp_processor_id() and drop the now-unneeded put_cpu().
--- arch/powerpc/kexec/core_64.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/kexec/core_64.c +1 -3
@@ -169,7 +169,7 @@ static void kexec_prepare_cpus_wait(int wait_state)int my_cpu, i, notified=-1 ;hw_breakpoint_disable (); - my_cpu =get_cpu (); + my_cpu =raw_smp_processor_id ();/* Make sure each CPU has at least made it to the state we need. * * FIXME: There is a (slim) chance of a problem if not all of the CPUs
@@ -267,8 +267,6 @@ static void kexec_prepare_cpus(void)/* after we tell the others to go down */ if (ppc_md.kexec_cpu_down) ppc_md.kexec_cpu_down(0, 0); - - put_cpu(); }#else /* ! SMP */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 792/2077 KEYS: Use acquire when reading state in keyring search
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit c1201b37f666f6466ab1fd3a381c2b7a4b7e9fee ]
The negative-key race fix added release/acquire ordering for key use.
Publish payload before state; read state before payload.
keyring_search_iterator() still uses READ_ONCE() before match callbacks. An asymmetric match callback calls asymmetric_key_ids(), which reads key->payload.data[asym_key_ids].
Use key_read_state() there to complete that ordering.
--- security/keys/keyring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyring.c +1 -1
@@ -576,7 +576,7 @@ static int keyring_search_iterator(const void *object, void *iterator_data)struct keyring_search_context *ctx = iterator_data;const struct key *key =keyring_ptr_to_key (object);unsigned long kflags =READ_ONCE (key->flags); -short state =READ_ONCE (key->state); +short state =key_read_state (key);kenter ("{%d}" , key->serial);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 793/2077 tipc: fix UAF in tipc_l2_send_msg()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit f4c3d89fc986b0da196ddfc6cfe0ea5d5d08bec6 ]
Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().
The root cause is that tipc_disable_l2_media() calls synchronize_net() while b->media_ptr is still valid. This allows concurrent RCU readers to obtain the device pointer after synchronize_net() has finished. The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.
Fix this by clearing b->media_ptr in tipc_disable_l2_media() before calling synchronize_net().
This is safe to do now because the call order in bearer_disable() was reversed in 0d051bf93c06 ("tipc: make bearer packet filtering generic") to call tipc_node_delete_links() (which needs the pointer) before disable_media().
https: //lore.kernel.org/netdev/[email protected]/T/#u
--- net/tipc/bearer.c | 1 + 1 file changed, 1 insertion(+)
net/tipc/bearer.c +1 -0
@@ -482,6 +482,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b) dev = (struct net_device *)rtnl_dereference (b->media_ptr);dev_remove_pack (&b->pt);RCU_INIT_POINTER (dev->tipc_ptr,NULL ); +RCU_INIT_POINTER (b->media_ptr,NULL );synchronize_net ();dev_put (dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 794/2077 tcp: ipv6: clamp default adverting MSS to avoid GSO_BY_FRAGS (0xFFFF)
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 2bf43d0e2e6a27d52a7d624e2d6b9116972e8a22 ]
When MTU is large, ip6_default_advmss() can return IPV6_MAXPLEN (65535). This is interpreted by TCP as mss_clamp, allowing the MSS to reach 65535.
However, 0xFFFF is also used as a magic value GSO_BY_FRAGS in the kernel. If a TCP packet with gso_size=0xFFFF is passed to skb_segment(), it will be mistakenly treated as GSO_BY_FRAGS, leading to a NULL pointer dereference because local TCP packets do not use frag_list.
Fix this by returning min(IPV6_MAXPLEN, GSO_BY_FRAGS - 1) (65534) from ip6_default_advmss() when MTU is large.
Also update the stale comment in ip6_default_advmss() which suggested that IPV6_MAXPLEN is returned to mean "any MSS".
--- net/ipv6/route.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/route.c +3 -3
@@ -3275,11 +3275,11 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)/* * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and * corresponding MSS is IPV6_MAXPLEN - tcp_header_size. -* IPV6_MAXPLEN is also valid and means: "any MSS, -* rely only on pmtu discovery" +* Limit the default MSS to GSO_BY_FRAGS - 1 to avoid +* collision with the GSO_BY_FRAGS magic value (0xFFFF). */ if (mtu >IPV6_MAXPLEN -sizeof (struct tcphdr )) - mtu =IPV6_MAXPLEN ; + mtu = min_t(unsigned int, IPV6_MAXPLEN, GSO_BY_FRAGS - 1);return mtu; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 795/2077 net: airoha: Fix always-true condition in PPE1 queue reservation loop
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit c66f8511a8109fa50767941b26d3623e316fde02 ]
In airoha_fe_pse_ports_init(), the inner condition for PPE1 queue reservation is identical to the for-loop bound, making it always true and the else branch dead code:
for (q = 0; q < pse_port_num_queues[FE_PSE_PORT_PPE1]; q++) {
if (q < pse_port_num_queues[FE_PSE_PORT_PPE1]) /* always true */
set RSV_PAGES;
else
set 0; /* unreachable */
}The intended behavior is to reserve pages only for the first half of the queues, matching the PPE2 implementation on line 334 which correctly uses the /2 divisor. Fix the PPE1 condition accordingly.
--- drivers/net/ethernet/airoha/airoha_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/airoha/airoha_eth.c +1 -1
@@ -311,7 +311,7 @@ static void airoha_fe_pse_ports_init(struct airoha_eth *eth) PSE_QUEUE_RSV_PAGES);/* PPE1 */ for (q =0 ; q < pse_port_num_queues[FE_PSE_PORT_PPE1 ]; q++) { -if (q < pse_port_num_queues[FE_PSE_PORT_PPE1 ]) +if (q < pse_port_num_queues[FE_PSE_PORT_PPE1 ] /2 )airoha_fe_set_pse_oq_rsv (eth,FE_PSE_PORT_PPE1 , q,PSE_QUEUE_RSV_PAGES );else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 796/2077 net: ti: icssg-prueth: Fix AF_XDP fill ring alloc and wakeup condition
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meghana Malladi <[email protected]>
[ Upstream commit dfb787f7d157f97ba91344b584d33481f572530e ]
emac_rx_packet_zc() calls prueth_rx_alloc_zc() with count (frames received in the current NAPI poll) as the allocation budget. Two problems arise from this:
1. When the CPPI5 descriptor pool is exhausted (avail_desc == 0, FDQ already holds the maximum number of descriptors), count > 0 still triggers allocation attempts that all fail, spamming the kernel log with "rx push: failed to allocate descriptor" at high packet rates.
2. The XSK wakeup condition "ret < count" is wrong when avail_desc is zero: ret == 0 and count can be up to 64, so the condition is always true. This causes ~200 spurious ndo_xsk_wakeup() calls per second even when the FDQ is already full, wasting CPU cycles in repeated NAPI invocations that process zero frames.
Fix both by introducing alloc_budget = min(budget, avail_desc):
- When avail_desc == 0 no allocation is attempted, avoiding pool exhaustion errors. The wakeup condition "ret < alloc_budget" evaluates to 0 < 0 == false, correctly clearing the wakeup flag so the hardware IRQ re-arms NAPI without spurious kicks.
- In steady state avail_desc == count <= budget, so alloc_budget == count and behaviour is unchanged.
- After a dry-ring stall (count == 0, avail_desc > 0), alloc_budget
Quoted 1 line
0 causes new descriptors to be posted to the FDQ so the hardware
can resume receiving immediately.
--- drivers/net/ethernet/ti/icssg/icssg_common.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +6 -8
@@ -927,6 +927,7 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id,struct cppi5_host_desc_t *desc_rx;struct prueth_swdata *swdata;dma_addr_t desc_dma, buf_dma; +int avail_desc, alloc_budget;struct xdp_buff *xdp;int xdp_status =0 ;int count =0 ;
@@ -993,16 +994,13 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id,if (xdp_status &ICSSG_XDP_REDIR )xdp_do_flush (); -/* Allocate xsk buffers from the pool for the "count" number of -* packets processed in order to be able to receive more packets. -*/ - ret =prueth_rx_alloc_zc (emac, count); + avail_desc =k3_cppi_desc_pool_avail (rx_chn->desc_pool); + alloc_budget =min_t (int, budget, avail_desc); + + ret =prueth_rx_alloc_zc (emac, alloc_budget);if (xsk_uses_need_wakeup (rx_chn->xsk_pool)) { -/* If the user space doesn't provide enough buffers then it must -* explicitly wake up the kernel when new buffers are available -*/ -if (ret < count) +if (ret < alloc_budget)xsk_set_rx_need_wakeup (rx_chn->xsk_pool);else xsk_clear_rx_need_wakeup (rx_chn->xsk_pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 797/2077 net: ti: icssg: Use undirected TX tag for native XDP in HSR offload mode
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meghana Malladi <[email protected]>
[ Upstream commit bcbf73d98195577a89e788179843f6d0c66244a5 ]
emac_xmit_xdp_frame() always sets the CPPI5 descriptor destination tag to emac->port_id, which directs the PRU firmware to transmit the frame on that specific slave port only. In HSR offload mode this bypasses the firmware's HSR duplication logic: the frame goes out on one ring leg and never appears on the other, breaking HSR redundancy for XDP_TX paths.
icssg_ndo_start_xmit() already handles this correctly: when HSR offload mode is active and NETIF_F_HW_HSR_DUP is set it substitutes PRUETH_UNDIRECTED_PKT_DST_TAG (port 0) so the PRU duplicates the frame to both slave ports. It also sets PRUETH_UNDIRECTED_PKT_TAG_INS in epib[1] when NETIF_F_HW_HSR_TAG_INS is set so the PRU inserts the HSR sequence tag, which XDP_TX frames lack (the tag is stripped by the PRU on RX before the frame reaches the XDP program).
Apply the same logic in emac_xmit_xdp_frame() so XDP_TX frames in HSR mode are treated identically to skb TX via hsr0.
--- drivers/net/ethernet/ti/icssg/icssg_common.c | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +19 -2
@@ -696,6 +696,7 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,dma_addr_t desc_dma, buf_dma;struct prueth_swdata *swdata;struct page *page; +u32 dst_tag_id;u32 *epib;int ret;
@@ -737,9 +738,25 @@ u32 emac_xmit_xdp_frame(struct prueth_emac *emac,/* set dst tag to indicate internal qid at the firmware which is at * bit8..bit15. bit0..bit7 indicates port num for directed -* packets in case of switch mode operation +* packets in case of switch mode operation and port num 0 +* for undirected packets in case of HSR offload mode. +* +* XDP_TX frames arrive on a slave port with the HSR tag already +* stripped by the PRU firmware. Like skb TX via hsr0, they must +* be sent as undirected so the PRU duplicates them to both ports +* and re-inserts the HSR sequence tag. */ -cppi5_desc_set_tags_ids (&first_desc->hdr,0 , (emac->port_id | (q_idx <<8 ))); + dst_tag_id = emac->port_id | (q_idx <<8 ); + +if (emac->prueth->is_hsr_offload_mode && + (ndev->features &NETIF_F_HW_HSR_DUP )) + dst_tag_id =PRUETH_UNDIRECTED_PKT_DST_TAG ; + +if (emac->prueth->is_hsr_offload_mode && + (ndev->features &NETIF_F_HW_HSR_TAG_INS )) + epib[1 ] |=PRUETH_UNDIRECTED_PKT_TAG_INS ; + +cppi5_desc_set_tags_ids (&first_desc->hdr,0 , dst_tag_id);k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn->tx_chn, &buf_dma);cppi5_hdesc_attach_buf (first_desc, buf_dma, xdpf->len, buf_dma, xdpf->len); swdata =cppi5_hdesc_get_swdata (first_desc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 798/2077 net: ti: icssg: Use undirected TX tag for XDP zero copy in HSR offload mode
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meghana Malladi <[email protected]>
[ Upstream commit f9691288413ceb4fc72f3ccc4d8e42adf66eb28d ]
emac_xsk_xmit_zc() has the same issue as the fixed emac_xmit_xdp_frame():
it always sets the CPPI5 descriptor destination tag to emac->port_id, which directs the PRU firmware to transmit on only one slave port in HSR mode, breaking redundancy.
Apply the same fix: in HSR offload mode when NETIF_F_HW_HSR_DUP is set, use PRUETH_UNDIRECTED_PKT_DST_TAG (port 0) so the PRU duplicates frames to both ports. Also set PRUETH_UNDIRECTED_PKT_TAG_INS when NETIF_F_HW_HSR_TAG_INS is set so the PRU re-inserts the HSR sequence tag that was stripped by the PRU on RX before the XDP program saw the frame.
This ensures XSK XDP_TX frames in HSR mode are treated identically to skb TX via hsr0.
--- drivers/net/ethernet/ti/icssg/icssg_common.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +11 -2
@@ -105,6 +105,7 @@ static int emac_xsk_xmit_zc(struct prueth_emac *emac,struct xdp_desc xdp_desc;int num_tx =0 , pkt_len;int descs_avail, ret; +u32 dst_tag_id;u32 *epib;int i;
@@ -137,9 +138,17 @@ static int emac_xsk_xmit_zc(struct prueth_emac *emac, epib[0 ] =0 ; epib[1 ] =0 ;cppi5_hdesc_set_pktlen (host_desc, pkt_len); -cppi5_desc_set_tags_ids (&host_desc->hdr,0 , - (emac->port_id | (q_idx <<8 ))); + dst_tag_id = emac->port_id | (q_idx <<8 ); + +if (emac->prueth->is_hsr_offload_mode && + (ndev->features &NETIF_F_HW_HSR_DUP )) + dst_tag_id =PRUETH_UNDIRECTED_PKT_DST_TAG ; + +if (emac->prueth->is_hsr_offload_mode && + (ndev->features &NETIF_F_HW_HSR_TAG_INS )) + epib[1 ] |=PRUETH_UNDIRECTED_PKT_TAG_INS ; +cppi5_desc_set_tags_ids (&host_desc->hdr,0 , dst_tag_id);k3_udma_glue_tx_dma_to_cppi5_addr (tx_chn->tx_chn, &dma_buf);cppi5_hdesc_attach_buf (host_desc, dma_buf, pkt_len, dma_buf, pkt_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 799/2077 net: ethernet: oa_tc6: mdiobus->parent initialized with NULL
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvamani Rajagopal <[email protected]>
[ Upstream commit a221d3f7e3f3ea6a3b4bc511cf2a59242daa06e1 ]
As "dev" pointer in oa_tc6 structure is never initialized, mbiobus->parent was initialized with NULL. This change fixes it by initializing it with device pointer of spi.
--- drivers/net/ethernet/oa_tc6.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/oa_tc6.c +1 -2
@@ -107,7 +107,6 @@/* Internal structure for MAC-PHY drivers */ struct oa_tc6 { -struct device *dev;struct net_device *netdev;struct phy_device *phydev;struct mii_bus *mdiobus;
@@ -518,7 +517,7 @@ static int oa_tc6_mdiobus_register(struc tc6->mdiobus->read_c45 = oa_tc6_mdiobus_read_c45; tc6->mdiobus->write_c45 = oa_tc6_mdiobus_write_c45; tc6->mdiobus->name ="oa-tc6-mdiobus" ; - tc6->mdiobus->parent = tc6->dev; + tc6->mdiobus->parent = &tc6->spi->dev;snprintf (tc6->mdiobus->id,ARRAY_SIZE (tc6->mdiobus->id),"%s" ,dev_name (&tc6->spi->dev));
Greg Kroah-Hartman
maintainerPATCH 800/2077 net: ethernet: oa_tc6: Remove FCS size in RX frame
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvamani Rajagopal <[email protected]>
[ Upstream commit a5a1d11dd3729146abe7420b874bab15870a42b4 ]
OA TC6 MAC-PHY appends FCS to the incoming frame. It must be removed from the frame before being passed to the stack.
With FCS in the frame, many applications, like ping or any application that uses IP layer may work as they may carry the packet size information in the protocol.
Application like ptp4l, particularly if it uses layer 2 for its communication, it will fail with "bad message" due to the extra 4 bytes added by the presence of FCS.
--- drivers/net/ethernet/oa_tc6.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/ethernet/oa_tc6.c +11 -0
@@ -751,6 +751,17 @@ static int oa_tc6_process_rx_chunk_footestatic void oa_tc6_submit_rx_skb (struct oa_tc6 *tc6) { +/* MAC-PHY delivers each frame with its Ethernet FCS attached. +* Strip it before handing over to the stack, unless the user +* has asked to keep it via NETIF_F_RXFCS. Keeping the FCS +* in the frame is harmless for IP traffic, but is parsed as +* a (malformed) suffix TLV by PTP, which makes ptp4l reject +* every message with "bad message" error. +*/ +if (!(tc6->netdev->features &NETIF_F_RXFCS ) && + tc6->rx_skb->len >ETH_FCS_LEN ) +skb_trim (tc6->rx_skb, tc6->rx_skb->len -ETH_FCS_LEN ); + tc6->rx_skb->protocol =eth_type_trans (tc6->rx_skb, tc6->netdev); tc6->netdev->stats.rx_packets++; tc6->netdev->stats.rx_bytes += tc6->rx_skb->len;
Greg Kroah-Hartman
maintainerPATCH 801/2077 dt-bindings: net: updated interrupt type to be active low, level triggered
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvamani Rajagopal <[email protected]>
[ Upstream commit 31e56112e6544afba0a50d60251175585ee62943 ]
According to OPEN Alliance 10BASE-T1x MACPHY Serial Interface (TC6) specification, interrupt type is active low, level triggered interrupt.
Specification calls for when interrupt level will be asserted and what condition it is de-asserted. By using edge triggered interrupt, there is a potential chance to miss it, particularly if it is asserted when interrupt is disabled.
Level triggered interrupt can't be missed as it gets de-asserted only on interrupt handler taking actions on interrupting conditions.
--- Documentation/devicetree/bindings/net/microchip,lan8650.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/microchip,lan8650.yaml +1 -1
@@ -67,7 +67,7 @@ examples: pinctrl-names = "default"; pinctrl-0 = <ð0_pins>; interrupt-parent = <&gpio>; - interrupts = <6 IRQ_TYPE_EDGE_FALLING>; + interrupts = <6 IRQ_TYPE_LEVEL_LOW>; local-mac-address = [04 05 06 01 02 03]; spi-max-frequency = <15000000>; };
Signature · 1 line
2.53.0
RE: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggered
Quoted 8 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Tuesday, July 21, 2026 8:08 AM
Subject: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggered
Quoted 6 lines
---
Documentation/devicetree/bindings/net/microchip,lan8650.yaml| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)- interrupts = <6
IRQ_TYPE_EDGE_FALLING>;
+ interrupts = <6IRQ_TYPE_LEVEL_LOW>;
Wouldn't this need to go in along with source code changes to drivers/net/ethernet/oa_tc6.c? Otherwise, binding would say IRQ_TYPE_LEVEL_LOW, but the code in oa_tc6.c would be using IRQ_TYPE_EDGE_FALLING. If that is acceptable, then it is fine.
FYI: drivers/net/ethernet/oa_tc6.c isn't ready for pulling into 7.1 or 6.18 as we have a follow-up patches to the "net" repo that is still under review.
Greg Kroah-Hartman
maintainerRe: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggered
Quoted 15 lines · Selvamani Rajagopal
Quoted 8 lines
-----Original Message-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Tuesday, July 21, 2026 8:08 AM
Subject: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggeredQuoted 6 lines
---
Documentation/devicetree/bindings/net/microchip,lan8650.yaml| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)- interrupts = <6
IRQ_TYPE_EDGE_FALLING>;
+ interrupts = <6IRQ_TYPE_LEVEL_LOW>;
Quoted 7 lines
Wouldn't this need to go in along with source code changes to
drivers/net/ethernet/oa_tc6.c? Otherwise, binding would sayIRQ_TYPE_LEVEL_LOW, but the code inoa_tc6.cwould be usingIRQ_TYPE_EDGE_FALLING. If that is acceptable, then it is fine.FYI:
drivers/net/ethernet/oa_tc6.cisn't ready for pulling into 7.1 or 6.18 as we have a follow-up patches to the "net" repo that is still under review.
Ok, then the "Fixes:" tag in this commit was wrong. I'll go drop this from all stable queues now, thanks for the review!
greg k-h
Sasha Levin
maintainerRe: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggered
In reply to Selvamani RajagopalQuoted 3 lines · Selvamani Rajagopal
Wouldn't this need to go in along with source code changes to
drivers/net/ethernet/oa_tc6.c? Otherwise, binding would sayIRQ_TYPE_LEVEL_LOW, but the code inoa_tc6.cwould be usingIRQ_TYPE_EDGE_FALLING. If that is acceptable, then it is fine.
You're right - the companion driver change (b542d13fab0f) was already dropped at your request, so this binding change makes no sense on its own. Dropped it from the 7.1, 6.18, and 6.12 queues.
Quoted 2 lines
FYI:
drivers/net/ethernet/oa_tc6.cisn't ready for pulling into 7.1 or 6.18 as we have a follow-up patches to the "net" repo that is still under review.
I've also dropped the mdiobus->parent fix (a221d3f7e3f3) from the 7.1, 6.18, and 6.12 queues. We'll requeue the whole set together once your follow-up series lands upstream.
The one patch I kept is the FCS trim fix (a5a1d11dd372 "net: ethernet:oa_tc6: remove FCS size in rx frame"): I verified it against your pending "fix race condition and crash" v3 series and it's independent of both pending fixes - the race fix targets the threaded-IRQ state that's no longer in the stable queues, and the skb_over_panic fix doesn't touch oa_tc6_submit_rx_skb(). It fixes real user-visible ptp4l breakage, so I'd like it to ship. If you'd rather see that one held back too, please let me know.
Signature · 2 lines
Thanks, Sasha
RE: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggered
Quoted 10 lines
-----Original Message-----
From: Sasha Levin <[email protected]>
Sent: Wednesday, July 22, 2026 9:43 AM
Subject: Re: [PATCH 7.1 0801/2077] dt-bindings: net: updated interrupt type to be active low, level triggeredI've also dropped the
mdiobus->parentfix (a221d3f7e3f3) from the 7.1, 6.18, and 6.12 queues. We'll requeue the whole set together once your follow-up series lands upstream.
a221d3f7e3f3 (mdiobus->parent) fix is also an independent fix in case you want to re-consider. Parent pointer was NULL before. It is getting initialized with SPI device pointer now.
Quoted 4 lines
The one patch I kept is the FCS trim fix (
a5a1d11dd372"net: ethernet:oa_tc6: remove FCS size in rx frame"): I verified it against your pending "fix race condition and crash" v3 series and it's independent
Agree. It is independent change with no side effects in taking to other branches.
Greg Kroah-Hartman
maintainerPATCH 802/2077 ionic: Fix check in ionic_get_link_ext_stats
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 7678e69079c10b2fb10977f28f44ddb22971ea5b ]
The current check will fail if SR-IOV is not initialized for the physical function; this is because is_physfn is 0 if sriov_init() isn't run or fails. Change the check that prevents getting the link down count to use is_virtfn instead so that VFs don't get this functionality, which was the original intent.
--- drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +9 -2
@@ -116,8 +116,15 @@ static void ionic_get_link_ext_stats(struct net_device *netdev, {struct ionic_lif *lif =netdev_priv (netdev); -if (lif->ionic->pdev->is_physfn) - stats->link_down_events = lif->link_down_count; +if (lif->ionic->pdev->is_virtfn) +return ; + +if (!lif->ionic->idev.port_info) { +netdev_err_once (netdev,"port_info not initialized\n" ); +return ; + } + + stats->link_down_events = lif->link_down_count; } static int ionic_get_link_ksettings(struct net_device *netdev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 803/2077 RDMA/bnxt_re: Initialize dpi variable to zero
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 978b27d6ce538bb832ccd69e45802824e4301c4b ]
dpi is initialized only for BNXT_RE_ALLOC_WC_PAGE, but copied for all the cases. So initialize the dpi to 0.
--- drivers/infiniband/hw/bnxt_re/uapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/uapi.c +1 -1
@@ -76,8 +76,8 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *struct ib_ucontext *ib_uctx;struct bnxt_re_dev *rdev;u64 mmap_offset; +u32 dpi =0 ;u32 length; -u32 dpi;u64 addr;int err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 804/2077 RDMA/bnxt_re: Free SRQ toggle page after firmware teardown
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 131e2918b9b0529687e67e2e58047304027f095a ]
Free the toggle page only after firmware teardown completes so that an NQ interrupt arriving during bnxt_qplib_destroy_srq() won't write the toggle values to an already-freed page. Move free_page() after bnxt_qplib_destroy_srq().
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +3 -3
@@ -2029,11 +2029,11 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)if (ret)return ret; -if (rdev->chip_ctx->modes.toggle_bits &BNXT_QPLIB_SRQ_TOGGLE_BIT ) { -free_page ((unsigned long )srq->uctx_srq_page); +if (rdev->chip_ctx->modes.toggle_bits &BNXT_QPLIB_SRQ_TOGGLE_BIT )hash_del (&srq->hash_entry); - }bnxt_qplib_destroy_srq (&rdev->qplib_res, qplib_srq); +if (rdev->chip_ctx->modes.toggle_bits &BNXT_QPLIB_SRQ_TOGGLE_BIT ) +free_page ((unsigned long )srq->uctx_srq_page);ib_umem_release (srq->umem);atomic_dec (&rdev->stats.res.srq_count);return ib_respond_empty_udata (udata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 805/2077 RDMA/bnxt_re: Free CQ toggle page after firmware teardown
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit bb45e06f9914ca64ac95341a80a0c20bb8dd46a9 ]
Free the toggle page only after firmware teardown completes so that an NQ interrupt arriving during bnxt_qplib_destroy_cq() won't write the toggle value to an already-freed page. Move free_page() after bnxt_qplib_destroy_cq.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +3 -3
@@ -3332,11 +3332,11 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)if (ret)return ret; -if (cctx->modes.toggle_bits &BNXT_QPLIB_CQ_TOGGLE_BIT ) { -free_page ((unsigned long )cq->uctx_cq_page); +if (cctx->modes.toggle_bits &BNXT_QPLIB_CQ_TOGGLE_BIT )hash_del (&cq->hash_entry); - }bnxt_qplib_destroy_cq (&rdev->qplib_res, &cq->qplib_cq); +if (cctx->modes.toggle_bits &BNXT_QPLIB_CQ_TOGGLE_BIT ) +free_page ((unsigned long )cq->uctx_cq_page);bnxt_re_put_nq (rdev, nq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 806/2077 RDMA/bnxt_re: Avoid displaying the kernel pointer
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 7d70c704a06f620d5d421ab76bac5e225bfb4308 ]
While dumping the info on MR using the rdma tool, we dump the mr_hwq which is a kernel pointer. There is no need to expose this value for end user. So avoid it.
--- drivers/infiniband/hw/bnxt_re/main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +0 -2
@@ -1093,8 +1093,6 @@ static int bnxt_re_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr) goto err;if (rdma_nl_put_driver_u32 (msg,"element_size" , mr_hwq->element_size)) goto err; -if (rdma_nl_put_driver_u64_hex (msg,"hwq" , (unsigned long )mr_hwq)) - goto err;if (rdma_nl_put_driver_u64_hex (msg,"va" , mr->qplib_mr.va)) goto err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 807/2077 RDMA/bnxt_re: Refactor bnxt_re_init_user_qp()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sriharsha Basavapatna <[email protected]>
[ Upstream commit 9a79dcbedcc7a0330a227f23fbd220515c61d54c ]
The umem changes for CQ added a helper - bnxt_re_setup_sginfo(). Use the same helper for QP creation since we support only 4K pages for QP ring memory too.
Add a new helper function bnxt_re_get_psn_bytes() to improve readability as this code will be updated in subsequent patches.
Stable-dep-of: dc95931b7e13 ("RDMA/bnxt_re: Add a max slot check for SQ")
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 127 +++++++++++++---------- 1 file changed, 73 insertions(+), 54 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +73 -54
@@ -1136,34 +1136,64 @@ static int bnxt_re_setup_swqe_size(struct bnxt_re_qp *qp,return 0 ; } +static int bnxt_re_setup_sginfo (struct bnxt_re_dev *rdev, +struct ib_umem *umem, +struct bnxt_qplib_sg_info *sginfo) +{ +unsigned long page_size; + +if (!umem) +return -EINVAL ; + + page_size =ib_umem_find_best_pgsz (umem,SZ_4K ,0 ); +if (!page_size || page_size !=SZ_4K ) +return -EINVAL ; + + sginfo->umem = umem; + sginfo->npages =ib_umem_num_dma_blocks (umem, page_size); + sginfo->pgsize = page_size; + sginfo->pgshft =__builtin_ctz (page_size); +return 0 ; +} + +static int bnxt_re_get_psn_bytes (struct bnxt_re_dev *rdev, +struct bnxt_re_ucontext *cntx, +struct bnxt_qplib_qp *qplib_qp, +struct bnxt_re_qp_req *ureq) +{ +int psn_sz, psn_nume; + + psn_sz =bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ? +sizeof (struct sq_psn_search_ext ) : +sizeof (struct sq_psn_search ); +if (cntx &&bnxt_re_is_var_size_supported (rdev, cntx)) { + psn_nume = ureq->sq_slots; + }else { + psn_nume = (qplib_qp->wqe_mode ==BNXT_QPLIB_WQE_MODE_STATIC ) ? + qplib_qp->sq.max_wqe : ((qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) / +sizeof (struct bnxt_qplib_sge )); + } +if (_is_host_msn_table (rdev->qplib_res.dattr->dev_cap_flags2)) + psn_nume =roundup_pow_of_two (psn_nume); + +return psn_nume * psn_sz; +} +static int bnxt_re_init_user_qp (struct bnxt_re_dev *rdev,struct bnxt_re_pd *pd,struct bnxt_re_qp *qp,struct bnxt_re_ucontext *cntx,struct bnxt_re_qp_req *ureq) {struct bnxt_qplib_qp *qplib_qp; -int bytes =0 , psn_sz;struct ib_umem *umem; -int psn_nume; +int bytes; +int rc; qplib_qp = &qp->qplib_qp; bytes = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size);/* Consider mapping PSN search memory only for RC QPs. */ -if (qplib_qp->type ==CMDQ_CREATE_QP_TYPE_RC ) { - psn_sz =bnxt_qplib_is_chip_gen_p5_p7 (rdev->chip_ctx) ? -sizeof (struct sq_psn_search_ext ) : -sizeof (struct sq_psn_search ); -if (cntx &&bnxt_re_is_var_size_supported (rdev, cntx)) { - psn_nume = ureq->sq_slots; - }else { - psn_nume = (qplib_qp->wqe_mode ==BNXT_QPLIB_WQE_MODE_STATIC ) ? - qplib_qp->sq.max_wqe : ((qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) / -sizeof (struct bnxt_qplib_sge )); - } -if (_is_host_msn_table (rdev->qplib_res.dattr->dev_cap_flags2)) - psn_nume =roundup_pow_of_two (psn_nume); - bytes += (psn_nume * psn_sz); - } +if (qplib_qp->type ==CMDQ_CREATE_QP_TYPE_RC ) + bytes +=bnxt_re_get_psn_bytes (rdev, cntx, qplib_qp, ureq); bytes =PAGE_ALIGN (bytes); umem = ib_umem_get(&rdev->ibdev, ureq->qpsva, bytes,
@@ -1172,33 +1202,42 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,return PTR_ERR (umem); qp->sumem = umem; - qplib_qp->sq.sg_info.umem = umem; - qplib_qp->sq.sg_info.pgsize =PAGE_SIZE ; - qplib_qp->sq.sg_info.pgshft =PAGE_SHIFT ; - qplib_qp->qp_handle = ureq->qp_handle; + rc =bnxt_re_setup_sginfo (rdev, qp->sumem, &qplib_qp->sq.sg_info); +if (rc) + goto fail; + +if (qp->qplib_qp.srq) + goto done; -if (!qp->qplib_qp.srq) { - bytes = (qplib_qp->rq.max_wqe * qplib_qp->rq.wqe_size); - bytes =PAGE_ALIGN (bytes); - umem =ib_umem_get (&rdev->ibdev, ureq->qprva, bytes, -IB_ACCESS_LOCAL_WRITE ); -if (IS_ERR (umem)) - goto rqfail; - qp->rumem = umem; - qplib_qp->rq.sg_info.umem = umem; - qplib_qp->rq.sg_info.pgsize =PAGE_SIZE ; - qplib_qp->rq.sg_info.pgshft =PAGE_SHIFT ; + bytes = (qplib_qp->rq.max_wqe * qplib_qp->rq.wqe_size); + bytes =PAGE_ALIGN (bytes); + umem =ib_umem_get (&rdev->ibdev, ureq->qprva, bytes, +IB_ACCESS_LOCAL_WRITE ); +if (IS_ERR (umem)) { + rc =PTR_ERR (umem); + goto fail; } + qp->rumem = umem; + rc =bnxt_re_setup_sginfo (rdev, qp->rumem, &qplib_qp->rq.sg_info); +if (rc) + goto rqfail; + +done: + qplib_qp->qp_handle = ureq->qp_handle; qplib_qp->dpi = &cntx->dpi; qplib_qp->is_user = true;return 0 ; + rqfail: +ib_umem_release (qp->rumem); + qp->rumem =NULL ; +memset (&qplib_qp->rq.sg_info,0 ,sizeof (qplib_qp->rq.sg_info)); +fail:ib_umem_release (qp->sumem); qp->sumem =NULL ;memset (&qplib_qp->sq.sg_info,0 ,sizeof (qplib_qp->sq.sg_info)); - -return PTR_ERR (umem); +return rc; }static struct bnxt_re_ah *bnxt_re_create_shadow_qp_ah
@@ -3345,26 +3384,6 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)return ib_respond_empty_udata (udata); } -static int bnxt_re_setup_sginfo (struct bnxt_re_dev *rdev, -struct ib_umem *umem, -struct bnxt_qplib_sg_info *sginfo) -{ -unsigned long page_size; - -if (!umem) -return -EINVAL ; - - page_size =ib_umem_find_best_pgsz (umem,SZ_4K ,0 ); -if (!page_size || page_size !=SZ_4K ) -return -EINVAL ; - - sginfo->umem = umem; - sginfo->npages =ib_umem_num_dma_blocks (umem, page_size); - sginfo->pgsize = page_size; - sginfo->pgshft =__builtin_ctz (page_size); -return 0 ; -} -int bnxt_re_create_user_cq (struct ib_cq *ibcq,const struct ib_cq_init_attr *attr,struct uverbs_attr_bundle *attrs) {
Signature · 1 line
2.53.0