6.13.2-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 430/623 of: property: Avoiding using uninitialized variable @imaplen in parse_interrupt_map()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit f73780e772c06901e99b2ad114b7f0f3fbe73ad4 ]
parse_interrupt_map() will use uninitialized variable @imaplen if fails to get property 'interrupt-map'.
Fix by using the variable after successfully getting the property.
--- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/property.c +1 -1
@@ -1390,9 +1390,9 @@ static struct device_node *parse_interrupt_map(struct device_node *np, addrcells =of_bus_n_addr_cells (np); imap =of_get_property (np,"interrupt-map" , &imaplen); - imaplen /=sizeof (*imap);if (!imap)return NULL ; + imaplen /=sizeof (*imap); imap_end = imap + imaplen;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 431/623 of: reserved-memory: Do not make kmemleak ignore freed address
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 29091a52562bca4d6e678dd8f0085dac119d6a21 ]
early_init_dt_alloc_reserved_memory_arch() will free address @base when suffers memblock_mark_nomap() error, but it still makes kmemleak ignore the freed address @base via kmemleak_ignore_phys().
That is unnecessary, besides, also causes unnecessary warning messages:
kmemleak_ignore_phys()
-> make_black_object()
-> paint_ptr()
-> kmemleak_warn() // warning message here.Fix by avoiding kmemleak_ignore_phys() when suffer the error.
--- drivers/of/of_reserved_mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/of_reserved_mem.c +2 -1
@@ -52,7 +52,8 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,memblock_phys_free (base, size); } -kmemleak_ignore_phys (base); +if (!err) +kmemleak_ignore_phys (base);return err; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 432/623 efi: sysfb_efi: fix W=1 warnings when EFI is not set
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 19fdc68aa7b90b1d3d600e873a3e050a39e7663d ]
A build with W=1 fails because there are code and data that are not needed or used when CONFIG_EFI is not set. Move the "#ifdef CONFIG_EFI" block to earlier in the source file so that the unused code/data are not built.
drivers/firmware/efi/sysfb_efi.c:345:39: warning: ‘efifb_fwnode_ops’ defined but not used [-Wunused-const-variable=]
345 | static const struct fwnode_operations efifb_fwnode_ops = {
| ^~~~~~~~~~~~~~~~
drivers/firmware/efi/sysfb_efi.c:238:35: warning: ‘efifb_dmi_swap_width_height’ defined but not used [-Wunused-const-variable=]
238 | static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/efi/sysfb_efi.c:188:35: warning: ‘efifb_dmi_system_table’ defined but not used [-Wunused-const-variable=]
188 | static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
| ^~~~~~~~~~~~~~~~~~~~~~--- drivers/firmware/efi/sysfb_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/sysfb_efi.c +1 -1
@@ -91,6 +91,7 @@ void efifb_setup_from_dmi(struct screen_info *si, const char *opt) _ret_; \ }) +#ifdef CONFIG_EFI static int __init efifb_set_system (const struct dmi_system_id *id) {struct efifb_dmi_info *info = id->driver_data;
@@ -346,7 +347,6 @@ static const struct fwnode_operations efifb_fwnode_ops = { .add_links = efifb_add_links, }; -#ifdef CONFIG_EFI static struct fwnode_handle efifb_fwnode;__init void sysfb_apply_efi_quirks (void )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 433/623 RDMA/cxgb4: Notify rdma stack for IB_EVENT_QP_LAST_WQE_REACHED event
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anumula Murali Mohan Reddy <[email protected]>
[ Upstream commit 42e6ddda4c17fa0d5120e3723d522649f8fc62fa ]
This patch sends IB_EVENT_QP_LAST_WQE_REACHED event on a QP that is in error state and associated with an SRQ. This behaviour is incorporated in flush_qp() which is called when QP transitions to error state. Supports SRQ drain functionality added by commit 844bc12e6da3 ("IB/core:
add support for draining Shared receive queues")
--- drivers/infiniband/hw/cxgb4/qp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/infiniband/hw/cxgb4/qp.c +8 -0
@@ -1599,6 +1599,7 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,int count;int rq_flushed =0 , sq_flushed;unsigned long flag; +struct ib_event ev;pr_debug ("qhp %p rchp %p schp %p\n" , qhp, rchp, schp);
@@ -1607,6 +1608,13 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,if (schp != rchp)spin_lock (&schp->lock);spin_lock (&qhp->lock); +if (qhp->srq && qhp->attr.state ==C4IW_QP_STATE_ERROR && + qhp->ibqp.event_handler) { + ev.device = qhp->ibqp.device; + ev.element.qp = &qhp->ibqp; + ev.event =IB_EVENT_QP_LAST_WQE_REACHED ; + qhp->ibqp.event_handler (&ev, qhp->ibqp.qp_context); + }if (qhp->wq.flushed) {spin_unlock (&qhp->lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 434/623 RDMA/rxe: Fix the warning "__rxe_cleanup+0x12c/0x170 [rdma_rxe]"
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <[email protected]>
[ Upstream commit edc4ef0e0154096d6c0cf5e06af6fc330dbad9d1 ]
The Call Trace is as below:
"
<TASK> ? show_regs.cold+0x1a/0x1f ? __rxe_cleanup+0x12c/0x170 [rdma_rxe] ? __warn+0x84/0xd0 ? __rxe_cleanup+0x12c/0x170 [rdma_rxe] ? report_bug+0x105/0x180 ? handle_bug+0x46/0x80 ? exc_invalid_op+0x19/0x70 ? asm_exc_invalid_op+0x1b/0x20 ? __rxe_cleanup+0x12c/0x170 [rdma_rxe] ? __rxe_cleanup+0x124/0x170 [rdma_rxe] rxe_destroy_qp.cold+0x24/0x29 [rdma_rxe] ib_destroy_qp_user+0x118/0x190 [ib_core] rdma_destroy_qp.cold+0x43/0x5e [rdma_cm] rtrs_cq_qp_destroy.cold+0x1d/0x2b [rtrs_core] rtrs_srv_close_work.cold+0x1b/0x31 [rtrs_server] process_one_work+0x21d/0x3f0 worker_thread+0x4a/0x3c0 ? process_one_work+0x3f0/0x3f0 kthread+0xf0/0x120 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 </TASK>
"
When too many rdma resources are allocated, rxe needs more time to handle these rdma resources. Sometimes with the current timeout, rxe can not release the rdma resources correctly.
Compared with other rdma drivers, a bigger timeout is used.
--- drivers/infiniband/sw/rxe/rxe_pool.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_pool.c +5 -6
@@ -178,7 +178,6 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable) {struct rxe_pool *pool = elem->pool;struct xarray *xa = &pool->xa; -static int timeout =RXE_POOL_TIMEOUT ;int ret, err =0 ;void *xa_ret;
@@ -202,19 +201,19 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)* return to rdma-core */ if (sleepable) { -if (!completion_done (&elem->complete) && timeout) { +if (!completion_done (&elem->complete)) { ret =wait_for_completion_timeout (&elem->complete, - timeout); +msecs_to_jiffies (50000 ));/* Shouldn't happen. There are still references to * the object but, rather than deadlock, free the * object or pass back to rdma-core. */ if (WARN_ON (!ret)) - err = -EINVAL ; + err = -ETIMEDOUT ; } }else { -unsigned long until = jiffies + timeout; +unsigned long until = jiffies +RXE_POOL_TIMEOUT ;/* AH objects are unique in that the destroy_ah verb * can be called in atomic context. This delay
@@ -226,7 +225,7 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)mdelay (1 );if (WARN_ON (!completion_done (&elem->complete))) - err = -EINVAL ; + err = -ETIMEDOUT ; }if (pool->cleanup)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 435/623 iommu: iommufd: fix WARNING in iommufd_device_unbind
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suraj Sonawane <[email protected]>
[ Upstream commit d9df72c6acd683adf6dd23c061f3a414ec00b1f8 ]
Fix an issue detected by syzbot:
WARNING in iommufd_device_unbind iommufd: Time out waiting for iommufd object to become free
Resolve a warning in iommufd_device_unbind caused by a timeout while waiting for the shortterm_users reference count to reach zero. The existing 10-second timeout is insufficient in some scenarios, resulting in failures the above warning.
Increase the timeout in iommufd_object_dec_wait_shortterm from 10 seconds to 60 seconds to allow sufficient time for the reference count to drop to zero. This change prevents premature timeouts and reduces the likelihood of warnings during iommufd_device_unbind.
--- drivers/iommu/iommufd/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommufd/main.c +1 -1
@@ -104,7 +104,7 @@ static int iommufd_object_dec_wait_shortterm(struct iommufd_ctx *ictx,if (wait_event_timeout (ictx->destroy_wait,refcount_read (&to_destroy->shortterm_users) ==0 , -msecs_to_jiffies (10000 ))) +msecs_to_jiffies (60000 )))return 0 ;pr_crit ("Time out waiting for iommufd object to become free\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 436/623 iommufd/iova_bitmap: Fix shift-out-of-bounds in iova_bitmap_offset_to_index()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qasim Ijaz <[email protected]>
[ Upstream commit e24c1551059268b37f6f40639883eafb281b8b9c ]
Resolve a UBSAN shift-out-of-bounds issue in iova_bitmap_offset_to_index() where shifting the constant "1" (of type int) by bitmap->mapped.pgshift (an unsigned long value) could result in undefined behavior.
The constant "1" defaults to a 32-bit "int", and when "pgshift" exceeds 31 (e.g., pgshift = 63) the shift operation overflows, as the result cannot be represented in a 32-bit type.
To resolve this, the constant is updated to "1UL", promoting it to an unsigned long type to match the operand's type.
--- drivers/iommu/iommufd/iova_bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommufd/iova_bitmap.c +1 -1
@@ -130,7 +130,7 @@ struct iova_bitmap {static unsigned long iova_bitmap_offset_to_index (struct iova_bitmap *bitmap,unsigned long iova) { -unsigned long pgsize =1 << bitmap->mapped.pgshift; +unsigned long pgsize =1UL << bitmap->mapped.pgshift;return iova / (BITS_PER_TYPE (*bitmap->bitmap) * pgsize); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 437/623 mailbox: th1520: Fix a NULL vs IS_ERR() bug
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit d0f98e14c010bcf27898b635a54c1994ac4110a8 ]
The devm_ioremap() function doesn't return error pointers, it returns NULL. Update the error checking to match.
--- drivers/mailbox/mailbox-th1520.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mailbox/mailbox-th1520.c +3 -1
@@ -387,8 +387,10 @@ static void __iomem *th1520_map_mmio(struct platform_device *pdev, mapped =devm_ioremap (&pdev->dev, res->start + offset,resource_size (res) - offset); -if (IS_ERR (mapped)) +if (!mapped) {dev_err (&pdev->dev,"Failed to map resource: %s\n" , res_name); +return ERR_PTR (-ENOMEM ); + }return mapped; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 438/623 mailbox: mpfs: fix copy and paste bug in probe
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f055feb49c1c4333abb80ce1e9d93841cf74ea84 ]
This code accidentally checks ->ctrl_base instead of ->mbox_base so the error handling can never be triggered.
--- drivers/mailbox/mailbox-mpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mailbox-mpfs.c +1 -1
@@ -251,7 +251,7 @@ static inline int mpfs_mbox_syscon_probe(struct mpfs_mbox *mbox, struct platformreturn PTR_ERR (mbox->sysreg_scb); mbox->mbox_base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (mbox->ctrl_base)) +if (IS_ERR (mbox->mbox_base))return PTR_ERR (mbox->mbox_base);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 439/623 mailbox: th1520: Fix memory corruption due to incorrect array size
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Wilczynski <[email protected]>
[ Upstream commit db049866943a38bf46a34fa120d526663339d7a5 ]
The functions th1520_mbox_suspend_noirq and th1520_mbox_resume_noirq are intended to save and restore the interrupt mask registers in the MBOX ICU0. However, the array used to store these registers was incorrectly sized, leading to memory corruption when accessing all four registers.
This commit corrects the array size to accommodate all four interrupt mask registers, preventing memory corruption during suspend and resume operations.
--- drivers/mailbox/mailbox-th1520.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mailbox-th1520.c +1 -1
@@ -41,7 +41,7 @@#ifdef CONFIG_PM_SLEEP /* store MBOX context across system-wide suspend/resume transitions */ struct th1520_mbox_context { -u32 intr_mask[TH_1520_MBOX_CHANS -1 ]; +u32 intr_mask[TH_1520_MBOX_CHANS ]; };#endif
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 440/623 spi: omap2-mcspi: Correctly handle devm_clk_get_optional() errors
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit a07eb4f67ed085f32002a1af2b6073546d67de3f ]
devm_clk_get_optional() returns NULL for missing clocks and a PTR_ERR() if there is a clock but we fail to get it, but currently we only handle the latter case and do so as though the clock was missing. If we get an error back we should handle that as an error since the clock exists but we failed to get it, if we get NULL then the clock doesn't exist and we should handle that.
--- drivers/spi/spi-omap2-mcspi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/spi/spi-omap2-mcspi.c +8 -3
@@ -1561,10 +1561,15 @@ static int omap2_mcspi_probe(struct platform_device *pdev) } mcspi->ref_clk =devm_clk_get_optional_enabled (&pdev->dev,NULL ); -if (IS_ERR (mcspi->ref_clk)) - mcspi->ref_clk_hz =OMAP2_MCSPI_MAX_FREQ ; -else +if (IS_ERR (mcspi->ref_clk)) { + status =PTR_ERR (mcspi->ref_clk); +dev_err_probe (&pdev->dev, status,"Failed to get ref_clk" ); + goto free_ctlr; + } +if (mcspi->ref_clk) mcspi->ref_clk_hz =clk_get_rate (mcspi->ref_clk); +else + mcspi->ref_clk_hz =OMAP2_MCSPI_MAX_FREQ ; ctlr->max_speed_hz = mcspi->ref_clk_hz; ctlr->min_speed_hz = mcspi->ref_clk_hz >>15 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 441/623 of/fdt: Restore possibility to use both ACPI and FDT from bootloader
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmytro Maluka <[email protected]>
[ Upstream commit 14bce187d1600710623d81888da3501bbc470ba2 ]
There are cases when the bootloader provides information to the kernel in both ACPI and DTB, not interchangeably. One such use case is virtual machines in Android. When running on x86, the Android Virtualization Framework (AVF) boots VMs with ACPI like it is usually done on x86 (i.e. the virtual LAPIC, IOAPIC, HPET, PCI MMCONFIG etc are described in ACPI) but also passes various AVF-specific boot parameters in DTB. This allows reusing the same implementations of various AVF components on both arm64 and x86.
Commit 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware") removed the possibility to do that, since among other things it introduced forcing emptying the bootloader-provided DTB if ACPI is enabled (probably assuming that if ACPI is available, a DTB can only be useful for applying overlays to it afterwards, for testing purposes).
So restore this possibility. Instead of completely preventing using ACPI and DT together, rely on arch-specific setup code to prevent using both to set up the same things (see various acpi_disabled checks under arch/).
--- drivers/of/fdt.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/of/fdt.c +1 -9
@@ -8,7 +8,6 @@#define pr_fmt (fmt) "OF: fdt: " fmt -#include <linux/acpi.h> #include <linux/crash_dump.h> #include <linux/crc32.h> #include <linux/kernel.h>
@@ -1215,14 +1214,7 @@ void __init unflatten_device_tree(void)/* Save the statically-placed regions in the reserved_mem array */ fdt_scan_reserved_mem_reg_nodes (); -/* Don't use the bootloader provided DTB if ACPI is enabled */ -if (!acpi_disabled) - fdt =NULL ; - -/* -* Populate an empty root node when ACPI is enabled or bootloader -* doesn't provide one. -*/ +/* Populate an empty root node when bootloader doesn't provide one */ if (!fdt) { fdt = (void *) __dtb_empty_root_begin;/* fdt_totalsize() will be used for copy size */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 442/623 media: rc: iguanair: handle timeouts
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit b98d5000c50544f14bacb248c34e5219fbe81287 ]
In case of a timeout the IO must be cancelled or the next IO using the URB will fail and/or overwrite an operational URB.
The automatic bisection fails because it arrives
at a commit that correctly lets the test case run
without an error.
--- drivers/media/rc/iguanair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/rc/iguanair.c +3 -1
@@ -194,8 +194,10 @@ static int iguanair_send(struct iguanair *ir, unsigned size)if (rc)return rc; -if (wait_for_completion_timeout (&ir->completion,TIMEOUT ) ==0 ) +if (wait_for_completion_timeout (&ir->completion,TIMEOUT ) ==0 ) { +usb_kill_urb (ir->urb_out);return -ETIMEDOUT ; + }return rc; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 443/623 media: lmedm04: Handle errors for lme2510_int_read
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit a2836d3fe220220ff8c495ca9722f89cea8a67e7 ]
Add check for the return value of usb_pipe_endpoint() and usb_submit_urb() in order to catch the errors.
--- drivers/media/usb/dvb-usb-v2/lmedm04.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/lmedm04.c +11 -1
@@ -373,6 +373,7 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)struct dvb_usb_device *d =adap_to_d (adap);struct lme2510_state *lme_int =adap_to_priv (adap);struct usb_host_endpoint *ep; +int ret; lme_int->lme_urb =usb_alloc_urb (0 ,GFP_KERNEL );
@@ -390,11 +391,20 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)/* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */ ep =usb_pipe_endpoint (d->udev, lme_int->lme_urb->pipe); +if (!ep) { +usb_free_urb (lme_int->lme_urb); +return -ENODEV ; + }if (usb_endpoint_type (&ep->desc) ==USB_ENDPOINT_XFER_BULK ) lme_int->lme_urb->pipe =usb_rcvbulkpipe (d->udev,0xa ); -usb_submit_urb (lme_int->lme_urb,GFP_KERNEL ); + ret =usb_submit_urb (lme_int->lme_urb,GFP_KERNEL ); +if (ret) { +usb_free_urb (lme_int->lme_urb); +return ret; + } +info ("INT Interrupt Service Started" );return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 444/623 PCI: endpoint: Destroy the EPC device in devm_pci_epc_destroy()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d4929755e4d02bd3de3ae5569dab69cb9502c54f ]
The devm_pci_epc_destroy() comment says destroys the EPC device, but it does not actually do that since devres_destroy() does not call devm_pci_epc_release(), and it also can not fully undo what the API devm_pci_epc_create() does, so it is faulty.
Fortunately, the faulty API has not been used by current kernel tree. Use devres_release() instead of devres_destroy() so the EPC device will be released.
--- drivers/pci/endpoint/pci-epc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/pci-epc-core.c +1 -1
@@ -942,7 +942,7 @@ void devm_pci_epc_destroy(struct device *dev, struct pci_epc *epc) {int r; - r =devres_destroy (dev, devm_pci_epc_release, devm_pci_epc_match, + r =devres_release (dev, devm_pci_epc_release, devm_pci_epc_match, epc);dev_WARN_ONCE (dev, r,"couldn't find PCI EPC resource\n" ); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 445/623 PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Hong Pan <[email protected]>
[ Upstream commit 1db806ec06b7c6e08e8af57088da067963ddf117 ]
After 17423360a27a ("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"), pci_save_aspm_l1ss_state(dev) saves the L1SS state for "dev", and pci_restore_aspm_l1ss_state(dev) restores the state for both "dev" and its parent.
The problem is that unless pci_save_state() has been used in some other path and has already saved the parent L1SS state, we will restore junk to the parent, which means the L1 Substates likely won't work correctly.
Save the L1SS config for both the device and its parent in pci_save_aspm_l1ss_state(). When restoring, we need both because L1SS must be enabled at the parent (the Downstream Port) before being enabled at the child (the Upstream Port).
[bhelgaas: parallel save/restore structure, simplify commit log, patch at
https://lore.kernel.org/r/20241212230340.GA3267194@bhelgaas]
--- drivers/pci/pcie/aspm.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
drivers/pci/pcie/aspm.c +28 -5
@@ -81,24 +81,47 @@ void pci_configure_aspm_l1ss(struct pci_dev *pdev)void pci_save_aspm_l1ss_state (struct pci_dev *pdev) { +struct pci_dev *parent = pdev->bus->self;struct pci_cap_saved_state *save_state; -u16 l1ss = pdev->l1ss;u32 *cap; +/* +* If this is a Downstream Port, we never restore the L1SS state +* directly; we only restore it when we restore the state of the +* Upstream Port below it. +*/ +if (pcie_downstream_port (pdev) || !parent) +return ; + +if (!pdev->l1ss || !parent->l1ss) +return ; +/* * Save L1 substate configuration. The ASPM L0s/L1 configuration * in PCI_EXP_LNKCTL_ASPMC is saved by pci_save_pcie_state(). */ -if (!l1ss) + save_state =pci_find_saved_ext_cap (pdev,PCI_EXT_CAP_ID_L1SS ); +if (!save_state)return ; - save_state =pci_find_saved_ext_cap (pdev,PCI_EXT_CAP_ID_L1SS ); + cap = &save_state->cap.data[0 ]; +pci_read_config_dword (pdev, pdev->l1ss +PCI_L1SS_CTL2 , cap++); +pci_read_config_dword (pdev, pdev->l1ss +PCI_L1SS_CTL1 , cap++); + +if (parent->state_saved) +return ; + +/* +* Save parent's L1 substate configuration so we have it for +* pci_restore_aspm_l1ss_state(pdev) to restore. +*/ + save_state =pci_find_saved_ext_cap (parent,PCI_EXT_CAP_ID_L1SS );if (!save_state)return ; cap = &save_state->cap.data[0 ]; -pci_read_config_dword (pdev, l1ss +PCI_L1SS_CTL2 , cap++); -pci_read_config_dword (pdev, l1ss +PCI_L1SS_CTL1 , cap++); +pci_read_config_dword (parent, parent->l1ss +PCI_L1SS_CTL2 , cap++); +pci_read_config_dword (parent, parent->l1ss +PCI_L1SS_CTL1 , cap++); }void pci_restore_aspm_l1ss_state (struct pci_dev *pdev)
Signature · 1 line
2.39.5
Re: [PATCH 6.13 445/623] PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
Quoted 27 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Hong Pan <[email protected]>
[ Upstream commit
1db806ec06b7c6e08e8af57088da067963ddf117]After
17423360a27a("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"),pci_save_aspm_l1ss_state(dev)saves the L1SS state for "dev", andpci_restore_aspm_l1ss_state(dev)restores the state for both "dev" and its parent.The problem is that unless
pci_save_state()has been used in some other path and has already saved the parent L1SS state, we will restore junk to the parent, which means the L1 Substates likely won't work correctly.Save the L1SS config for both the device and its parent in
pci_save_aspm_l1ss_state(). When restoring, we need both because L1SS must be enabled at the parent (the Downstream Port) before being enabled at the child (the Upstream Port).Fixes 17423360a27a ("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume")Suggested-by Ilpo Järvinen <[email protected]>Signed-off-by Jian-Hong Pan <[email protected]>
Quoted 5 lines
[bhelgaas: parallel save/restore structure, simplify commit log, patch at
https://lore.kernel.org/r/20241212230340.GA3267194@bhelgaas]Signed-off-by Bjorn Helgaas <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Hi stable maintainers,
Please withhold this commit from stable until its fix ("PCI/ASPM: Fix L1SS saving") can be pushed at the same as having this commit alone can causes PCIe devices to becomes unavailable and hang the system during PM transitions.
The fix is currently in pci/for-linus as the commit c312f005dedc, but Bjorn might add more reported-by/tested-by tags if more people hit it before the commit makes into Linus' tree so don't expect that commit id to be stable just yet.
Signature · 1 line
i.
Quoted 62 lines
--- drivers/pci/pcie/aspm.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)drivers/pci/pcie/aspm.c +28
-5@@ -81,24 +81,47 @@ void pci_configure_aspm_l1ss(struct pci_dev *pdev)void pci_save_aspm_l1ss_state (struct pci_dev *pdev) { +struct pci_dev *parent = pdev->bus->self;struct pci_cap_saved_state *save_state; -u16 l1ss = pdev->l1ss;u32 *cap; +/* +* If this is a Downstream Port, we never restore the L1SS state +* directly; we only restore it when we restore the state of the +* Upstream Port below it. +*/ +if (pcie_downstream_port (pdev) || !parent) +return ; + +if (!pdev->l1ss || !parent->l1ss) +return ; +/* * Save L1 substate configuration. The ASPM L0s/L1 configuration * in PCI_EXP_LNKCTL_ASPMC is saved by pci_save_pcie_state(). */ -if (!l1ss) + save_state =pci_find_saved_ext_cap (pdev,PCI_EXT_CAP_ID_L1SS ); +if (!save_state)return ; - save_state =pci_find_saved_ext_cap (pdev,PCI_EXT_CAP_ID_L1SS ); + cap = &save_state->cap.data[0 ]; +pci_read_config_dword (pdev, pdev->l1ss +PCI_L1SS_CTL2 , cap++); +pci_read_config_dword (pdev, pdev->l1ss +PCI_L1SS_CTL1 , cap++); + +if (parent->state_saved) +return ; + +/* +* Save parent's L1 substate configuration so we have it for +* pci_restore_aspm_l1ss_state(pdev) to restore. +*/ + save_state =pci_find_saved_ext_cap (parent,PCI_EXT_CAP_ID_L1SS );if (!save_state)return ; cap = &save_state->cap.data[0 ]; -pci_read_config_dword (pdev, l1ss +PCI_L1SS_CTL2 , cap++); -pci_read_config_dword (pdev, l1ss +PCI_L1SS_CTL1 , cap++); +pci_read_config_dword (parent, parent->l1ss +PCI_L1SS_CTL2 , cap++); +pci_read_config_dword (parent, parent->l1ss +PCI_L1SS_CTL1 , cap++); }void pci_restore_aspm_l1ss_state (struct pci_dev *pdev)
Greg Kroah-Hartman
maintainerRe: [PATCH 6.13 445/623] PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
Quoted 42 lines · Ilpo Järvinen
Quoted 27 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Hong Pan <[email protected]>
[ Upstream commit
1db806ec06b7c6e08e8af57088da067963ddf117]After
17423360a27a("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"),pci_save_aspm_l1ss_state(dev)saves the L1SS state for "dev", andpci_restore_aspm_l1ss_state(dev)restores the state for both "dev" and its parent.The problem is that unless
pci_save_state()has been used in some other path and has already saved the parent L1SS state, we will restore junk to the parent, which means the L1 Substates likely won't work correctly.Save the L1SS config for both the device and its parent in
pci_save_aspm_l1ss_state(). When restoring, we need both because L1SS must be enabled at the parent (the Downstream Port) before being enabled at the child (the Upstream Port).Fixes 17423360a27a ("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume")Suggested-by Ilpo Järvinen <[email protected]>Signed-off-by Jian-Hong Pan <[email protected]>Quoted 5 lines
[bhelgaas: parallel save/restore structure, simplify commit log, patch at
https://lore.kernel.org/r/20241212230340.GA3267194@bhelgaas]Signed-off-by Bjorn Helgaas <[email protected]>Signed-off-by Sasha Levin <[email protected]>Hi stable maintainers,
Please withhold this commit from stable until its fix ("PCI/ASPM: Fix L1SS saving") can be pushed at the same as having this commit alone can causes PCIe devices to becomes unavailable and hang the system during PM transitions.
Quoted 4 lines
The fix is currently in pci/for-linus as the commit
c312f005dedc, but Bjorn might add more reported-by/tested-by tags if more people hit it before the commit makes into Linus' tree so don't expect that commit id to be stable just yet.
Ok, now dropped from all stable queues, thanks for letting us know.
greg k-h
Re: [PATCH 6.13 445/623] PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
Hello,
Quoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Ilpo Järvinen
Quoted 12 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Hong Pan <[email protected]>
[ Upstream commit
1db806ec06b7c6e08e8af57088da067963ddf117]After
17423360a27a("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"),pci_save_aspm_l1ss_state(dev)saves the L1SS state for "dev", andpci_restore_aspm_l1ss_state(dev)restores the state for both "dev" and its parent.
[...]
Quoted 11 lines
Quoted 9 lines
Please withhold this commit from stable until its fix ("PCI/ASPM: Fix L1SS saving") can be pushed at the same as having this commit alone can causes PCIe devices to becomes unavailable and hang the system during PM transitions.
The fix is currently in pci/for-linus as the commit
c312f005dedc, but Bjorn might add more reported-by/tested-by tags if more people hit it before the commit makes into Linus' tree so don't expect that commit id to be stable just yet.Ok, now dropped from all stable queues, thanks for letting us know.
Any chance these can be re-included? That's:
1db806ec06b7 ("PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()") 7507eb3e7bfa ("PCI/ASPM: Fix L1SS saving")
We've independently backported them into kernels we're using, but it seems wise to get 6.12.y, etc., back up to date.
Brian
Greg Kroah-Hartman
maintainerRe: [PATCH 6.13 445/623] PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
Quoted 31 lines · Brian Norris
Hello,
Quoted 15 lines · Greg Kroah-Hartman
Quoted 14 lines · Ilpo Järvinen
Quoted 12 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian-Hong Pan <[email protected]>
[ Upstream commit
1db806ec06b7c6e08e8af57088da067963ddf117]After
17423360a27a("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"),pci_save_aspm_l1ss_state(dev)saves the L1SS state for "dev", andpci_restore_aspm_l1ss_state(dev)restores the state for both "dev" and its parent.[...]
Quoted 11 lines
Quoted 9 lines
Please withhold this commit from stable until its fix ("PCI/ASPM: Fix L1SS saving") can be pushed at the same as having this commit alone can causes PCIe devices to becomes unavailable and hang the system during PM transitions.
The fix is currently in pci/for-linus as the commit
c312f005dedc, but Bjorn might add more reported-by/tested-by tags if more people hit it before the commit makes into Linus' tree so don't expect that commit id to be stable just yet.Ok, now dropped from all stable queues, thanks for letting us know.
Quoted 7 lines
Any chance these can be re-included? That's:
1db806ec06b7("PCI/ASPM: Save parent L1SS config inpci_save_aspm_l1ss_state()")7507eb3e7bfa("PCI/ASPM: Fix L1SS saving")We've independently backported them into kernels we're using, but it seems wise to get 6.12.y, etc., back up to date.
Now queued up, thanks.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 446/623 remoteproc: mtk_scp: Only populate devices for SCP cores
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit dbb9c372555c0b2a5a9264418bfba6d017752808 ]
When multi-core SCP support was added, the driver was made to populate platform devices for all the sub-nodes. This ended up adding platform devices for the rpmsg sub-nodes as well, which never actually get used, since rpmsg devices are registered through the rpmsg interface.
Limit of_platform_populate() to just populating the SCP cores with a compatible string match list.
--- drivers/remoteproc/mtk_scp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/remoteproc/mtk_scp.c +10 -2
@@ -1326,6 +1326,11 @@ static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_clusreturn ret; } +static const struct of_device_id scp_core_match[] = { + { .compatible ="mediatek,scp-core" }, + {} +}; +static int scp_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1357,13 +1362,15 @@ static int scp_probe(struct platform_device *pdev)INIT_LIST_HEAD (&scp_cluster->mtk_scp_list);mutex_init (&scp_cluster->cluster_lock); - ret =devm_of_platform_populate (dev); + ret =of_platform_populate (dev_of_node (dev), scp_core_match,NULL , dev);if (ret)return dev_err_probe (dev, ret,"Failed to populate platform devices\n" ); ret =scp_cluster_init (pdev, scp_cluster); -if (ret) +if (ret) { +of_platform_depopulate (dev);return ret; + }return 0 ; }
@@ -1379,6 +1386,7 @@ static void scp_remove(struct platform_device *pdev)rproc_del (scp->rproc);scp_free (scp); } +of_platform_depopulate (&pdev->dev);mutex_destroy (&scp_cluster->cluster_lock); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 447/623 media: marvell: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 11f68d2ba2e1521a608af773bf788e8cfa260f68 ]
Add check for the return value of clk_enable() to guarantee the success.
--- drivers/media/platform/marvell/mcam-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/platform/marvell/mcam-core.c +6 -1
@@ -935,7 +935,12 @@ static int mclk_enable(struct clk_hw *hw) ret =pm_runtime_resume_and_get (cam->dev);if (ret <0 )return ret; -clk_enable (cam->clk[0 ]); + ret =clk_enable (cam->clk[0 ]); +if (ret) { +pm_runtime_put (cam->dev); +return ret; + } +mcam_reg_write (cam,REG_CLKCTRL , (mclk_src <<29 ) | mclk_div);mcam_ctlr_power_up (cam);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 448/623 media: i2c: imx290: Register 0x3011 varies between imx327 and imx290
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit f2055c1d62d6dfd25a31d1d1923883f21305aea5 ]
Reviewing the datasheets, register 0x3011 is meant to be 0x02 on imx327 and 0x00 on imx290.
Move it out of the common registers, and set it appropriately in the sensor specific sections. (Included for imx290 to be explicit, rather than relying on the default value).
--- drivers/media/i2c/imx290.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/imx290.c +2 -1
@@ -267,7 +267,6 @@ static const struct cci_reg_sequence imx290_global_init_settings[] = { { IMX290_WINWV, 1097 }, { IMX290_XSOUTSEL, IMX290_XSOUTSEL_XVSOUTSEL_VSYNC | IMX290_XSOUTSEL_XHSOUTSEL_HSYNC }, - { CCI_REG8(0x3011), 0x02 }, { CCI_REG8(0x3012), 0x64 }, { CCI_REG8(0x3013), 0x00 }, };
@@ -275,6 +274,7 @@ static const struct cci_reg_sequence imx290_global_init_settings[] = {static const struct cci_reg_sequence imx290_global_init_settings_290[] = { {CCI_REG8 (0x300f ),0x00 }, {CCI_REG8 (0x3010 ),0x21 }, + {CCI_REG8 (0x3011 ),0x00 }, {CCI_REG8 (0x3016 ),0x09 }, {CCI_REG8 (0x3070 ),0x02 }, {CCI_REG8 (0x3071 ),0x11 },
@@ -328,6 +328,7 @@ static const struct cci_reg_sequence xclk_regs[][IMX290_NUM_CLK_REGS] = { };static const struct cci_reg_sequence imx290_global_init_settings_327[] = { + {CCI_REG8 (0x3011 ),0x02 }, {CCI_REG8 (0x309e ),0x4A }, {CCI_REG8 (0x309f ),0x4A }, {CCI_REG8 (0x313b ),0x61 },
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 449/623 media: i2c: imx412: Add missing newline to prints
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 33f4a7fba7229232e294f4794503283e44cd03f2 ]
Add trailing \n to dev_dbg and dev_err prints where missing.
--- drivers/media/i2c/imx412.c | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/media/i2c/imx412.c +21 -21
@@ -547,7 +547,7 @@ static int imx412_update_exp_gain(struct imx412 *imx412, u32 exposure, u32 gain) lpfr = imx412->vblank + imx412->cur_mode->height; -dev_dbg (imx412->dev,"Set exp %u, analog gain %u, lpfr %u" , +dev_dbg (imx412->dev,"Set exp %u, analog gain %u, lpfr %u\n" , exposure, gain, lpfr); ret =imx412_write_reg (imx412,IMX412_REG_HOLD ,1 ,1 );
@@ -594,7 +594,7 @@ static int imx412_set_ctrl(struct v4l2_ctrl *ctrl)case V4L2_CID_VBLANK : imx412->vblank = imx412->vblank_ctrl->val; -dev_dbg (imx412->dev,"Received vblank %u, new lpfr %u" , +dev_dbg (imx412->dev,"Received vblank %u, new lpfr %u\n" , imx412->vblank, imx412->vblank + imx412->cur_mode->height);
@@ -613,7 +613,7 @@ static int imx412_set_ctrl(struct v4l2_ctrl *ctrl) exposure = ctrl->val; analog_gain = imx412->again_ctrl->val; -dev_dbg (imx412->dev,"Received exp %u, analog gain %u" , +dev_dbg (imx412->dev,"Received exp %u, analog gain %u\n" , exposure, analog_gain); ret =imx412_update_exp_gain (imx412, exposure, analog_gain);
@@ -622,7 +622,7 @@ static int imx412_set_ctrl(struct v4l2_ctrl *ctrl)break ;default : -dev_err (imx412->dev,"Invalid control %d" , ctrl->id); +dev_err (imx412->dev,"Invalid control %d\n" , ctrl->id); ret = -EINVAL ; }
@@ -803,14 +803,14 @@ static int imx412_start_streaming(struct imx412 *imx412) ret =imx412_write_regs (imx412, reg_list->regs, reg_list->num_of_regs);if (ret) { -dev_err (imx412->dev,"fail to write initial registers" ); +dev_err (imx412->dev,"fail to write initial registers\n" );return ret; }/* Setup handler will write actual exposure and gain */ ret =__v4l2_ctrl_handler_setup (imx412->sd.ctrl_handler);if (ret) { -dev_err (imx412->dev,"fail to setup handler" ); +dev_err (imx412->dev,"fail to setup handler\n" );return ret; }
@@ -821,7 +821,7 @@ static int imx412_start_streaming(struct imx412 *imx412) ret =imx412_write_reg (imx412,IMX412_REG_MODE_SELECT ,1 ,IMX412_MODE_STREAMING );if (ret) { -dev_err (imx412->dev,"fail to start streaming" ); +dev_err (imx412->dev,"fail to start streaming\n" );return ret; }
@@ -895,7 +895,7 @@ static int imx412_detect(struct imx412 *imx412)return ret;if (val !=IMX412_ID ) { -dev_err (imx412->dev,"chip id mismatch: %x!=%x" , +dev_err (imx412->dev,"chip id mismatch: %x!=%x\n" ,IMX412_ID , val);return -ENXIO ; }
@@ -927,7 +927,7 @@ static int imx412_parse_hw_config(struct imx412 *imx412) imx412->reset_gpio =devm_gpiod_get_optional (imx412->dev,"reset" ,GPIOD_OUT_LOW );if (IS_ERR (imx412->reset_gpio)) { -dev_err (imx412->dev,"failed to get reset gpio %ld" , +dev_err (imx412->dev,"failed to get reset gpio %ld\n" ,PTR_ERR (imx412->reset_gpio));return PTR_ERR (imx412->reset_gpio); }
@@ -935,13 +935,13 @@ static int imx412_parse_hw_config(struct imx412 *imx412)/* Get sensor input clock */ imx412->inclk =devm_clk_get (imx412->dev,NULL );if (IS_ERR (imx412->inclk)) { -dev_err (imx412->dev,"could not get inclk" ); +dev_err (imx412->dev,"could not get inclk\n" );return PTR_ERR (imx412->inclk); } rate =clk_get_rate (imx412->inclk);if (rate !=IMX412_INCLK_RATE ) { -dev_err (imx412->dev,"inclk frequency mismatch" ); +dev_err (imx412->dev,"inclk frequency mismatch\n" );return -EINVAL ; }
@@ -966,14 +966,14 @@ static int imx412_parse_hw_config(struct imx412 *imx412)if (bus_cfg.bus.mipi_csi2.num_data_lanes !=IMX412_NUM_DATA_LANES ) {dev_err (imx412->dev, -"number of CSI2 data lanes %d is not supported" , +"number of CSI2 data lanes %d is not supported\n" , bus_cfg.bus.mipi_csi2.num_data_lanes); ret = -EINVAL ; goto done_endpoint_free; }if (!bus_cfg.nr_of_link_frequencies) { -dev_err (imx412->dev,"no link frequencies defined" ); +dev_err (imx412->dev,"no link frequencies defined\n" ); ret = -EINVAL ; goto done_endpoint_free; }
@@ -1034,7 +1034,7 @@ static int imx412_power_on(struct device *dev) ret =clk_prepare_enable (imx412->inclk);if (ret) { -dev_err (imx412->dev,"fail to enable inclk" ); +dev_err (imx412->dev,"fail to enable inclk\n" ); goto error_reset; }
@@ -1145,7 +1145,7 @@ static int imx412_init_controls(struct imx412 *imx412) imx412->hblank_ctrl->flags |=V4L2_CTRL_FLAG_READ_ONLY ;if (ctrl_hdlr->error) { -dev_err (imx412->dev,"control init failed: %d" , +dev_err (imx412->dev,"control init failed: %d\n" , ctrl_hdlr->error);v4l2_ctrl_handler_free (ctrl_hdlr);return ctrl_hdlr->error;
@@ -1183,7 +1183,7 @@ static int imx412_probe(struct i2c_client *client) ret =imx412_parse_hw_config (imx412);if (ret) { -dev_err (imx412->dev,"HW configuration is not supported" ); +dev_err (imx412->dev,"HW configuration is not supported\n" );return ret; }
@@ -1191,14 +1191,14 @@ static int imx412_probe(struct i2c_client *client) ret =imx412_power_on (imx412->dev);if (ret) { -dev_err (imx412->dev,"failed to power-on the sensor" ); +dev_err (imx412->dev,"failed to power-on the sensor\n" ); goto error_mutex_destroy; }/* Check module identity */ ret =imx412_detect (imx412);if (ret) { -dev_err (imx412->dev,"failed to find sensor: %d" , ret); +dev_err (imx412->dev,"failed to find sensor: %d\n" , ret); goto error_power_off; }
@@ -1208,7 +1208,7 @@ static int imx412_probe(struct i2c_client *client) ret =imx412_init_controls (imx412);if (ret) { -dev_err (imx412->dev,"failed to init controls: %d" , ret); +dev_err (imx412->dev,"failed to init controls: %d\n" , ret); goto error_power_off; }
@@ -1222,14 +1222,14 @@ static int imx412_probe(struct i2c_client *client) imx412->pad.flags =MEDIA_PAD_FL_SOURCE ; ret =media_entity_pads_init (&imx412->sd.entity,1 , &imx412->pad);if (ret) { -dev_err (imx412->dev,"failed to init entity pads: %d" , ret); +dev_err (imx412->dev,"failed to init entity pads: %d\n" , ret); goto error_handler_free; } ret =v4l2_async_register_subdev_sensor (&imx412->sd);if (ret <0 ) {dev_err (imx412->dev, -"failed to register async subdev: %d" , ret); +"failed to register async subdev: %d\n" , ret); goto error_media_entity; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 450/623 media: i2c: ov9282: Correct the exposure offset
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit feaf4154d69657af2bf96e6e66cca794f88b1a61 ]
The datasheet lists that "Maximum exposure time is frame length -25 row periods, where frame length is set by registers {0x380E, 0x380F}".
However this driver had OV9282_EXPOSURE_OFFSET set to 12 which allowed that restriction to be violated, and would result in very under-exposed images.
Correct the offset.
--- drivers/media/i2c/ov9282.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov9282.c +1 -1
@@ -40,7 +40,7 @@/* Exposure control */ #define OV9282_REG_EXPOSURE 0x3500#define OV9282_EXPOSURE_MIN 1 -#define OV9282_EXPOSURE_OFFSET 12 +#define OV9282_EXPOSURE_OFFSET 25#define OV9282_EXPOSURE_STEP 1#define OV9282_EXPOSURE_DEFAULT 0x0282
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 451/623 media: mipi-csis: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 125ad1aeec77eb55273b420be6894b284a01e4b6 ]
Add check for the return value of clk_enable() to gurantee the success.
--- drivers/media/platform/samsung/exynos4-is/mipi-csis.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/samsung/exynos4-is/mipi-csis.c +8 -2
@@ -940,13 +940,19 @@ static int s5pcsis_pm_resume(struct device *dev, bool runtime) state->supplies); goto unlock; } -clk_enable (state->clock[CSIS_CLK_GATE ]); + ret =clk_enable (state->clock[CSIS_CLK_GATE ]); +if (ret) { +phy_power_off (state->phy); +regulator_bulk_disable (CSIS_NUM_SUPPLIES , + state->supplies); + goto unlock; + } }if (state->flags &ST_STREAMING )s5pcsis_start_stream (state); state->flags &= ~ST_SUSPENDED ; - unlock: +unlock:mutex_unlock (&state->lock);return ret ? -EAGAIN :0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 452/623 media: camif-core: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit 77ed2470ac09c2b0a33cf3f98cc51d18ba9ed976 ]
Add check for the return value of clk_enable() to gurantee the success.
--- .../media/platform/samsung/s3c-camif/camif-core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/media/platform/samsung/s3c-camif/camif-core.c +11 -2
@@ -527,10 +527,19 @@ static void s3c_camif_remove(struct platform_device *pdev)static int s3c_camif_runtime_resume (struct device *dev) {struct camif_dev *camif =dev_get_drvdata (dev); +int ret; + + ret =clk_enable (camif->clock[CLK_GATE ]); +if (ret) +return ret; -clk_enable (camif->clock[CLK_GATE ]);/* null op on s3c244x */ -clk_enable (camif->clock[CLK_CAM ]); + ret =clk_enable (camif->clock[CLK_CAM ]); +if (ret) { +clk_disable (camif->clock[CLK_GATE ]); +return ret; + } +return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 453/623 media: uvcvideo: Fix deadlock during uvc_probe
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit a67f75c2b5ecf534eab416ce16c11fe780c4f8f6 ]
If uvc_probe() fails, it can end up calling uvc_status_unregister() before uvc_status_init() is called.
Fix this by checking if dev->status is NULL or not in uvc_status_unregister().
--- drivers/media/usb/uvc/uvc_status.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/usb/uvc/uvc_status.c +3 -0
@@ -294,6 +294,9 @@ int uvc_status_init(struct uvc_device *dev)void uvc_status_unregister (struct uvc_device *dev) { +if (!dev->status) +return ; +uvc_status_suspend (dev);uvc_input_unregister (dev); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 454/623 media: uvcvideo: Propagate buf->error to userspace
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit 87ce177654e388451850905a1d376658aebe8699 ]
Now we return VB2_BUF_STATE_DONE for valid and invalid frames. Propagate the correct value, so the user can know if the frame is valid or not via struct v4l2_buffer->flags.
--- drivers/media/usb/uvc/uvc_queue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_queue.c +2 -1
@@ -479,7 +479,8 @@ static void uvc_queue_buffer_complete(struct kref *ref) buf->state = buf->error ?UVC_BUF_STATE_ERROR :UVC_BUF_STATE_DONE ;vb2_set_plane_payload (&buf->buf.vb2_buf,0 , buf->bytesused); -vb2_buffer_done (&buf->buf.vb2_buf,VB2_BUF_STATE_DONE ); +vb2_buffer_done (&buf->buf.vb2_buf, buf->error ?VB2_BUF_STATE_ERROR : +VB2_BUF_STATE_DONE ); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 455/623 mtd: rawnand: brcmnand: fix status read of brcmnand_waitfunc
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: david regan <[email protected]>
[ Upstream commit 03271ea36ea7a58d30a4bde182eb2a0d46220467 ]
This change fixes an issue where an error return value may be mistakenly used as NAND status.
--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +5 -0
@@ -2342,6 +2342,11 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,brcmnand_send_cmd (host,CMD_PROGRAM_PAGE ); status =brcmnand_waitfunc (chip); +if (status <0 ) { + ret = status; + goto out; + } +if (status &NAND_STATUS_FAIL ) {dev_info (ctrl->dev,"program failed at %llx\n" , (unsigned long long )addr);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 456/623 mtd: hyperbus: hbmc-am654: fix an OF node reference leak
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit bf5821909eb9c7f5d07d5c6e852ead2c373c94a0 ]
In am654_hbmc_platform_driver, .remove() and the error path of .probe() do not decrement the refcount of an OF node obtained by
of_get_next_child(). Fix this by adding of_node_put() calls.
--- drivers/mtd/hyperbus/hbmc-am654.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/mtd/hyperbus/hbmc-am654.c +13 -6
@@ -174,26 +174,30 @@ static int am654_hbmc_probe(struct platform_device *pdev) priv->hbdev.np =of_get_next_child (np,NULL ); ret =of_address_to_resource (priv->hbdev.np,0 , &res);if (ret) -return ret; + goto put_node;if (of_property_read_bool (dev->of_node,"mux-controls" )) {struct mux_control *control =devm_mux_control_get (dev,NULL ); -if (IS_ERR (control)) -return PTR_ERR (control); +if (IS_ERR (control)) { + ret =PTR_ERR (control); + goto put_node; + } ret =mux_control_select (control,1 );if (ret) {dev_err (dev,"Failed to select HBMC mux\n" ); -return ret; + goto put_node; } priv->mux_ctrl = control; } priv->hbdev.map.size =resource_size (&res); priv->hbdev.map.virt =devm_ioremap_resource (dev, &res); -if (IS_ERR (priv->hbdev.map.virt)) -return PTR_ERR (priv->hbdev.map.virt); +if (IS_ERR (priv->hbdev.map.virt)) { + ret =PTR_ERR (priv->hbdev.map.virt); + goto disable_mux; + } priv->ctlr.dev = dev; priv->ctlr.ops = &am654_hbmc_ops;
@@ -226,6 +230,8 @@ static int am654_hbmc_probe(struct platform_device *pdev) disable_mux:if (priv->mux_ctrl)mux_control_deselect (priv->mux_ctrl); +put_node: +of_node_put (priv->hbdev.np);return ret; }
@@ -241,6 +247,7 @@ static void am654_hbmc_remove(struct platform_device *pdev)if (dev_priv->rx_chan)dma_release_channel (dev_priv->rx_chan); +of_node_put (priv->hbdev.np); }static const struct of_device_id am654_hbmc_dt_ids[] = {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 457/623 media: nxp: imx8-isi: fix v4l2-compliance test errors
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurentiu Palcu <[email protected]>
[ Upstream commit 7b12ab055edef2f51733d155617a401a05237bcc ]
Running the v4l2-compliance (1.27.0-5208, SHA: af114250d48d) on the m2m device fails on the MMAP streaming tests, with the following messages:
fail: v4l2-test-buffers.cpp(240): g_field() == V4L2_FIELD_ANY
fail: v4l2-test-buffers.cpp(1508): buf.qbuf(node)
Apparently, the driver does not properly set the field member of vb2_v4l2_buffer struct, returning the default V4L2_FIELD_ANY value which is against the guidelines.
--- drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +3 -0
@@ -861,6 +861,7 @@ int mxc_isi_video_buffer_prepare(struct mxc_isi_dev *isi, struct vb2_buffer *vb2const struct mxc_isi_format_info *info, const struct v4l2_pix_format_mplane *pix) { + struct vb2_v4l2_buffer *v4l2_buf = to_vb2_v4l2_buffer(vb2);unsigned int i;for (i =0 ; i < info->mem_planes; i++) {
@@ -875,6 +876,8 @@ int mxc_isi_video_buffer_prepare(struct mxc_isi_dev *isi, struct vb2_buffer *vb2vb2_set_plane_payload (vb2, i, size); } + v4l2_buf->field = pix->field; +return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 458/623 watchdog: rti_wdt: Fix an OF node leak in rti_wdt_probe()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit 143981aa63f33d469a55a55fd9fb81cd90109672 ]
rti_wdt_probe() does not release the OF node reference obtained by of_parse_phandle(). Add a of_node_put() call.
This was found by an experimental verification tool that I am developing. Due to the lack of the actual device, no runtime test was able to be performed.
--- drivers/watchdog/rti_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/rti_wdt.c +1 -0
@@ -301,6 +301,7 @@ static int rti_wdt_probe(struct platform_device *pdev) node =of_parse_phandle (pdev->dev.of_node,"memory-region" ,0 );if (node) { ret =of_address_to_resource (node,0 , &res); +of_node_put (node);if (ret) {dev_err (dev,"No memory address assigned to the region.\n" ); goto err_iomap;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 459/623 staging: media: imx: fix OF node leak in imx_media_add_of_subdevs()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit 094f5c315f756b19198e6c401aa821ac0e868750 ]
imx_media_add_of_subdevs() calls of_parse_phandle() and passes the obtained node to imx_media_of_add_csi(). The passed node is used in v4l2_async_nf_add_fwnode(), which increments the refcount of the node. Therefore, while the current implementation only releases the node when imx_media_of_add_csi() fails, but should always release it. Call of_node_put() right after imx_media_of_add_csi().
--- drivers/staging/media/imx/imx-media-of.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/media/imx/imx-media-of.c +2 -6
@@ -54,22 +54,18 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,break ; ret =imx_media_of_add_csi (imxmd, csi_np); +of_node_put (csi_np);if (ret) {/* unavailable or already added is not an error */ if (ret == -ENODEV || ret == -EEXIST ) { -of_node_put (csi_np);continue ; }/* other error, can't continue */ - goto err_out; +return ret; } }return 0 ; - -err_out: -of_node_put (csi_np); -return ret; }EXPORT_SYMBOL_GPL (imx_media_add_of_subdevs);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 460/623 media: dvb-usb-v2: af9035: fix ISO C90 compilation error on af9035_i2c_master_xfer
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Desnes Nunes <[email protected]>
[ Upstream commit c36b9ad1a8add3c114e25fe167efa217a813b0c7 ]
This fixes a 'ISO C90 forbids mixed declarations and code' compilation error on af9035_i2c_master_xfer, which is caused by the sanity check added on user controlled msg[i], before declaring the demodulator register.
--- drivers/media/usb/dvb-usb-v2/af9035.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/af9035.c +12 -6
@@ -322,13 +322,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ret = -EOPNOTSUPP ; }else if ((msg[0 ].addr == state->af9033_i2c_addr[0 ]) || (msg[0 ].addr == state->af9033_i2c_addr[1 ])) { +/* demod access via firmware interface */ +u32 reg; +if (msg[0 ].len <3 || msg[1 ].len <1 ) { ret = -EOPNOTSUPP ; goto unlock; } -/* demod access via firmware interface */ -u32 reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | - msg[0 ].buf[2 ]; + + reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | + msg[0 ].buf[2 ];if (msg[0 ].addr == state->af9033_i2c_addr[1 ]) reg |=0x100000 ;
@@ -385,13 +388,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ret = -EOPNOTSUPP ; }else if ((msg[0 ].addr == state->af9033_i2c_addr[0 ]) || (msg[0 ].addr == state->af9033_i2c_addr[1 ])) { +/* demod access via firmware interface */ +u32 reg; +if (msg[0 ].len <3 ) { ret = -EOPNOTSUPP ; goto unlock; } -/* demod access via firmware interface */ -u32 reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | - msg[0 ].buf[2 ]; + + reg = msg[0 ].buf[0 ] <<16 | msg[0 ].buf[1 ] <<8 | + msg[0 ].buf[2 ];if (msg[0 ].addr == state->af9033_i2c_addr[1 ]) reg |=0x100000 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 461/623 PCI: rcar-ep: Fix incorrect variable used when calling devm_request_mem_region()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: King Dix <[email protected]>
[ Upstream commit 2d2da5a4c1b4509f6f7e5a8db015cd420144beb4 ]
The rcar_pcie_parse_outbound_ranges() uses the devm_request_mem_region() macro to request a needed resource. A string variable that lives on the stack is then used to store a dynamically computed resource name, which is then passed on as one of the macro arguments. This can lead to undefined behavior.
Depending on the current contents of the memory, the manifestations of errors may vary. One possible output may be as follows:
$ cat /proc/iomem 30000000-37ffffff : 38000000-3fffffff :
Sometimes, garbage may appear after the colon.
In very rare cases, if no NULL-terminator is found in memory, the system might crash because the string iterator will overrun which can lead to access of unmapped memory above the stack.
Thus, fix this by replacing outbound_name with the name of the previously requested resource. With the changes applied, the output will be as follows:
$ cat /proc/iomem 30000000-37ffffff : memory2 38000000-3fffffff : memory3
--- drivers/pci/controller/pcie-rcar-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-rcar-ep.c +1 -1
@@ -107,7 +107,7 @@ static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep, }if (!devm_request_mem_region (&pdev->dev, res->start,resource_size (res), - outbound_name)) { + res->name)) {dev_err (pcie->dev,"Cannot request memory region %s.\n" , outbound_name);return -EIO ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 462/623 PCI: rockchip: Add missing fields descriptions for struct rockchip_pcie_ep
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit fd46bc0e0bb3c6607363bd23f2b3c2a73dc75d66 ]
When compiling the Rockchip endpoint driver with -W=1, the following warnings can be seen in the output:
drivers/pci/controller/pcie-rockchip-ep.c:59: warning: Function parameter or struct member 'perst_irq' not described in 'rockchip_pcie_ep' drivers/pci/controller/pcie-rockchip-ep.c:59: warning: Function parameter or struct member 'perst_asserted' not described in 'rockchip_pcie_ep' drivers/pci/controller/pcie-rockchip-ep.c:59: warning: Function parameter or struct member 'link_up' not described in 'rockchip_pcie_ep' drivers/pci/controller/pcie-rockchip-ep.c:59: warning: Function parameter or struct member 'link_training' not described in 'rockchip_pcie_ep'
Fix these warnings by adding the missing field descriptions in struct rockchip_pcie_ep kernel-doc comment.
--- drivers/pci/controller/pcie-rockchip-ep.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/controller/pcie-rockchip-ep.c +4 -0
@@ -40,6 +40,10 @@* @irq_pci_fn: the latest PCI function that has updated the mapping of * the MSI/INTX IRQ dedicated outbound region. * @irq_pending: bitmask of asserted INTX IRQs. +* @perst_irq: IRQ used for the PERST# signal. +* @perst_asserted: True if the PERST# signal was asserted. +* @link_up: True if the PCI link is up. +* @link_training: Work item to execute PCI link training. */ struct rockchip_pcie_ep {struct rockchip_pcie rockchip;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 463/623 PCI: rockchip-ep: Fix error code in rockchip_pcie_ep_init_ob_mem()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 7ca288760007cab6588dc17f5b6fecf52c83a945 ]
Return -ENOMEM if pci_epc_mem_alloc_addr() fails. Don't return success.
--- drivers/pci/controller/pcie-rockchip-ep.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-rockchip-ep.c +1 -0
@@ -788,6 +788,7 @@ static int rockchip_pcie_ep_init_ob_mem(struct rockchip_pcie_ep *ep) SZ_1M);if (!ep->irq_cpu_addr) {dev_err (dev,"failed to reserve memory space for MSI\n" ); + err = -ENOMEM ; goto err_epc_mem_exit; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 464/623 PCI: imx6: Configure PHY based on Root Complex or Endpoint mode
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit de22e20589b79f35f92543119c33051f8179dba0 ]
Pass PHY_MODE_PCIE_EP if the PCI controller operates in Endpoint (EP) mode, and fix the Root Complex (RC) mode being hardcoded using a drvdata mode check.
--- drivers/pci/controller/dwc/pci-imx6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-imx6.c +3 -1
@@ -966,7 +966,9 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp) goto err_clk_disable; } - ret =phy_set_mode_ext (imx_pcie->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_RC ); + ret =phy_set_mode_ext (imx_pcie->phy,PHY_MODE_PCIE , + imx_pcie->drvdata->mode ==DW_PCIE_EP_TYPE ? +PHY_MODE_PCIE_EP :PHY_MODE_PCIE_RC );if (ret) {dev_err (dev,"unable to set PCIe PHY mode\n" ); goto err_phy_exit;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 465/623 PCI: imx6: Skip controller_id generation logic for i.MX7D
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
[ Upstream commit f068ffdd034c93f0c768acdc87d4d2d7023c1379 ]
The i.MX7D only has one PCIe controller, so controller_id should always be
0. The previous code is incorrect although yielding the correct result.
Fix by removing "IMX7D" from the switch case branch.
--- drivers/pci/controller/dwc/pci-imx6.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/controller/dwc/pci-imx6.c +0 -1
@@ -1393,7 +1393,6 @@ static int imx_pcie_probe(struct platform_device *pdev)switch (imx_pcie->drvdata->variant) {case IMX8MQ :case IMX8MQ_EP : -case IMX7D :if (dbi_base->start ==IMX8MQ_PCIE2_BASE_ADDR ) imx_pcie->controller_id =1 ;break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 466/623 PCI: imx6: Deassert apps_reset in imx_pcie_deassert_core_reset()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
[ Upstream commit ef61c7d8d032adb467f99d03ccfaa293b417ac75 ]
Since the apps_reset is asserted in imx_pcie_assert_core_reset(), it should be deasserted in imx_pcie_deassert_core_reset().
--- drivers/pci/controller/dwc/pci-imx6.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pci-imx6.c +1 -0
@@ -775,6 +775,7 @@ static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie)static int imx_pcie_deassert_core_reset (struct imx_pcie *imx_pcie) {reset_control_deassert (imx_pcie->pciephy_reset); +reset_control_deassert (imx_pcie->apps_reset);if (imx_pcie->drvdata->core_reset) imx_pcie->drvdata->core_reset (imx_pcie, false);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 467/623 PCI: imx6: Add missing reference clock disable logic
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
[ Upstream commit 93d883f89063744a92006fc356b1c767eb62d950 ]
Ensure the *_enable_ref_clk() function is symmetric by addressing missing disable parts on some platforms.
--- drivers/pci/controller/dwc/pci-imx6.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +12 -12
@@ -598,10 +598,9 @@ static int imx_pcie_attach_pd(struct device *dev)static int imx6sx_pcie_enable_ref_clk (struct imx_pcie *imx_pcie,bool enable) { -if (enable) -regmap_clear_bits (imx_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6SX_GPR12_PCIE_TEST_POWERDOWN ); - +regmap_update_bits (imx_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6SX_GPR12_PCIE_TEST_POWERDOWN , + enable ?0 :IMX6SX_GPR12_PCIE_TEST_POWERDOWN );return 0 ; }
@@ -630,19 +629,20 @@ static int imx8mm_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable) {int offset =imx_pcie_grp_offset (imx_pcie); -if (enable) { -regmap_clear_bits (imx_pcie->iomuxc_gpr, offset,IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE ); -regmap_set_bits (imx_pcie->iomuxc_gpr, offset,IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN ); - } - +regmap_update_bits (imx_pcie->iomuxc_gpr, offset, +IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE , + enable ?0 :IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE ); +regmap_update_bits (imx_pcie->iomuxc_gpr, offset, +IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN , + enable ?IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN :0 );return 0 ; }static int imx7d_pcie_enable_ref_clk (struct imx_pcie *imx_pcie,bool enable) { -if (!enable) -regmap_set_bits (imx_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX7D_GPR12_PCIE_PHY_REFCLK_SEL ); +regmap_update_bits (imx_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX7D_GPR12_PCIE_PHY_REFCLK_SEL , + enable ?0 :IMX7D_GPR12_PCIE_PHY_REFCLK_SEL );return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 468/623 PCI: qcom: Update ICC and OPP values after Link Up event
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna chaitanya chundru <[email protected]>
[ Upstream commit f0639013d340580b72df95d012a93f35eeb0da64 ]
4581403f6792 ("PCI: qcom: Enumerate endpoints based on Link up event in 'global_irq' interrupt") added the Link Up-based enumeration support, but did not update the ICC/OPP vote once link is up. Before that, the update happened during probe and the endpoints may or may not be enumerated at that time, so the ICC/OPP vote was not guaranteed to be accurate.
With Link Up-based enumeration support, the driver can request the accurate vote based on the PCIe link.
Call qcom_pcie_icc_opp_update() in qcom_pcie_global_irq_thread() after enumerating the endpoints.
--- drivers/pci/controller/dwc/pcie-qcom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
@@ -1569,6 +1569,8 @@ static irqreturn_t qcom_pcie_global_irq_thread(int irq, void *data)pci_lock_rescan_remove ();pci_rescan_bus (pp->bridge->bus);pci_unlock_rescan_remove (); + +qcom_pcie_icc_opp_update (pcie); }else {dev_WARN_ONCE (dev,1 ,"Received unknown event. INT_STATUS: 0x%08x\n" , status);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 469/623 PCI: dwc: Always stop link in the dw_pcie_suspend_noirq
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Zhu <[email protected]>
[ Upstream commit 86a016e278b78cc2281edd4ffaddbc011c87a593 ]
On the i.MX8QM, PCIe link can't be re-established again in dw_pcie_resume_noirq(), if the LTSSM_EN bit is not cleared properly in dw_pcie_suspend_noirq().
So, add dw_pcie_stop_link() to dw_pcie_suspend_noirq() to fix this issue and to align the suspend/resume functions since there is dw_pcie_start_link() in dw_pcie_resume_noirq() already.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -0
@@ -946,6 +946,7 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)return ret; } +dw_pcie_stop_link (pci);if (pci->pp.ops->deinit) pci->pp.ops->deinit (&pci->pp);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 470/623 PCI: endpoint: pci-epf-test: Set dma_chan_rx pointer to NULL on error
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Khalfella <[email protected]>
[ Upstream commit b1b1f4b12969130c0a6ec0cf0299460cb01e799c ]
If dma_chan_tx allocation fails, set dma_chan_rx to NULL after it is freed.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +1 -1
@@ -251,7 +251,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) fail_back_rx:dma_release_channel (epf_test->dma_chan_rx); - epf_test->dma_chan_tx =NULL ; + epf_test->dma_chan_rx =NULL ; fail_back_tx:dma_cap_zero (mask);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 471/623 PCI: endpoint: pci-epf-test: Fix check for DMA MEMCPY test
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 235c2b197a8de2887f13990094a3343d2392155b ]
Currently, if DMA MEMCPY test is requested by the host, and if the endpoint DMA controller supports DMA_PRIVATE, the test will fail. This is not correct since there is no check for DMA_MEMCPY capability and the DMA controller can support both DMA_PRIVATE and DMA_MEMCPY.
Fix the check and also reword the error message.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/endpoint/functions/pci-epf-test.c +2 -2
@@ -328,8 +328,8 @@ static void pci_epf_test_copy(struct pci_epf_test *epf_test,void *copy_buf =NULL , *buf;if (reg->flags &FLAG_USE_DMA ) { -if (epf_test->dma_private) { -dev_err (dev,"Cannot transfer data using DMA\n" ); +if (!dma_has_cap (DMA_MEMCPY , epf_test->dma_chan_tx->device->cap_mask)) { +dev_err (dev,"DMA controller doesn't support MEMCPY\n" ); ret = -EINVAL ; goto set_status; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 472/623 PCI: microchip: Set inbound address translation for coherent or non-coherent mode
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daire McNamara <[email protected]>
[ Upstream commit 1390a33b3d04fdf6ba4e3e7082107a12027fc188 ]
On Microchip PolarFire SoC the PCIe Root Port can be behind one of three general purpose Fabric Interface Controller (FIC) buses that encapsulates an AXI-S bus. Depending on which FIC(s) the Root Port is connected through to CPU space, and what address translation is done by that FIC, the Root Port driver's inbound address translation may vary.
For all current supported designs and all future expected designs, inbound address translation done by a FIC on PolarFire SoC varies depending on whether PolarFire SoC is operating in coherent DMA mode or noncoherent DMA mode.
The setup of the outbound address translation tables in the Root Port driver only needs to handle these two cases.
Setup the inbound address translation tables to one of two address translations, depending on whether the Root Port is being used with coherent DMA or noncoherent DMA.
[bhelgaas: adapt for ac7f53b7e728 ("PCI: microchip: Add support for using either Root Port 1 or 2")]
--- .../pci/controller/plda/pcie-microchip-host.c | 96 +++++++++++++++++++ drivers/pci/controller/plda/pcie-plda-host.c | 17 +++- drivers/pci/controller/plda/pcie-plda.h | 6 +- 3 files changed, 114 insertions(+), 5 deletions(-)
drivers/pci/controller/plda/pcie-microchip-host.c +96 -0
@@ -7,20 +7,27 @@* Author: Daire McNamara <[email protected]> */ +#include <linux/align.h> +#include <linux/bits.h> #include <linux/bitfield.h> #include <linux/clk.h> #include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> +#include <linux/log2.h> #include <linux/module.h> #include <linux/msi.h> #include <linux/of_address.h> #include <linux/of_pci.h> #include <linux/pci-ecam.h> #include <linux/platform_device.h> +#include <linux/wordpart.h> #include "../../pci.h" #include "pcie-plda.h" +#define MC_MAX_NUM_INBOUND_WINDOWS 8 +#define MPFS_NC_BOUNCE_ADDR 0x80000000 +/* PCIe Bridge Phy and Controller Phy offsets */ #define MC_PCIE1_BRIDGE_ADDR 0x00008000u#define MC_PCIE1_CTRL_ADDR 0x0000a000u
@@ -607,6 +614,91 @@ static void mc_disable_interrupts(struct mc_pcie *port)writel_relaxed (GENMASK (31 ,0 ), port->bridge_base_addr +ISTATUS_HOST ); } +static void mc_pcie_setup_inbound_atr (struct mc_pcie *port,int window_index, +u64 axi_addr,u64 pcie_addr,u64 size) +{ +u32 table_offset = window_index *ATR_ENTRY_SIZE ; +void __iomem *table_addr = port->bridge_base_addr + table_offset; +u32 atr_sz; +u32 val; + + atr_sz =ilog2 (size) -1 ; + + val =ALIGN_DOWN (lower_32_bits (pcie_addr),SZ_4K ); + val |=FIELD_PREP (ATR_SIZE_MASK , atr_sz); + val |=ATR_IMPL_ENABLE ; + +writel (val, table_addr +ATR0_PCIE_WIN0_SRCADDR_PARAM ); + +writel (upper_32_bits (pcie_addr), table_addr +ATR0_PCIE_WIN0_SRC_ADDR ); + +writel (lower_32_bits (axi_addr), table_addr +ATR0_PCIE_WIN0_TRSL_ADDR_LSB ); +writel (upper_32_bits (axi_addr), table_addr +ATR0_PCIE_WIN0_TRSL_ADDR_UDW ); + +writel (TRSL_ID_AXI4_MASTER_0 , table_addr +ATR0_PCIE_WIN0_TRSL_PARAM ); +} + +static int mc_pcie_setup_inbound_ranges (struct platform_device *pdev, +struct mc_pcie *port) +{ +struct device *dev = &pdev->dev; +struct device_node *dn = dev->of_node; +struct of_range_parser parser; +struct of_range range; +int atr_index =0 ; + +/* +* MPFS PCIe Root Port is 32-bit only, behind a Fabric Interface +* Controller FPGA logic block which contains the AXI-S interface. +* +* From the point of view of the PCIe Root Port, there are only two +* supported Root Port configurations: +* +* Configuration 1: for use with fully coherent designs; supports a +* window from 0x0 (CPU space) to specified PCIe space. +* +* Configuration 2: for use with non-coherent designs; supports two +* 1 GB windows to CPU space; one mapping CPU space 0 to PCIe space +* 0x80000000 and a second mapping CPU space 0x40000000 to PCIe +* space 0xc0000000. This cfg needs two windows because of how the +* MSI space is allocated in the AXI-S range on MPFS. +* +* The FIC interface outside the PCIe block *must* complete the +* inbound address translation as per MCHP MPFS FPGA design +* guidelines. +*/ +if (device_property_read_bool (dev,"dma-noncoherent" )) { +/* +* Always need same two tables in this case. Need two tables +* due to hardware interactions between address and size. +*/ +mc_pcie_setup_inbound_atr (port,0 ,0 , +MPFS_NC_BOUNCE_ADDR ,SZ_1G ); +mc_pcie_setup_inbound_atr (port,1 ,SZ_1G , +MPFS_NC_BOUNCE_ADDR +SZ_1G ,SZ_1G ); + }else { +/* Find any DMA ranges */ +if (of_pci_dma_range_parser_init (&parser, dn)) { +/* No DMA range property - setup default */ +mc_pcie_setup_inbound_atr (port,0 ,0 ,0 ,SZ_4G ); +return 0 ; + } + +for_each_of_range (&parser, &range) { +if (atr_index >=MC_MAX_NUM_INBOUND_WINDOWS ) { +dev_err (dev,"too many inbound ranges; %d available tables\n" , +MC_MAX_NUM_INBOUND_WINDOWS ); +return -EINVAL ; + } +mc_pcie_setup_inbound_atr (port, atr_index,0 , + range.pci_addr, range.size); + atr_index++; + } + } + +return 0 ; +} +static int mc_platform_init (struct pci_config_window *cfg) {struct device *dev = cfg->parent;
@@ -627,6 +719,10 @@ static int mc_platform_init(struct pci_config_window *cfg)if (ret)return ret; + ret =mc_pcie_setup_inbound_ranges (pdev, port); +if (ret) +return ret; + port->plda.event_ops = &mc_event_ops; port->plda.event_irq_chip = &mc_event_irq_chip; port->plda.events_bitmap =GENMASK (NUM_EVENTS -1 ,0 );
drivers/pci/controller/plda/pcie-plda-host.c +14 -3
@@ -8,11 +8,14 @@* Author: Daire McNamara <[email protected]> */ +#include <linux/align.h> +#include <linux/bitfield.h> #include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> #include <linux/msi.h> #include <linux/pci_regs.h> #include <linux/pci-ecam.h> +#include <linux/wordpart.h> #include "pcie-plda.h"
@@ -502,8 +505,9 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index,writel (val, bridge_base_addr + (index *ATR_ENTRY_SIZE ) +ATR0_AXI4_SLV0_TRSL_PARAM ); - val =lower_32_bits (axi_addr) | (atr_sz <<ATR_SIZE_SHIFT ) | -ATR_IMPL_ENABLE ; + val =ALIGN_DOWN (lower_32_bits (axi_addr),SZ_4K ); + val |=FIELD_PREP (ATR_SIZE_MASK , atr_sz); + val |=ATR_IMPL_ENABLE ;writel (val, bridge_base_addr + (index *ATR_ENTRY_SIZE ) +ATR0_AXI4_SLV0_SRCADDR_PARAM );
@@ -518,13 +522,20 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, val =upper_32_bits (pci_addr);writel (val, bridge_base_addr + (index *ATR_ENTRY_SIZE ) +ATR0_AXI4_SLV0_TRSL_ADDR_UDW ); +} +EXPORT_SYMBOL_GPL (plda_pcie_setup_window); + +void plda_pcie_setup_inbound_address_translation (struct plda_pcie_rp *port) +{ +void __iomem *bridge_base_addr = port->bridge_addr; +u32 val; val =readl (bridge_base_addr +ATR0_PCIE_WIN0_SRCADDR_PARAM ); val |= (ATR0_PCIE_ATR_SIZE <<ATR0_PCIE_ATR_SIZE_SHIFT );writel (val, bridge_base_addr +ATR0_PCIE_WIN0_SRCADDR_PARAM );writel (0 , bridge_base_addr +ATR0_PCIE_WIN0_SRC_ADDR ); } -EXPORT_SYMBOL_GPL (plda_pcie_setup_window); +EXPORT_SYMBOL_GPL (plda_pcie_setup_inbound_address_translation);int plda_pcie_setup_iomems (struct pci_host_bridge *bridge,struct plda_pcie_rp *port)
drivers/pci/controller/plda/pcie-plda.h +4 -2
@@ -89,14 +89,15 @@/* PCIe AXI slave table init defines */ #define ATR0_AXI4_SLV0_SRCADDR_PARAM 0x800u -#define ATR_SIZE_SHIFT 1 -#define ATR_IMPL_ENABLE 1 +#define ATR_SIZE_MASK GENMASK(6, 1) +#define ATR_IMPL_ENABLE BIT(0)#define ATR0_AXI4_SLV0_SRC_ADDR 0x804u#define ATR0_AXI4_SLV0_TRSL_ADDR_LSB 0x808u#define ATR0_AXI4_SLV0_TRSL_ADDR_UDW 0x80cu#define ATR0_AXI4_SLV0_TRSL_PARAM 0x810u#define PCIE_TX_RX_INTERFACE 0x00000000u#define PCIE_CONFIG_INTERFACE 0x00000001u +#define TRSL_ID_AXI4_MASTER_0 0x00000004u#define CONFIG_SPACE_ADDR_OFFSET 0x1000u
@@ -204,6 +205,7 @@ int plda_init_interrupts(struct platform_device *pdev,void plda_pcie_setup_window (void __iomem *bridge_base_addr,u32 index,phys_addr_t axi_addr,phys_addr_t pci_addr,size_t size); +void plda_pcie_setup_inbound_address_translation (struct plda_pcie_rp *port);int plda_pcie_setup_iomems (struct pci_host_bridge *bridge,struct plda_pcie_rp *port); int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 473/623 scsi: mpt3sas: Set ioc->manu_pg11.EEDPTagMode directly to 1
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Menzel <[email protected]>
[ Upstream commit ad7c3c0cb8f61d6d5a48b83e62ca4a9fd2f26153 ]
Currently, the code does:
if (x == 0) {
x &= ~0x3;
x |= 0x1;
}Zeroing bits 0 and 1 of a variable that is 0 is not necessary. So directly set the variable to 1.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +1 -2
@@ -5629,8 +5629,7 @@ _base_static_config_pages(struct MPT3SAS_ADAPTER *ioc)if (!ioc->is_gen35_ioc && ioc->manu_pg11.EEDPTagMode ==0 ) {pr_err ("%s: overriding NVDATA EEDPTagMode setting\n" , ioc->name); - ioc->manu_pg11.EEDPTagMode &= ~0x3 ; - ioc->manu_pg11.EEDPTagMode |=0x1 ; + ioc->manu_pg11.EEDPTagMode =0x1 ;mpt3sas_config_set_manufacturing_pg11 (ioc, &mpi_reply, &ioc->manu_pg11); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 474/623 scsi: ufs: bsg: Delete bsg_dev when setting up bsg fails
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit fcf247deb3c3e1c6be5774e3fa03bbd018eff1a9 ]
We should remove the bsg device when bsg_setup_queue() fails to release the resources.
--- drivers/ufs/core/ufs_bsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/ufs/core/ufs_bsg.c +1 -0
@@ -257,6 +257,7 @@ int ufs_bsg_probe(struct ufs_hba *hba) NULL, 0);if (IS_ERR (q)) { ret =PTR_ERR (q); +device_del (bsg_dev); goto out; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 475/623 scsi: mpi3mr: Fix possible crash when setting up bsg fails
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 295006f6e8c17212d3098811166e29627d19e05c ]
If bsg_setup_queue() fails, the bsg_queue is assigned a non-NULL value. Consequently, in mpi3mr_bsg_exit(), the condition "if(!mrioc->bsg_queue)" will not be satisfied, preventing execution from entering bsg_remove_queue(), which could lead to the following crash:
BUG: kernel NULL pointer dereference, address: 000000000000041c Call Trace: <TASK> mpi3mr_bsg_exit+0x1f/0x50 [mpi3mr] mpi3mr_remove+0x6f/0x340 [mpi3mr] pci_device_remove+0x3f/0xb0 device_release_driver_internal+0x19d/0x220 unbind_store+0xa4/0xb0 kernfs_fop_write_iter+0x11f/0x200 vfs_write+0x1fc/0x3e0 ksys_write+0x67/0xe0 do_syscall_64+0x38/0x80 entry_SYSCALL_64_after_hwframe+0x78/0xe2
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +6 -2
@@ -2951,6 +2951,7 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc) .max_hw_sectors = MPI3MR_MAX_APP_XFER_SECTORS, .max_segments = MPI3MR_MAX_APP_XFER_SEGMENTS, }; +struct request_queue *q;device_initialize (bsg_dev);
@@ -2966,14 +2967,17 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)return ; } - mrioc->bsg_queue =bsg_setup_queue (bsg_dev,dev_name (bsg_dev), &lim, + q =bsg_setup_queue (bsg_dev,dev_name (bsg_dev), &lim, mpi3mr_bsg_request,NULL ,0 ); -if (IS_ERR (mrioc->bsg_queue)) { +if (IS_ERR (q)) {ioc_err (mrioc,"%s: bsg registration failed\n" ,dev_name (bsg_dev));device_del (bsg_dev);put_device (bsg_dev); +return ; } + + mrioc->bsg_queue = q; }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 476/623 firewire: test: Fix potential null dereference in firewire kunit test
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit 352fafe97784e81a10a7c74bd508f71a19b53c2a ]
kunit_kzalloc() may return a NULL pointer, dereferencing it without NULL check may lead to NULL dereference.
Add a NULL check for test_state.
--- drivers/firewire/device-attribute-test.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firewire/device-attribute-test.c +2 -0
@@ -99,6 +99,7 @@ static void device_attr_simple_avc(struct kunit *test)struct device *unit0_dev = (struct device *)&unit0.device;static const int unit0_expected_ids[] = {0x00ffffff ,0x00ffffff ,0x0000a02d ,0x00010001 };char *buf =kunit_kzalloc (test,PAGE_SIZE ,GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, buf);int ids[4 ] = {0 ,0 ,0 ,0 };// Ensure associations for node and unit devices.
@@ -180,6 +181,7 @@ static void device_attr_legacy_avc(struct kunit *test)struct device *unit0_dev = (struct device *)&unit0.device;static const int unit0_expected_ids[] = {0x00012345 ,0x00fedcba ,0x00abcdef ,0x00543210 };char *buf =kunit_kzalloc (test,PAGE_SIZE ,GFP_KERNEL ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, buf);int ids[4 ] = {0 ,0 ,0 ,0 };// Ensure associations for node and unit devices.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 477/623 erofs: fix potential return value overflow of z_erofs_shrink_scan()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <[email protected]>
[ Upstream commit db902986dee453bfb5835cbc8efa67154ab34caf ]
z_erofs_shrink_scan() could return small numbers due to the mistyped freed.
Although I don't think it has any visible impact.
--- fs/erofs/zdata.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/erofs/zdata.c +1 -2
@@ -927,8 +927,7 @@ unsigned long z_erofs_shrink_scan(struct erofs_sb_info *sbi, unsigned long nr_shrink) {struct z_erofs_pcluster *pcl; -unsigned int freed =0 ; -unsigned long index; +unsigned long index, freed =0 ;xa_lock (&sbi->managed_pslots);xa_for_each (&sbi->managed_pslots, index, pcl) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 478/623 ocfs2: mark dquot as inactive if failed to start trans while releasing dquot
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Yue <[email protected]>
[ Upstream commit 276c61385f6bc3223a5ecd307cf4aba2dfbb9a31 ]
While running fstests generic/329, the kernel workqueue quota_release_workfn is dead looping in calling ocfs2_release_dquot(). The ocfs2 state is already readonly but ocfs2_release_dquot wants to start a transaction but fails and returns.
=====================================================================
[ 2918.123602 ][ T275 ] On-disk corruption discovered. Please run fsck.ocfs2 once the filesystem is unmounted.
[ 2918.124034 ][ T275 ] (kworker/u135:1,275,11):ocfs2_release_dquot:765
ERROR: status = -30
[ 2918.124452 ][ T275 ] (kworker/u135:1,275,11):ocfs2_release_dquot:795
ERROR: status = -30
[ 2918.124883 ][ T275 ] (kworker/u135:1,275,11):ocfs2_start_trans:357
ERROR: status = -30
[ 2918.125276 ][ T275 ] OCFS2: abort (device dm-0): ocfs2_start_trans:
Detected aborted journal
[ 2918.125710 ][ T275 ] On-disk corruption discovered. Please run fsck.ocfs2 once the filesystem is unmounted.
=====================================================================
ocfs2_release_dquot() is much like dquot_release(), which is called by ext4 to handle similar situation. So here fix it by marking the dquot as inactive like what dquot_release() does.
--- fs/ocfs2/quota_global.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ocfs2/quota_global.c +5 -0
@@ -761,6 +761,11 @@ static int ocfs2_release_dquot(struct dquot *dquot) handle =ocfs2_start_trans (osb,ocfs2_calc_qdel_credits (dquot->dq_sb, dquot->dq_id.type));if (IS_ERR (handle)) { +/* +* Mark dquot as inactive to avoid endless cycle in +* quota_release_workfn(). +*/ +clear_bit (DQ_ACTIVE_B , &dquot->dq_flags); status =PTR_ERR (handle);mlog_errno (status); goto out_ilock;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 479/623 nilfs2: do not force clear folio if buffer is referenced
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit ca76bb226bf47ff04c782cacbd299f12ddee1ec1 ]
Patch series "nilfs2: protect busy buffer heads from being force-cleared".
This series fixes the buffer head state inconsistency issues reported by syzbot that occurs when the filesystem is corrupted and falls back to read-only, and the associated buffer head use-after-free issue.
This patch (of 2):
Syzbot has reported that after nilfs2 detects filesystem corruption and falls back to read-only, inconsistencies in the buffer state may occur.
One of the inconsistencies is that when nilfs2 calls mark_buffer_dirty() to set a data or metadata buffer as dirty, but it detects that the buffer is not in the uptodate state:
WARNING: CPU: 0 PID: 6049 at fs/buffer.c:1177 mark_buffer_dirty+0x2e5/0x520 fs/buffer.c:1177 ... Call Trace: <TASK> nilfs_palloc_commit_alloc_entry+0x4b/0x160 fs/nilfs2/alloc.c:598 nilfs_ifile_create_inode+0x1dd/0x3a0 fs/nilfs2/ifile.c:73 nilfs_new_inode+0x254/0x830 fs/nilfs2/inode.c:344 nilfs_mkdir+0x10d/0x340 fs/nilfs2/namei.c:218 vfs_mkdir+0x2f9/0x4f0 fs/namei.c:4257 do_mkdirat+0x264/0x3a0 fs/namei.c:4280 __do_sys_mkdirat fs/namei.c:4295 [inline] __se_sys_mkdirat fs/namei.c:4293 [inline] __x64_sys_mkdirat+0x87/0xa0 fs/namei.c:4293 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
The other is when nilfs_btree_propagate(), which propagates the dirty state to the ancestor nodes of a b-tree that point to a dirty buffer, detects that the origin buffer is not dirty, even though it should be:
WARNING: CPU: 0 PID: 5245 at fs/nilfs2/btree.c:2089 nilfs_btree_propagate+0xc79/0xdf0 fs/nilfs2/btree.c:2089 ... Call Trace: <TASK> nilfs_bmap_propagate+0x75/0x120 fs/nilfs2/bmap.c:345 nilfs_collect_file_data+0x4d/0xd0 fs/nilfs2/segment.c:587 nilfs_segctor_apply_buffers+0x184/0x340 fs/nilfs2/segment.c:1006 nilfs_segctor_scan_file+0x28c/0xa50 fs/nilfs2/segment.c:1045 nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1216 [inline] nilfs_segctor_collect fs/nilfs2/segment.c:1540 [inline] nilfs_segctor_do_construct+0x1c28/0x6b90 fs/nilfs2/segment.c:2115 nilfs_segctor_construct+0x181/0x6b0 fs/nilfs2/segment.c:2479 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2587 [inline] nilfs_segctor_thread+0x69e/0xe80 fs/nilfs2/segment.c:2701 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK>
Both of these issues are caused by the callbacks that handle the page/folio write requests, forcibly clear various states, including the working state of the buffers they hold, at unexpected times when they detect read-only fallback.
Fix these issues by checking if the buffer is referenced before clearing the page/folio state, and skipping the clear if it is.
--- fs/nilfs2/page.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
fs/nilfs2/page.c +27 -4
@@ -392,6 +392,11 @@ void nilfs_clear_dirty_pages(struct address_space *mapping)/** * nilfs_clear_folio_dirty - discard dirty folio * @folio: dirty folio that will be discarded +* +* nilfs_clear_folio_dirty() clears working states including dirty state for +* the folio and its buffers. If the folio has buffers, clear only if it is +* confirmed that none of the buffer heads are busy (none have valid +* references and none are locked). */ void nilfs_clear_folio_dirty (struct folio *folio) {
@@ -399,10 +404,6 @@ void nilfs_clear_folio_dirty(struct folio *folio)BUG_ON (!folio_test_locked (folio)); -folio_clear_uptodate (folio); -folio_clear_mappedtodisk (folio); -folio_clear_checked (folio); - head =folio_buffers (folio);if (head) { const unsigned long clear_bits =
@@ -410,6 +411,25 @@ void nilfs_clear_folio_dirty(struct folio *folio)BIT (BH_Async_Write) |BIT (BH_NILFS_Volatile) |BIT (BH_NILFS_Checked) |BIT (BH_NILFS_Redirected) | BIT(BH_Delay)); +bool busy, invalidated = false; + +recheck_buffers: + busy = false; + bh = head; +do { +if (atomic_read (&bh->b_count) |buffer_locked (bh)) { + busy = true; +break ; + } + }while (bh = bh->b_this_page, bh != head); + +if (busy) { +if (invalidated) +return ; +invalidate_bh_lrus (); + invalidated = true; + goto recheck_buffers; + } bh = head; do {
@@ -419,6 +439,9 @@ void nilfs_clear_folio_dirty(struct folio *folio) }while (bh = bh->b_this_page, bh != head); } +folio_clear_uptodate (folio); +folio_clear_mappedtodisk (folio); +folio_clear_checked (folio);__nilfs_clear_folio_dirty (folio); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 480/623 nilfs2: protect access to buffers with no active references
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 367a9bffabe08c04f6d725032cce3d891b2b9e1a ]
nilfs_lookup_dirty_data_buffers(), which iterates through the buffers attached to dirty data folios/pages, accesses the attached buffers without locking the folios/pages.
For data cache, nilfs_clear_folio_dirty() may be called asynchronously when the file system degenerates to read only, so nilfs_lookup_dirty_data_buffers() still has the potential to cause use after free issues when buffers lose the protection of their dirty state midway due to this asynchronous clearing and are unintentionally freed by try_to_free_buffers().
Eliminate this race issue by adjusting the lock section in this function.
--- fs/nilfs2/segment.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nilfs2/segment.c +3 -1
@@ -734,7 +734,6 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,if (!head) head =create_empty_buffers (folio,i_blocksize (inode),0 ); -folio_unlock (folio); bh = head; do {
@@ -744,11 +743,14 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,list_add_tail (&bh->b_assoc_buffers, listp); ndirties++;if (unlikely (ndirties >= nlimit)) { +folio_unlock (folio);folio_batch_release (&fbatch);cond_resched ();return ndirties; } }while (bh = bh->b_this_page, bh != head); + +folio_unlock (folio); }folio_batch_release (&fbatch);cond_resched ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 481/623 nilfs2: handle errors that nilfs_prepare_chunk() may return
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit ee70999a988b8abc3490609142f50ebaa8344432 ]
Patch series "nilfs2: fix issues with rename operations".
This series fixes BUG_ON check failures reported by syzbot around rename operations, and a minor behavioral issue where the mtime of a child directory changes when it is renamed instead of moved.
This patch (of 2):
The directory manipulation routines nilfs_set_link() and nilfs_delete_entry() rewrite the directory entry in the folio/page previously read by nilfs_find_entry(), so error handling is omitted on the assumption that nilfs_prepare_chunk(), which prepares the buffer for rewriting, will always succeed for these. And if an error is returned, it triggers the legacy BUG_ON() checks in each routine.
This assumption is wrong, as proven by syzbot: the buffer layer called by nilfs_prepare_chunk() may call nilfs_get_block() if necessary, which may fail due to metadata corruption or other reasons. This has been there all along, but improved sanity checks and error handling may have made it more reproducible in fuzzing tests.
Fix this issue by adding missing error paths in nilfs_set_link(), nilfs_delete_entry(), and their caller nilfs_rename().
--- fs/nilfs2/dir.c | 13 ++++++++++--- fs/nilfs2/namei.c | 29 +++++++++++++++-------------- fs/nilfs2/nilfs.h | 4 ++-- 3 files changed, 27 insertions(+), 19 deletions(-)
fs/nilfs2/dir.c +10 -3
@@ -400,7 +400,7 @@ int nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr, ino_t *ino)return 0 ; } -void nilfs_set_link (struct inode *dir,struct nilfs_dir_entry *de, +int nilfs_set_link (struct inode *dir,struct nilfs_dir_entry *de,struct folio *folio,struct inode *inode) {size_t from =offset_in_folio (folio, de);
@@ -410,11 +410,15 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de,folio_lock (folio); err =nilfs_prepare_chunk (folio, from, to); -BUG_ON (err); +if (unlikely (err)) { +folio_unlock (folio); +return err; + } de->inode =cpu_to_le64 (inode->i_ino); de->file_type =fs_umode_to_ftype (inode->i_mode);nilfs_commit_chunk (folio, mapping, from, to);inode_set_mtime_to_ts (dir,inode_set_ctime_current (dir)); +return 0 ; }/*
@@ -543,7 +547,10 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) from = (char *)pde - kaddr;folio_lock (folio); err =nilfs_prepare_chunk (folio, from, to); -BUG_ON (err); +if (unlikely (err)) { +folio_unlock (folio); + goto out; + }if (pde) pde->rec_len =nilfs_rec_len_to_disk (to - from); dir->inode =0 ;
fs/nilfs2/namei.c +15 -14
@@ -406,8 +406,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, err =PTR_ERR (new_de); goto out_dir; } -nilfs_set_link (new_dir, new_de, new_folio, old_inode); + err =nilfs_set_link (new_dir, new_de, new_folio, old_inode);folio_release_kmap (new_folio, new_de); +if (unlikely (err)) + goto out_dir;nilfs_mark_inode_dirty (new_dir);inode_set_ctime_current (new_inode);if (dir_de)
@@ -430,28 +432,27 @@ static int nilfs_rename(struct mnt_idmap *idmap,*/ inode_set_ctime_current (old_inode); -nilfs_delete_entry (old_de, old_folio); - -if (dir_de) { -nilfs_set_link (old_inode, dir_de, dir_folio, new_dir); -folio_release_kmap (dir_folio, dir_de); -drop_nlink (old_dir); + err =nilfs_delete_entry (old_de, old_folio); +if (likely (!err)) { +if (dir_de) { + err =nilfs_set_link (old_inode, dir_de, dir_folio, + new_dir); +drop_nlink (old_dir); + } +nilfs_mark_inode_dirty (old_dir); } -folio_release_kmap (old_folio, old_de); - -nilfs_mark_inode_dirty (old_dir);nilfs_mark_inode_dirty (old_inode); - err =nilfs_transaction_commit (old_dir->i_sb); -return err; - out_dir:if (dir_de)folio_release_kmap (dir_folio, dir_de); out_old:folio_release_kmap (old_folio, old_de); out: -nilfs_transaction_abort (old_dir->i_sb); +if (likely (!err)) + err =nilfs_transaction_commit (old_dir->i_sb); +else +nilfs_transaction_abort (old_dir->i_sb);return err; }
fs/nilfs2/nilfs.h +2 -2
@@ -261,8 +261,8 @@ struct nilfs_dir_entry *nilfs_find_entry(struct inode *, const struct qstr *,int nilfs_delete_entry (struct nilfs_dir_entry *,struct folio *);int nilfs_empty_dir (struct inode *);struct nilfs_dir_entry *nilfs_dotdot (struct inode *,struct folio **); -void nilfs_set_link (struct inode *,struct nilfs_dir_entry *, -struct folio *,struct inode *); +int nilfs_set_link (struct inode *dir,struct nilfs_dir_entry *de, +struct folio *folio,struct inode *inode);/* file.c */ extern int nilfs_sync_file (struct file *,loff_t ,loff_t ,int );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 482/623 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suren Baghdasaryan <[email protected]>
[ Upstream commit 07438779313caafe52ac1a1a6958d735a5938988 ]
When memory allocation profiling is disabled there is no need to update current->alloc_tag and these manipulations add unnecessary overhead. Fix the overhead by skipping these extra updates.
I ran comprehensive testing on Pixel 6 on Big, Medium and Little cores:
Overhead before fixes Overhead after fixes
slab alloc page alloc slab alloc page alloc
Big 6.21% 5.32% 3.31% 4.93% Medium 4.51% 5.05% 3.79% 4.39% Little 7.62% 1.82% 6.68% 1.02%
This is an allocation microbenchmark doing allocations in a tight loop. Not a really realistic scenario and useful only to make performance comparisons.
--- include/linux/alloc_tag.h | 11 ++++++++--- lib/alloc_tag.c | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-)
include/linux/alloc_tag.h +8 -3
@@ -224,9 +224,14 @@ static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) {}#define alloc_hooks_tag (_tag, _do_alloc) \ ({ \ - struct alloc_tag * __maybe_unused _old = alloc_tag_save(_tag); \ - typeof(_do_alloc) _res = _do_alloc; \ - alloc_tag_restore(_tag, _old); \ + typeof(_do_alloc) _res; \ + if (mem_alloc_profiling_enabled()) { \ + struct alloc_tag * __maybe_unused _old; \ + _old = alloc_tag_save(_tag); \ + _res = _do_alloc; \ + alloc_tag_restore(_tag, _old); \ + } else \ + _res = _do_alloc; \ _res; \ })
lib/alloc_tag.c +2 -0
@@ -29,6 +29,8 @@ EXPORT_SYMBOL(_shared_alloc_tag);DEFINE_STATIC_KEY_MAYBE (CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT , mem_alloc_profiling_key); +EXPORT_SYMBOL (mem_alloc_profiling_key); +DEFINE_STATIC_KEY_FALSE (mem_profiling_compressed);struct alloc_tag_kernel_section kernel_tags = {NULL ,0 };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 483/623 module: Extend the preempt disabled section in dereference_symbol_descriptor().
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit a145c848d69f9c6f32008d8319edaa133360dd74 ]
dereference_symbol_descriptor() needs to obtain the module pointer belonging to pointer in order to resolve that pointer.
The returned mod pointer is obtained under RCU-sched/ preempt_disable() guarantees and needs to be used within this section to ensure that the module is not removed in the meantime.
Extend the preempt_disable() section to also cover dereference_module_function_descriptor().
--- include/linux/kallsyms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kallsyms.h +1 -1
@@ -57,10 +57,10 @@ static inline void *dereference_symbol_descriptor(void *ptr)preempt_disable (); mod =__module_address ((unsigned long )ptr); -preempt_enable ();if (mod) ptr =dereference_module_function_descriptor (mod, ptr); +preempt_enable ();#endif return ptr; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 484/623 module: Dont fail module loading when setting ro_after_init section RO failed
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 110b1e070f1d50f5217bd2c758db094998bb7b77 ]
Once module init has succeded it is too late to cancel loading. If setting ro_after_init data section to read-only fails, all we can do is to inform the user through a warning.
--- kernel/module/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/module/main.c +4 -3
@@ -2950,7 +2950,10 @@ static noinline int do_init_module(struct module *mod)#endif ret =module_enable_rodata_ro (mod, true);if (ret) - goto fail_mutex_unlock; +pr_warn ("%s: module_enable_rodata_ro_after_init() returned %d, " +"ro_after_init data might still be writable\n" , + mod->name, ret); +mod_tree_remove_init (mod);module_arch_freeing_init (mod); for_class_mod_mem_type(type, init) {
@@ -2989,8 +2992,6 @@ static noinline int do_init_module(struct module *mod)return 0 ; -fail_mutex_unlock: -mutex_unlock (&module_mutex); fail_free_freeinit:kfree (freeinit); fail:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 485/623 driver core: class: Fix wild pointer dereferences in API class_dev_iter_next()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit e128f82f7006991c99a58114f70ef61e937b1ac1 ]
There are a potential wild pointer dereferences issue regarding APIs class_dev_iter_(init|next|exit)(), as explained by below typical usage:
// All members of @iter are wild pointers.
struct class_dev_iter iter;
// class_dev_iter_init(@iter, @class, ...) checks parameter @class for // potential class_to_subsys() error, and it returns void type and does // not initialize its output parameter @iter, so caller can not detect // the error and continues to invoke class_dev_iter_next(@iter) even if // @iter still contains wild pointers. class_dev_iter_init(&iter, ...);
// Dereference these wild pointers in @iter here once suffer the error. while (dev = class_dev_iter_next(&iter)) { ... };
// Also dereference these wild pointers here.class_dev_iter_exit(&iter);
Actually, all callers of these APIs have such usage pattern in kernel tree. Fix by:
- Initialize output parameter @iter by memset() in class_dev_iter_init() and give callers prompt by pr_crit() for the error.
- Check if @iter is valid in class_dev_iter_next().
--- drivers/base/class.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/base/class.c +8 -1
@@ -323,8 +323,12 @@ void class_dev_iter_init(struct class_dev_iter *iter, const struct class *class,struct subsys_private *sp =class_to_subsys (class);struct klist_node *start_knode =NULL ; -if (!sp) +memset (iter,0 ,sizeof (*iter)); +if (!sp) { +pr_crit ("%s: class %p was not registered yet\n" , + __func__, class);return ; + }if (start) start_knode = &start->p->knode_class;
@@ -351,6 +355,9 @@ struct device *class_dev_iter_next(struct class_dev_iter *iter)struct klist_node *knode;struct device *dev; +if (!iter->sp) +return NULL ; +while (1 ) { knode =klist_next (&iter->ki);if (!knode)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 486/623 tty: mips_ejtag_fdc: fix one more u8 warning
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 6dd1de91e7a62bfd3878992c1db6e1d443022c76 ]
The LKP robot complains about:
drivers/tty/mips_ejtag_fdc.c:1224:31: error: incompatible pointer types passing 'const char *[1]' to parameter of type 'const u8 **' (aka 'const unsigned char **')
Fix this by turning the missing pieces (fetch from kgdbfdc_wbuf) to u8 too. Note the filling part (kgdbfdc_write_char()) already receives and stores u8 to kgdbfdc_wbuf.
--- drivers/tty/mips_ejtag_fdc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/mips_ejtag_fdc.c +2 -2
@@ -1154,7 +1154,7 @@ static char kgdbfdc_rbuf[4];/* write buffer to allow compaction */ static unsigned int kgdbfdc_wbuflen; -static char kgdbfdc_wbuf[4 ]; +static u8 kgdbfdc_wbuf[4 ];static void __iomem *kgdbfdc_setup (void ) {
@@ -1215,7 +1215,7 @@ static int kgdbfdc_read_char(void)/* push an FDC word from write buffer to TX FIFO */ static void kgdbfdc_push_one (void ) { -const char *bufs[1 ] = { kgdbfdc_wbuf }; +const u8 *bufs[1 ] = { kgdbfdc_wbuf };struct fdc_word word;void __iomem *regs;unsigned int i;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 487/623 serial: 8250: Adjust the timeout for FIFO mode
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit d91f98be26510f5f81ec66425bb0306d1ccd571a ]
After a console has written a record into UART_TX, it uses wait_for_xmitr() to wait until the data has been sent out before returning. However, wait_for_xmitr() will timeout after 10ms, regardless if the data has been transmitted or not.
For single bytes, this timeout is sufficient even at very slow baud rates, such as 1200bps. However, when FIFO mode is used, there may be 64 bytes pushed into the FIFO at once. At a baud rate of 115200bps, the 10ms timeout is still sufficient. But when using lower baud rates (such as 57600bps), the timeout is _not_ sufficient. This causes longer lines to be cut off, resulting in lost and horribly misformatted output on the console.
When using FIFO mode, take the number of bytes into account to determine an appropriate maximum timeout. Increasing the timeout does not affect performance since ideally the timeout never occurs.
--- drivers/tty/serial/8250/8250_port.c | 32 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_port.c +26 -6
@@ -2079,7 +2079,8 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state)serial8250_rpm_put (up); } -static void wait_for_lsr (struct uart_8250_port *up,int bits) +/* Returns true if @bits were set, false on timeout */ +static bool wait_for_lsr (struct uart_8250_port *up,int bits) {unsigned int status, tmout =10000 ;
@@ -2094,11 +2095,11 @@ static void wait_for_lsr(struct uart_8250_port *up, int bits)udelay (1 );touch_nmi_watchdog (); } + +return (tmout !=0 ); } -/* -* Wait for transmitter & holding register to empty -*/ +/* Wait for transmitter and holding register to empty with timeout */ static void wait_for_xmitr (struct uart_8250_port *up,int bits) {unsigned int tmout;
@@ -3317,6 +3318,16 @@ static void serial8250_console_restore(struct uart_8250_port *up)serial8250_out_MCR (up, up->mcr |UART_MCR_DTR |UART_MCR_RTS ); } +static void fifo_wait_for_lsr (struct uart_8250_port *up,unsigned int count) +{ +unsigned int i; + +for (i =0 ; i < count; i++) { +if (wait_for_lsr (up,UART_LSR_THRE )) +return ; + } +} +/* * Print a string to the serial port using the device FIFO *
@@ -3326,13 +3337,15 @@ static void serial8250_console_restore(struct uart_8250_port *up)static void serial8250_console_fifo_write (struct uart_8250_port *up,const char *s,unsigned int count) { -int i;const char *end = s + count;unsigned int fifosize = up->tx_loadsz; +unsigned int tx_count =0 ;bool cr_sent = false; +unsigned int i;while (s != end) { -wait_for_lsr (up,UART_LSR_THRE ); +/* Allow timeout for each byte of a possibly full FIFO */ +fifo_wait_for_lsr (up, fifosize);for (i =0 ; i < fifosize && s != end; ++i) {if (*s =='\n' && !cr_sent) {
@@ -3343,7 +3356,14 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up, cr_sent = false; } } + tx_count = i; } + +/* +* Allow timeout for each byte written since the caller will only wait +* for UART_LSR_BOTH_EMPTY using the timeout of a single character +*/ +fifo_wait_for_lsr (up, tx_count); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 488/623 nfs: fix incorrect error handling in LOCALIO
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Snitzer <[email protected]>
[ Upstream commit ead11ac50ad4b8ef1b64806e962ea984862d96ad ]
nfs4_stat_to_errno() expects a NFSv4 error code as an argument and returns a POSIX errno.
The problem is LOCALIO is passing nfs4_stat_to_errno() the POSIX errno return values from filp->f_op->read_iter(), filp->f_op->write_iter() and vfs_fsync_range().
So the POSIX errno that nfs_local_pgio_done() and nfs_local_commit_done() are passing to nfs4_stat_to_errno() are failing to match any NFSv4 error code, which results in nfs4_stat_to_errno() defaulting to returning -EREMOTEIO. This causes assertions in upper layers due to -EREMOTEIO not being a valid NFSv4 error code.
Fix this by updating nfs_local_pgio_done() and nfs_local_commit_done() to use the new nfs_localio_errno_to_nfs4_stat() to map a POSIX errno to an NFSv4 error code.
Care was taken to factor out nfs4_errtbl_common[] to avoid duplicating the same NFS error to errno table. nfs4_errtbl_common[] is checked first by both nfs4_stat_to_errno and nfs_localio_errno_to_nfs4_stat before they check their own more specialized tables (nfs4_errtbl[] and nfs4_errtbl_localio[] respectively).
While auditing the associated error mapping tables, the (ab)use of -1 for the last table entry was removed in favor of using ARRAY_SIZE to iterate the nfs_errtbl[] and nfs4_errtbl[]. And 'errno_NFSERR_IO' was removed because it caused needless obfuscation.
--- fs/nfs/localio.c | 4 +- fs/nfs_common/common.c | 89 +++++++++++++++++++++++++++++++++----- include/linux/nfs_common.h | 3 +- 3 files changed, 82 insertions(+), 14 deletions(-)
fs/nfs/localio.c +2 -2
@@ -328,7 +328,7 @@ nfs_local_pgio_done(struct nfs_pgio_header *hdr, long status) hdr->res.op_status =NFS4_OK ; hdr->task.tk_status =0 ; }else { - hdr->res.op_status =nfs4_stat_to_errno (status); + hdr->res.op_status =nfs_localio_errno_to_nfs4_stat (status); hdr->task.tk_status = status; } }
@@ -668,7 +668,7 @@ nfs_local_commit_done(struct nfs_commit_data *data, int status) data->task.tk_status =0 ; }else {nfs_reset_boot_verifier (data->inode); - data->res.op_status =nfs4_stat_to_errno (status); + data->res.op_status =nfs_localio_errno_to_nfs4_stat (status); data->task.tk_status = status; } }
fs/nfs_common/common.c +78 -11
143 lines not on this page · raw message
include/linux/nfs_common.h +2 -1
@@ -9,9 +9,10 @@#include <uapi/linux/nfs.h> /* Mapping from NFS error code to "errno" error code. */ -#define errno_NFSERR_IO EIOint nfs_stat_to_errno (enum nfs_stat status);int nfs4_stat_to_errno (int stat); +__u32 nfs_localio_errno_to_nfs4_stat (int errno); +#endif /* _LINUX_NFS_COMMON_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 489/623 NFSv4.2: fix COPY_NOTIFY xdr buf size calculation
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <[email protected]>
[ Upstream commit e8380c2d06055665b3df6c03964911375d7f9290 ]
We need to include sequence size in the compound.
--- fs/nfs/nfs42xdr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/nfs42xdr.c +2 -0
@@ -144,9 +144,11 @@ decode_putfh_maxsz + \ decode_offload_cancel_maxsz)#define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ encode_putfh_maxsz + \ encode_copy_notify_maxsz)#define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ decode_putfh_maxsz + \ decode_copy_notify_maxsz)#define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 490/623 NFSv4.2: mark OFFLOAD_CANCEL MOVEABLE
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <[email protected]>
[ Upstream commit 668135b9348c53fd205f5e07d11e82b10f31b55b ]
OFFLOAD_CANCEL should be marked MOVEABLE for when we need to move tasks off a non-functional transport.
--- fs/nfs/nfs42proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs42proc.c +1 -1
@@ -552,7 +552,7 @@ static int nfs42_do_offload_cancel_async(struct file *dst, .rpc_message = &msg, .callback_ops = &nfs42_offload_cancel_ops, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_MOVEABLE, };int status;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 491/623 LoongArch: Fix warnings during S3 suspend
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 26c0a2d93af55d30a46d5f45d3e9c42cde730168 ]
The enable_gpe_wakeup() function calls acpi_enable_all_wakeup_gpes(), and the later one may call the preempt_schedule_common() function, resulting in a thread switch and causing the CPU to be in an interrupt enabled state after the enable_gpe_wakeup() function returns, leading to the warnings as follow.
[ C0] WARNING: ... at kernel/time/timekeeping.c:845 ktime_get+0xbc/0xc8
[ C0] ...
[ C0] Call Trace:
[ C0] [<90000000002243b4>] show_stack+0x64/0x188
[ C0] [<900000000164673c>] dump_stack_lvl+0x60/0x88
[ C0] [<90000000002687e4>] __warn+0x8c/0x148
[ C0] [<90000000015e9978>] report_bug+0x1c0/0x2b0
[ C0] [<90000000016478e4>] do_bp+0x204/0x3b8
[ C0] [<90000000025b1924>] exception_handlers+0x1924/0x10000 [ C0] [<9000000000343bbc>] ktime_get+0xbc/0xc8
[ C0] [<9000000000354c08>] tick_sched_timer+0x30/0xb0
[ C0] [<90000000003408e0>] __hrtimer_run_queues+0x160/0x378 [ C0] [<9000000000341f14>] hrtimer_interrupt+0x144/0x388
[ C0] [<9000000000228348>] constant_timer_interrupt+0x38/0x48 [ C0] [<90000000002feba4>] __handle_irq_event_percpu+0x64/0x1e8 [ C0] [<90000000002fed48>] handle_irq_event_percpu+0x20/0x80 [ C0] [<9000000000306b9c>] handle_percpu_irq+0x5c/0x98
[ C0] [<90000000002fd4a0>] generic_handle_domain_irq+0x30/0x48 [ C0] [<9000000000d0c7b0>] handle_cpu_irq+0x70/0xa8
[ C0] [<9000000001646b30>] handle_loongarch_irq+0x30/0x48
[ C0] [<9000000001646bc8>] do_vint+0x80/0xe0
[ C0] [<90000000002aea1c>] finish_task_switch.isra.0+0x8c/0x2a8 [ C0] [<900000000164e34c>] __schedule+0x314/0xa48
[ C0] [<900000000164ead8>] schedule+0x58/0xf0
[ C0] [<9000000000294a2c>] worker_thread+0x224/0x498
[ C0] [<900000000029d2f0>] kthread+0xf8/0x108
[ C0] [<9000000000221f28>] ret_from_kernel_thread+0xc/0xa4
[ C0]
[ C0] ---[ end trace 0000000000000000 ]---
The root cause is acpi_enable_all_wakeup_gpes() uses a mutex to protect acpi_hw_enable_all_wakeup_gpes(), and acpi_ut_acquire_mutex() may cause a thread switch. Since there is no longer concurrent execution during loongarch_acpi_suspend(), we can call acpi_hw_enable_all_wakeup_gpes() directly in enable_gpe_wakeup().
The solution is similar to commit 22db06337f590d01 ("ACPI: sleep: Avoid breaking S3 wakeup due to might_sleep()").
--- arch/loongarch/power/platform.c | 2 +- drivers/acpi/acpica/achware.h | 2 -- include/acpi/acpixf.h | 1 + 3 files changed, 2 insertions(+), 3 deletions(-)
arch/loongarch/power/platform.c +1 -1
@@ -17,7 +17,7 @@ void enable_gpe_wakeup(void)if (acpi_gbl_reduced_hardware)return ; -acpi_enable_all_wakeup_gpes (); +acpi_hw_enable_all_wakeup_gpes (); }void enable_pci_wakeup (void )
drivers/acpi/acpica/achware.h +0 -2
@@ -103,8 +103,6 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,acpi_status acpi_hw_enable_all_runtime_gpes (void ); -acpi_status acpi_hw_enable_all_wakeup_gpes (void ); -u8 acpi_hw_check_all_gpes (acpi_handle gpe_skip_device,u32 gpe_skip_number); acpi_status
include/acpi/acpixf.h +1 -0
@@ -763,6 +763,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status *event_status)) ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_dispatch_gpe(acpi_handle gpe_device, u32 gpe_number)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_hw_disable_all_gpes(void)) +ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_hw_enable_all_wakeup_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 492/623 tools/bootconfig: Fix the wrong format specifier
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luo Yifan <[email protected]>
[ Upstream commit f6ab7384d554ba80ff4793259d75535874b366f5 ]
Use '%u' instead of '%d' for unsigned int.
--- tools/bootconfig/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/bootconfig/main.c +2 -2
@@ -226,7 +226,7 @@ static int load_xbc_from_initrd(int fd, char **buf)/* Wrong Checksum */ rcsum =xbc_calc_checksum (*buf, size);if (csum != rcsum) { -pr_err ("checksum error: %d != %d\n" , csum, rcsum); +pr_err ("checksum error: %u != %u\n" , csum, rcsum);return -EINVAL ; }
@@ -395,7 +395,7 @@ static int apply_xbc(const char *path, const char *xbc_path)xbc_get_info (&ret,NULL );printf ("\tNumber of nodes: %d\n" , ret);printf ("\tSize: %u bytes\n" , (unsigned int )size); -printf ("\tChecksum: %d\n" , (unsigned int )csum); +printf ("\tChecksum: %u\n" , (unsigned int )csum);/* TODO: Check the options by schema */ xbc_exit ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 493/623 xfrm: replay: Fix the update of replay_esn->oseq_hi for GSO
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianbo Liu <[email protected]>
[ Upstream commit c05c5e5aa163f4682ca97a2f0536575fc7dbdecb ]
When skb needs GSO and wrap around happens, if xo->seq.low (seqno of the first skb segment) is before the last seq number but oseq (seqno of the last segment) is after it, xo->seq.low is still bigger than replay_esn->oseq while oseq is smaller than it, so the update of replay_esn->oseq_hi is missed for this case wrap around because of the change in the cited commit.
For example, if sending a packet with gso_segs=3 while old replay_esn->oseq=0xfffffffe, we calculate:
xo->seq.low = 0xfffffffe + 1 = 0x0xffffffff
oseq = 0xfffffffe + 3 = 0x1(oseq < replay_esn->oseq) is true, but (xo->seq.low < replay_esn->oseq) is false, so replay_esn->oseq_hi is not incremented.
To fix this issue, change the outer checking back for the update of replay_esn->oseq_hi. And add new checking inside for the update of packet's oseq_hi.
--- net/xfrm/xfrm_replay.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/xfrm/xfrm_replay.c +6 -4
@@ -714,10 +714,12 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff oseq +=skb_shinfo (skb)->gso_segs; } -if (unlikely (xo->seq.low < replay_esn->oseq)) { -XFRM_SKB_CB (skb)->seq.output.hi = ++oseq_hi; - xo->seq.hi = oseq_hi; - replay_esn->oseq_hi = oseq_hi; +if (unlikely (oseq < replay_esn->oseq)) { + replay_esn->oseq_hi = ++oseq_hi; +if (xo->seq.low < replay_esn->oseq) { +XFRM_SKB_CB (skb)->seq.output.hi = oseq_hi; + xo->seq.hi = oseq_hi; + }if (replay_esn->oseq_hi ==0 ) { replay_esn->oseq--; replay_esn->oseq_hi--;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 494/623 xfrm: state: fix out-of-bounds read during lookup
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit e952837f3ddb0ff726d5b582aa1aad9aa38d024d ]
lookup and resize can run in parallel.
The xfrm_state_hash_generation seqlock ensures a retry, but the hash functions can observe a hmask value that is too large for the new hlist array.
rehash does:
rcu_assign_pointer(net->xfrm.state_bydst, ndst) [..] net->xfrm.state_hmask = nhashmask;
While state lookup does:
h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h, bydst) {
This is only safe in case the update to state_bydst is larger than net->xfrm.xfrm_state_hmask (or if the lookup function gets serialized via state spinlock again).
Fix this by prefetching state_hmask and the associated pointers. The xfrm_state_hash_generation seqlock retry will ensure that the pointer and the hmask will be consistent.
The existing helpers, like xfrm_dst_hash(), are now unsafe for RCU side, add lockdep assertions to document that they are only safe for insert side.
xfrm_state_lookup_byaddr() uses the spinlock rather than RCU. AFAICS this is an oversight from back when state lookup was converted to RCU, this lock should be replaced with RCU in a future patch.
--- net/xfrm/xfrm_state.c | 89 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 19 deletions(-)
net/xfrm/xfrm_state.c +70 -19
@@ -34,6 +34,8 @@#define xfrm_state_deref_prot (table, net) \ rcu_dereference_protected((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock)) +#define xfrm_state_deref_check (table, net) \ + rcu_dereference_check((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock))static void xfrm_state_gc_task (struct work_struct *work);
@@ -62,6 +64,8 @@ static inline unsigned int xfrm_dst_hash(struct net *net, u32 reqid, unsigned short family) { +lockdep_assert_held (&net->xfrm.xfrm_state_lock); +return __xfrm_dst_hash (daddr, saddr, reqid, family, net->xfrm.state_hmask); }
@@ -70,6 +74,8 @@ static inline unsigned int xfrm_src_hash(struct net *net,const xfrm_address_t *saddr, unsigned short family) { + lockdep_assert_held(&net->xfrm.xfrm_state_lock); +return __xfrm_src_hash (daddr, saddr, family, net->xfrm.state_hmask); }
@@ -77,11 +83,15 @@ static inline unsigned int xfrm_spi_hash(struct net *net, const xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family) { + lockdep_assert_held(&net->xfrm.xfrm_state_lock); +return __xfrm_spi_hash (daddr, spi, proto, family, net->xfrm.state_hmask); }static unsigned int xfrm_seq_hash (struct net *net,u32 seq) { +lockdep_assert_held (&net->xfrm.xfrm_state_lock); +return __xfrm_seq_hash (seq, net->xfrm.state_hmask); }
@@ -1041,16 +1051,38 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl, x->props.family = tmpl->encap_family; } -static struct xfrm_state *__xfrm_state_lookup_all (struct net *net,u32 mark, +struct xfrm_hash_state_ptrs { +const struct hlist_head *bydst; +const struct hlist_head *bysrc; +const struct hlist_head *byspi; +unsigned int hmask; +}; + +static void xfrm_hash_ptrs_get (const struct net *net,struct xfrm_hash_state_ptrs *ptrs) +{ +unsigned int sequence; + +do { + sequence =read_seqcount_begin (&net->xfrm.xfrm_state_hash_generation); + + ptrs->bydst =xfrm_state_deref_check (net->xfrm.state_bydst, net); + ptrs->bysrc =xfrm_state_deref_check (net->xfrm.state_bysrc, net); + ptrs->byspi =xfrm_state_deref_check (net->xfrm.state_byspi, net); + ptrs->hmask = net->xfrm.state_hmask; + }while (read_seqcount_retry (&net->xfrm.xfrm_state_hash_generation, sequence)); +} + +static struct xfrm_state *__xfrm_state_lookup_all (const struct xfrm_hash_state_ptrs *state_ptrs, +u32 mark,const xfrm_address_t *daddr,__be32 spi,u8 proto,unsigned short family,struct xfrm_dev_offload *xdo) { -unsigned int h =xfrm_spi_hash (net, daddr, spi, proto, family); +unsigned int h =__xfrm_spi_hash (daddr, spi, proto, family, state_ptrs->hmask);struct xfrm_state *x; -hlist_for_each_entry_rcu (x, net->xfrm.state_byspi + h, byspi) { +hlist_for_each_entry_rcu (x, state_ptrs->byspi + h, byspi) {#ifdef CONFIG_XFRM_OFFLOAD if (xdo->type ==XFRM_DEV_OFFLOAD_PACKET ) {if (x->xso.type !=XFRM_DEV_OFFLOAD_PACKET )
@@ -1084,15 +1116,16 @@ static struct xfrm_state *__xfrm_state_lookup_all(struct net *net, u32 mark,return NULL ; } -static struct xfrm_state *__xfrm_state_lookup (struct net *net,u32 mark, +static struct xfrm_state *__xfrm_state_lookup (const struct xfrm_hash_state_ptrs *state_ptrs, +u32 mark,const xfrm_address_t *daddr,__be32 spi,u8 proto,unsigned short family) { -unsigned int h =xfrm_spi_hash (net, daddr, spi, proto, family); +unsigned int h =__xfrm_spi_hash (daddr, spi, proto, family, state_ptrs->hmask);struct xfrm_state *x; -hlist_for_each_entry_rcu (x, net->xfrm.state_byspi + h, byspi) { +hlist_for_each_entry_rcu (x, state_ptrs->byspi + h, byspi) { if (x->props.family != family || x->id.spi != spi || x->id.proto != proto ||
@@ -1114,6 +1147,7 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, __be32 spi, u8 proto, unsigned short family) { + struct xfrm_hash_state_ptrs state_ptrs;struct hlist_head *state_cache_input;struct xfrm_state *x =NULL ;int cpu =get_cpu ();
@@ -1135,7 +1169,9 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, goto out; } - x =__xfrm_state_lookup (net, mark, daddr, spi, proto, family); +xfrm_hash_ptrs_get (net, &state_ptrs); + + x =__xfrm_state_lookup (&state_ptrs, mark, daddr, spi, proto, family);if (x && x->km.state ==XFRM_STATE_VALID ) {spin_lock_bh (&net->xfrm.xfrm_state_lock);
@@ -1155,15 +1191,16 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, }EXPORT_SYMBOL (xfrm_input_state_lookup); -static struct xfrm_state *__xfrm_state_lookup_byaddr (struct net *net,u32 mark, +static struct xfrm_state *__xfrm_state_lookup_byaddr (const struct xfrm_hash_state_ptrs *state_ptrs, +u32 mark,const xfrm_address_t *daddr,const xfrm_address_t *saddr,u8 proto,unsigned short family) { -unsigned int h =xfrm_src_hash (net, daddr, saddr, family); +unsigned int h =__xfrm_src_hash (daddr, saddr, family, state_ptrs->hmask);struct xfrm_state *x; -hlist_for_each_entry_rcu (x, net->xfrm.state_bysrc + h, bysrc) { +hlist_for_each_entry_rcu (x, state_ptrs->bysrc + h, bysrc) { if (x->props.family != family || x->id.proto != proto || !xfrm_addr_equal(&x->id.daddr, daddr, family) ||
@@ -1183,14 +1220,17 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(struct net *net, u32 mark,static inline struct xfrm_state *__xfrm_state_locate (struct xfrm_state *x,int use_spi,int family) { +struct xfrm_hash_state_ptrs state_ptrs;struct net *net =xs_net (x);u32 mark = x->mark.v & x->mark.m; +xfrm_hash_ptrs_get (net, &state_ptrs); +if (use_spi) -return __xfrm_state_lookup (net, mark, &x->id.daddr, +return __xfrm_state_lookup (&state_ptrs, mark, &x->id.daddr, x->id.spi, x->id.proto, family);else -return __xfrm_state_lookup_byaddr (net, mark, +return __xfrm_state_lookup_byaddr (&state_ptrs, mark, &x->id.daddr, &x->props.saddr, x->id.proto, family);
@@ -1264,6 +1304,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr, unsigned short family, u32 if_id) {static xfrm_address_t saddr_wildcard = { }; +struct xfrm_hash_state_ptrs state_ptrs;struct net *net =xp_net (pol);unsigned int h, h_wildcard;struct xfrm_state *x, *x0, *to_put;
@@ -1328,8 +1369,10 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,else if (acquire_in_progress)/* XXX: acquire_in_progress should not happen */ WARN_ON (1 ); - h =xfrm_dst_hash (net, daddr, saddr, tmpl->reqid, encap_family); -hlist_for_each_entry_rcu (x, net->xfrm.state_bydst + h, bydst) { +xfrm_hash_ptrs_get (net, &state_ptrs); + + h =__xfrm_dst_hash (daddr, saddr, tmpl->reqid, encap_family, state_ptrs.hmask); +hlist_for_each_entry_rcu (x, state_ptrs.bydst + h, bydst) {#ifdef CONFIG_XFRM_OFFLOAD if (pol->xdo.type ==XFRM_DEV_OFFLOAD_PACKET ) {if (x->xso.type !=XFRM_DEV_OFFLOAD_PACKET )
@@ -1362,8 +1405,9 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,if (best || acquire_in_progress) goto found; - h_wildcard =xfrm_dst_hash (net, daddr, &saddr_wildcard, tmpl->reqid, encap_family); -hlist_for_each_entry_rcu (x, net->xfrm.state_bydst + h_wildcard, bydst) { + h_wildcard =__xfrm_dst_hash (daddr, &saddr_wildcard, tmpl->reqid, + encap_family, state_ptrs.hmask); +hlist_for_each_entry_rcu (x, state_ptrs.bydst + h_wildcard, bydst) {#ifdef CONFIG_XFRM_OFFLOAD if (pol->xdo.type ==XFRM_DEV_OFFLOAD_PACKET ) {if (x->xso.type !=XFRM_DEV_OFFLOAD_PACKET )
@@ -1401,7 +1445,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,if (!x && !error && !acquire_in_progress) {if (tmpl->id.spi && - (x0 =__xfrm_state_lookup_all (net, mark, daddr, + (x0 =__xfrm_state_lookup_all (&state_ptrs, mark, daddr, tmpl->id.spi, tmpl->id.proto, encap_family, &pol->xdo)) !=NULL ) {
@@ -2180,10 +2224,13 @@ struct xfrm_state * xfrm_state_lookup(struct net *net, u32 mark, const xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family) { + struct xfrm_hash_state_ptrs state_ptrs;struct xfrm_state *x;rcu_read_lock (); - x =__xfrm_state_lookup (net, mark, daddr, spi, proto, family); +xfrm_hash_ptrs_get (net, &state_ptrs); + + x =__xfrm_state_lookup (&state_ptrs, mark, daddr, spi, proto, family);rcu_read_unlock ();return x; }
@@ -2194,10 +2241,14 @@ xfrm_state_lookup_byaddr(struct net *net, u32 mark, const xfrm_address_t *daddr, const xfrm_address_t *saddr, u8 proto, unsigned short family) { + struct xfrm_hash_state_ptrs state_ptrs;struct xfrm_state *x;spin_lock_bh (&net->xfrm.xfrm_state_lock); - x =__xfrm_state_lookup_byaddr (net, mark, daddr, saddr, proto, family); + +xfrm_hash_ptrs_get (net, &state_ptrs); + + x =__xfrm_state_lookup_byaddr (&state_ptrs, mark, daddr, saddr, proto, family);spin_unlock_bh (&net->xfrm.xfrm_state_lock);return x; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 495/623 phy: freescale: fsl-samsung-hdmi: Clean up fld_tg_code calculation
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Ford <[email protected]>
[ Upstream commit d567679f2b6a8bcea20589bbea6488c0236886cd ]
Currently, the calcuation for fld_tg_code is based on a lookup table, but there are gaps in the lookup table, and frequencies in these gaps may not properly use the correct divider. Based on the description of FLD_CK_DIV, the internal PLL frequency should be less than 50 MHz, so directly calcuate the value of FLD_CK_DIV from pixclk. This allow for proper calcuation of any pixel clock and eliminates a few gaps in the LUT.
Since the value of the int_pllclk is in Hz, do the fixed-point math in Hz to achieve a more accurate value and reduces the complexity of the caluation to 24MHz * (256 / int_pllclk).
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 32 +++++++------------- 1 file changed, 11 insertions(+), 21 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +11 -21
@@ -331,25 +331,17 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy, {u32 pclk = cfg->pixclk;u32 fld_tg_code; -u32 pclk_khz; -u8 div =1 ; - -switch (cfg->pixclk) { - case 22250000 ... 47500000: - div =1 ; -break ; - case 50349650 ... 99000000: - div =2 ; -break ; - case 100699300 ... 198000000: - div =4 ; -break ; - case 205000000 ... 297000000: - div =8 ; -break ; +u32 int_pllclk; +u8 div; + +/* Find int_pllclk speed */ +for (div =0 ; div <4 ; div++) { + int_pllclk = pclk / (1 << div); +if (int_pllclk < (50 *MHZ )) +break ; } -writeb (FIELD_PREP (REG12_CK_DIV_MASK ,ilog2 (div)), phy->regs +PHY_REG (12 )); +writeb (FIELD_PREP (REG12_CK_DIV_MASK , div), phy->regs +PHY_REG (12 ));/* * Calculation for the frequency lock detector target code (fld_tg_code)
@@ -362,10 +354,8 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,* settings rounding up always too. TODO: Check if that is * correct. */ - pclk /= div; - pclk_khz = pclk /1000 ; - fld_tg_code =256 *1000 *1000 / pclk_khz *24 ; - fld_tg_code =DIV_ROUND_UP (fld_tg_code,1000 ); + + fld_tg_code =DIV_ROUND_UP (24 *MHZ *256 , int_pllclk);/* FLD_TOL and FLD_RP_CODE taken from downstream driver */ writeb(FIELD_PREP(REG13_TG_CODE_LOW_MASK, fld_tg_code),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 496/623 dmaengine: ti: edma: fix OF node reference leaks in edma_driver
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit e883c64778e5a9905fce955681f8ee38c7197e0f ]
The .probe() of edma_driver calls of_parse_phandle_with_fixed_args() but does not release the obtained OF nodes. Thus add a of_node_put() call.
This bug was found by an experimental verification tool that I am developing.
--- drivers/dma/ti/edma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/ti/edma.c +1 -2
@@ -208,7 +208,6 @@ struct edma_desc {struct edma_cc ;struct edma_tc { -struct device_node *node;u16 id; };
@@ -2466,13 +2465,13 @@ static int edma_probe(struct platform_device *pdev)if (ret || i == ecc->num_tc)break ; - ecc->tc_list[i].node = tc_args.np; ecc->tc_list[i].id = i; queue_priority_mapping[i][1 ] = tc_args.args[0 ];if (queue_priority_mapping[i][1 ] > lowest_priority) { lowest_priority = queue_priority_mapping[i][1 ]; info->default_queue = i; } +of_node_put (tc_args.np); }/* See if we have optional dma-channel-mask array */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 497/623 xfrm: delete intermediate secpath entry in packet offload mode
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Cassen <[email protected]>
[ Upstream commit 600258d555f0710b9c47fb78d2d80a4aecd608cc ]
Packets handled by hardware have added secpath as a way to inform XFRM core code that this path was already handled. That secpath is not needed at all after policy is checked and it is removed later in the stack.
However, in the case of IP forwarding is enabled (/proc/sys/net/ipv4/ip_forward), that secpath is not removed and packets which already were handled are reentered to the driver TX path with xfrm_offload set.
The following kernel panic is observed in mlx5 in such case:
mlx5_core 0000:04:00.0 enp4s0f0np0: Link up
mlx5_core 0000:04:00.1 enp4s0f1np1: Link up
Initializing XFRM netlink socket
IPsec XFRM device driver
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 0 P4D 0 Oops: Oops: 0010 [#1] PREEMPT SMP CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.13.0-rc1-alex #3 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 0018:ffffb87380003800 EFLAGS: 00010206 RAX: ffff8df004e02600 RBX: ffffb873800038d8 RCX: 00000000ffff98cf RDX: ffff8df00733e108 RSI: ffff8df00521fb80 RDI: ffff8df001661f00 RBP: ffffb87380003850 R08: ffff8df013980000 R09: 0000000000000010 R10: 0000000000000002 R11: 0000000000000002 R12: ffff8df001661f00 R13: ffff8df00521fb80 R14: ffff8df00733e108 R15: ffff8df011faf04e FS: 0000000000000000(0000) GS:ffff8df46b800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000106384000 CR4: 0000000000350ef0 Call Trace: <IRQ> ? show_regs+0x63/0x70 ? __die_body+0x20/0x60 ? __die+0x2b/0x40 ? page_fault_oops+0x15c/0x550 ? do_user_addr_fault+0x3ed/0x870 ? exc_page_fault+0x7f/0x190 ? asm_exc_page_fault+0x27/0x30 mlx5e_ipsec_handle_tx_skb+0xe7/0x2f0 [mlx5_core] mlx5e_xmit+0x58e/0x1980 [mlx5_core] ? __fib_lookup+0x6a/0xb0 dev_hard_start_xmit+0x82/0x1d0 sch_direct_xmit+0xfe/0x390 __dev_queue_xmit+0x6d8/0xee0 ? __fib_lookup+0x6a/0xb0 ? internal_add_timer+0x48/0x70 ? mod_timer+0xe2/0x2b0 neigh_resolve_output+0x115/0x1b0 __neigh_update+0x26a/0xc50 neigh_update+0x14/0x20 arp_process+0x2cb/0x8e0 ? __napi_build_skb+0x5e/0x70 arp_rcv+0x11e/0x1c0 ? dev_gro_receive+0x574/0x820 __netif_receive_skb_list_core+0x1cf/0x1f0 netif_receive_skb_list_internal+0x183/0x2a0 napi_complete_done+0x76/0x1c0 mlx5e_napi_poll+0x234/0x7a0 [mlx5_core] __napi_poll+0x2d/0x1f0 net_rx_action+0x1a6/0x370 ? atomic_notifier_call_chain+0x3b/0x50 ? irq_int_handler+0x15/0x20 [mlx5_core] handle_softirqs+0xb9/0x2f0 ? handle_irq_event+0x44/0x60 irq_exit_rcu+0xdb/0x100 common_interrupt+0x98/0xc0 </IRQ> <TASK> asm_common_interrupt+0x27/0x40 RIP: 0010:pv_native_safe_halt+0xb/0x10 Code: 09 c3 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 0f 22 0f 1f 84 00 00 00 00 00 90 eb 07 0f 00 2d 7f e9 36 00 fb
40 00 83 ff 07 77 21 89 ff ff 24 fd 88 3d a1 bd 0f 21 f8
RSP: 0018:ffffffffbe603de8 EFLAGS: 00000202
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000f92f46680
RDX: 0000000000000037 RSI: 00000000ffffffff RDI: 00000000000518d4
RBP: ffffffffbe603df0 R08: 000000cd42e4dffb R09: ffffffffbe603d70
R10: 0000004d80d62680 R11: 0000000000000001 R12: ffffffffbe60bf40
R13: 0000000000000000 R14: 0000000000000000 R15: ffffffffbe60aff8
? default_idle+0x9/0x20 arch_cpu_idle+0x9/0x10 default_idle_call+0x29/0xf0 do_idle+0x1f2/0x240 cpu_startup_entry+0x2c/0x30 rest_init+0xe7/0x100 start_kernel+0x76b/0xb90 x86_64_start_reservations+0x18/0x30 x86_64_start_kernel+0xc0/0x110 ? setup_ghcb+0xe/0x130 common_startup_64+0x13e/0x141 </TASK> Modules linked in: esp4_offload esp4 xfrm_interface
xfrm6_tunnel tunnel4 tunnel6 xfrm_user xfrm_algo binfmt_misc intel_rapl_msr intel_rapl_common kvm_amd ccp kvm input_leds serio_raw qemu_fw_cfg sch_fq_codel dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua efi_pstore ip_tables x_tables autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq raid6_pq async_xor xor async_tx libcrc32c raid1 raid0 mlx5_core crct10dif_pclmul crc32_pclmul polyval_clmulni polyval_generic ghash_clmulni_intel sha256_ssse3 sha1_ssse3 ahci mlxfw i2c_i801 libahci i2c_mux i2c_smbus psample virtio_rng pci_hyperv_intf aesni_intel crypto_simd cryptd
CR2: 0000000000000000
---[ end trace 0000000000000000 ]--- RIP: 0010:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 0018:ffffb87380003800 EFLAGS: 00010206 RAX: ffff8df004e02600 RBX: ffffb873800038d8 RCX: 00000000ffff98cf RDX: ffff8df00733e108 RSI: ffff8df00521fb80 RDI: ffff8df001661f00 RBP: ffffb87380003850 R08: ffff8df013980000 R09: 0000000000000010 R10: 0000000000000002 R11: 0000000000000002 R12: ffff8df001661f00 R13: ffff8df00521fb80 R14: ffff8df00733e108 R15: ffff8df011faf04e FS: 0000000000000000(0000) GS:ffff8df46b800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 0000000106384000 CR4: 0000000000350ef0 Kernel panic - not syncing: Fatal exception in interrupt Kernel Offset: 0x3b800000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
--- include/net/xfrm.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
include/net/xfrm.h +13 -3
@@ -1224,9 +1224,19 @@ static inline int __xfrm_policy_check2(struct sock *sk, int dir,if (xo) { x =xfrm_input_state (skb); -if (x->xso.type ==XFRM_DEV_OFFLOAD_PACKET ) -return (xo->flags &CRYPTO_DONE ) && - (xo->status &CRYPTO_SUCCESS ); +if (x->xso.type ==XFRM_DEV_OFFLOAD_PACKET ) { +bool check = (xo->flags &CRYPTO_DONE ) && + (xo->status &CRYPTO_SUCCESS ); + +/* The packets here are plain ones and secpath was +* needed to indicate that hardware already handled +* them and there is no need to do nothing in addition. +* +* Consume secpath which was set by drivers. +*/ +secpath_reset (skb); +return check; + } } return __xfrm_check_nopolicy(net, skb, dir) ||
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 498/623 rtc: tps6594: Fix integer overflow on 32bit systems
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 09c4a610153286cef54d4f0c85398f4e32fc227e ]
The problem is this multiply in tps6594_rtc_set_offset()
tmp = offset * TICKS_PER_HOUR;
The "tmp" variable is an s64 but "offset" is a long in the (-277774)-277774 range. On 32bit systems a long can hold numbers up to approximately two billion. The number of TICKS_PER_HOUR is really large, (32768 * 3600) or roughly a hundred million. When you start multiplying by a hundred million it doesn't take long to overflow the two billion mark.
Probably the safest way to fix this is to change the type of TICKS_PER_HOUR to long long because it's such a large number.
--- drivers/rtc/rtc-tps6594.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-tps6594.c +1 -1
@@ -37,7 +37,7 @@#define MAX_OFFSET (277774)// Number of ticks per hour -#define TICKS_PER_HOUR (32768 * 3600) +#define TICKS_PER_HOUR (32768 * 3600LL)// Multiplier for ppb conversions #define PPB_MULT NANO
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 499/623 rtc: pcf85063: fix potential OOB write in PCF85063 NVMEM read
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksij Rempel <[email protected]>
[ Upstream commit 3ab8c5ed4f84fa20cd16794fe8dc31f633fbc70c ]
The nvmem interface supports variable buffer sizes, while the regmap interface operates with fixed-size storage. If an nvmem client uses a buffer size less than 4 bytes, regmap_read will write out of bounds as it expects the buffer to point at an unsigned int.
Fix this by using an intermediary unsigned int to hold the value.
--- drivers/rtc/rtc-pcf85063.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/rtc/rtc-pcf85063.c +10 -1
@@ -322,7 +322,16 @@ static const struct rtc_class_ops pcf85063_rtc_ops = {static int pcf85063_nvmem_read (void *priv,unsigned int offset,void *val,size_t bytes) { -return regmap_read (priv,PCF85063_REG_RAM , val); +unsigned int tmp; +int ret; + + ret =regmap_read (priv,PCF85063_REG_RAM , &tmp); +if (ret <0 ) +return ret; + + *(u8 *)val = tmp; + +return 0 ; } static int pcf85063_nvmem_write(void *priv, unsigned int offset,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 500/623 rtc: loongson: clear TOY_MATCH0_REG in loongson_rtc_isr()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Wang <[email protected]>
[ Upstream commit 09471d8f5b390883eaf21b917c4bf3ced1b8a1df ]
The TOY_MATCH0_REG should be cleared to 0 in the RTC interrupt handler, otherwise the interrupt cannot be cleared, which will cause the loongson_rtc_isr() to be triggered multiple times.
The previous code cleared TOY_MATCH0_REG in the loongson_rtc_handler(), which is an ACPI interrupt. This did not prevent loongson_rtc_isr() from being triggered multiple times.
This commit moves the clearing of TOY_MATCH0_REG to the loongson_rtc_isr() to ensure that the interrupt is properly cleared.
--- drivers/rtc/rtc-loongson.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/rtc/rtc-loongson.c +8 -5
@@ -114,6 +114,13 @@ static irqreturn_t loongson_rtc_isr(int irq, void *id)struct loongson_rtc_priv *priv = (struct loongson_rtc_priv *)id;rtc_update_irq (priv->rtcdev,1 ,RTC_AF |RTC_IRQF ); + +/* +* The TOY_MATCH0_REG should be cleared 0 here, +* otherwise the interrupt cannot be cleared. +*/ +regmap_write (priv->regmap,TOY_MATCH0_REG ,0 ); +return IRQ_HANDLED ; }
@@ -131,11 +138,7 @@ static u32 loongson_rtc_handler(void *id)writel (RTC_STS , priv->pm_base +PM1_STS_REG );spin_unlock (&priv->lock); -/* -* The TOY_MATCH0_REG should be cleared 0 here, -* otherwise the interrupt cannot be cleared. -*/ -return regmap_write (priv->regmap,TOY_MATCH0_REG ,0 ); +return ACPI_INTERRUPT_HANDLED ; }static int loongson_rtc_set_enabled (struct device *dev)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 501/623 ubi: Revert "ubi: wl: Close down wear-leveling before nand is suspended"
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 844c6fdc13cf3d9d251533631988a58f8356a8c8 ]
Commit 5580cdae05ae ("ubi: wl: Close down wear-leveling before nand is suspended") added a reboot notification in UBI layer to shutdown the wear-leveling subsystem, which imported an UAF problem[1]. Besides that, the method also brings other potential UAF problems, for example:
reboot kworker
ubi_wl_reboot_notifier
ubi_wl_close
ubi_fastmap_close
kfree(ubi->fm)
update_fastmap_work_fn
ubi_update_fastmap
old_fm = ubi->fm
if (old_fm && old_fm->e[i]) // UAF!Actually, the problem fixed by commit 5580cdae05ae ("ubi: wl: Close down wear-leveling before nand is suspended") has been solved by commit 8cba323437a4 ("mtd: rawnand: protect access to rawnand devices while in suspend"), which was discussed in [2]. So we can revert the commit 5580cdae05ae ("ubi: wl: Close down wear-leveling before nand is suspended") directly.
[1] https://lore.kernel.org/linux-mtd/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
--- drivers/mtd/ubi/ubi.h | 2 -- drivers/mtd/ubi/wl.c | 21 --------------------- 2 files changed, 23 deletions(-)
drivers/mtd/ubi/ubi.h +0 -2
@@ -549,7 +549,6 @@ struct ubi_debug_info {* @peb_buf: a buffer of PEB size used for different purposes * @buf_mutex: protects @peb_buf * @ckvol_mutex: serializes static volume checking when opening -* @wl_reboot_notifier: close all wear-leveling work before reboot * * @dbg: debugging information for this UBI device */
@@ -652,7 +651,6 @@ struct ubi_device {void *peb_buf;struct mutex buf_mutex;struct mutex ckvol_mutex; -struct notifier_block wl_reboot_notifier;struct ubi_debug_info dbg; };
drivers/mtd/ubi/wl.c +0 -21
@@ -89,7 +89,6 @@#include <linux/crc32.h> #include <linux/freezer.h> #include <linux/kthread.h> -#include <linux/reboot.h> #include "ubi.h" #include "wl.h"
@@ -128,8 +127,6 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi, struct ubi_wl_entry *e, struct rb_root *root);static int self_check_in_pq (const struct ubi_device *ubi,struct ubi_wl_entry *e); -static int ubi_wl_reboot_notifier (struct notifier_block *n, -unsigned long state,void *cmd);/** * wl_tree_add - add a wear-leveling entry to a WL RB-tree.
@@ -1953,13 +1950,6 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)if (!ubi->ro_mode && !ubi->fm_disabled)ubi_ensure_anchor_pebs (ubi);#endif - -if (!ubi->wl_reboot_notifier.notifier_call) { - ubi->wl_reboot_notifier.notifier_call = ubi_wl_reboot_notifier; - ubi->wl_reboot_notifier.priority =1 ;/* Higher than MTD */ -register_reboot_notifier (&ubi->wl_reboot_notifier); - } -return 0 ; out_free:
@@ -2005,17 +1995,6 @@ void ubi_wl_close(struct ubi_device *ubi)kfree (ubi->lookuptbl); } -static int ubi_wl_reboot_notifier (struct notifier_block *n, -unsigned long state,void *cmd) -{ -struct ubi_device *ubi; - - ubi = container_of(n, struct ubi_device, wl_reboot_notifier); -ubi_wl_close (ubi); - -return NOTIFY_DONE ; -} -/** * self_check_ec - make sure that the erase counter of a PEB is correct. * @ubi: UBI device description object
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 502/623 ubifs: skip dumping tnc tree when zroot is null
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: pangliyuan <[email protected]>
[ Upstream commit bdb0ca39e0acccf6771db49c3f94ed787d05f2d7 ]
Clearing slab cache will free all znode in memory and make c->zroot.znode = NULL, then dumping tnc tree will access c->zroot.znode which cause null pointer dereference.
--- fs/ubifs/debug.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
fs/ubifs/debug.c +13 -9
@@ -946,16 +946,20 @@ void ubifs_dump_tnc(struct ubifs_info *c)pr_err ("\n" );pr_err ("(pid %d) start dumping TNC tree\n" , current->pid); - znode =ubifs_tnc_levelorder_next (c, c->zroot.znode,NULL ); - level = znode->level; -pr_err ("== Level %d ==\n" , level); -while (znode) { -if (level != znode->level) { - level = znode->level; -pr_err ("== Level %d ==\n" , level); +if (c->zroot.znode) { + znode =ubifs_tnc_levelorder_next (c, c->zroot.znode,NULL ); + level = znode->level; +pr_err ("== Level %d ==\n" , level); +while (znode) { +if (level != znode->level) { + level = znode->level; +pr_err ("== Level %d ==\n" , level); + } +ubifs_dump_znode (c, znode); + znode =ubifs_tnc_levelorder_next (c, c->zroot.znode, znode); } -ubifs_dump_znode (c, znode); - znode =ubifs_tnc_levelorder_next (c, c->zroot.znode, znode); + }else { +pr_err ("empty TNC tree in memory\n" ); }pr_err ("(pid %d) finish dumping TNC tree\n" , current->pid); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 503/623 regulator: core: Add missing newline character
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
[ Upstream commit 155c569fa4c3b340fbf8571a0e42dd415c025377 ]
dev_err_probe() error messages need newline character.
--- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/core.c +1 -1
@@ -4908,7 +4908,7 @@ int _regulator_bulk_get(struct device *dev, int num_consumers, consumers[i].supply, get_type);if (IS_ERR (consumers[i].consumer)) { ret =dev_err_probe (dev,PTR_ERR (consumers[i].consumer), -"Failed to get supply '%s'" , +"Failed to get supply '%s'\n" , consumers[i].supply); consumers[i].consumer =NULL ; goto err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 504/623 net: airoha: Fix wrong GDM4 register definition
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit d31a49d37cb132b31cc6683eef2122f8609d6229 ]
Fix wrong GDM4 register definition, in Airoha SDK GDM4 is defined at offset 0x2400 but this doesn't make sense as it does conflict with the CDM4 that is in the same location.
Following the pattern where each GDM base is at the FWD_CFG, currently GDM4 base offset is set to 0x2500. This is correct but REG_GDM4_FWD_CFG and REG_GDM4_SRC_PORT_SET are still using the SDK reference with the 0x2400 offset. Fix these 2 define by subtracting 0x100 to each register to reflect the real address location.
--- drivers/net/ethernet/mediatek/airoha_eth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mediatek/airoha_eth.c +2 -2
@@ -258,11 +258,11 @@#define REG_GDM3_FWD_CFG GDM3_BASE#define GDM3_PAD_EN_MASK BIT(28) -#define REG_GDM4_FWD_CFG (GDM4_BASE + 0x100) +#define REG_GDM4_FWD_CFG GDM4_BASE#define GDM4_PAD_EN_MASK BIT(28)#define GDM4_SPORT_OFFSET0_MASK GENMASK(11, 8) -#define REG_GDM4_SRC_PORT_SET (GDM4_BASE + 0x33c) +#define REG_GDM4_SRC_PORT_SET (GDM4_BASE + 0x23c)#define GDM4_SPORT_OFF2_MASK GENMASK(19, 16)#define GDM4_SPORT_OFF1_MASK GENMASK(15, 12)#define GDM4_SPORT_OFF0_MASK GENMASK(11, 8)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 505/623 net: hns3: fix oops when unload drivers paralleling
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Shen <[email protected]>
[ Upstream commit 92e5995773774a3e70257e9c95ea03518268bea5 ]
When unload hclge driver, it tries to disable sriov first for each ae_dev node from hnae3_ae_dev_list. If user unloads hns3 driver at the time, because it removes all the ae_dev nodes, and it may cause oops.
But we can't simply use hnae3_common_lock for this. Because in the process flow of pci_disable_sriov(), it will trigger the remove flow of VF, which will also take hnae3_common_lock.
To fixes it, introduce a new mutex to protect the unload process.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 15 +++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 ++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 ++ 5 files changed, 23 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hnae3.c +15 -0
@@ -40,6 +40,21 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo_prepare);*/ static DEFINE_MUTEX (hnae3_common_lock); +/* ensure the drivers being unloaded one by one */ +static DEFINE_MUTEX (hnae3_unload_lock); + +void hnae3_acquire_unload_lock (void ) +{ +mutex_lock (&hnae3_unload_lock); +} +EXPORT_SYMBOL (hnae3_acquire_unload_lock); + +void hnae3_release_unload_lock (void ) +{ +mutex_unlock (&hnae3_unload_lock); +} +EXPORT_SYMBOL (hnae3_release_unload_lock); +static bool hnae3_client_match (enum hnae3_client_type client_type) { if (client_type == HNAE3_CLIENT_KNIC ||
drivers/net/ethernet/hisilicon/hns3/hnae3.h +2 -0
@@ -963,4 +963,6 @@ int hnae3_register_client(struct hnae3_client *client);void hnae3_set_client_init_flag (struct hnae3_client *client,struct hnae3_ae_dev *ae_dev,unsigned int inited); +void hnae3_acquire_unload_lock (void ); +void hnae3_release_unload_lock (void );#endif
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +2 -0
@@ -6002,9 +6002,11 @@ module_init(hns3_init_module);*/ static void __exit hns3_exit_module(void) { +hnae3_acquire_unload_lock ();pci_unregister_driver (&hns3_driver);hnae3_unregister_client (&client);hns3_dbg_unregister_debugfs (); +hnae3_release_unload_lock (); }module_exit (hns3_exit_module);
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +2 -0
@@ -12919,9 +12919,11 @@ static int __init hclge_init(void) static void __exit hclge_exit(void) { +hnae3_acquire_unload_lock ();hnae3_unregister_ae_algo_prepare (&ae_algo);hnae3_unregister_ae_algo (&ae_algo);destroy_workqueue (hclge_wq); +hnae3_release_unload_lock (); }module_init (hclge_init);module_exit (hclge_exit);
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +2 -0
@@ -3410,8 +3410,10 @@ static int __init hclgevf_init(void) static void __exit hclgevf_exit(void) { +hnae3_acquire_unload_lock ();hnae3_unregister_ae_algo (&ae_algovf);destroy_workqueue (hclgevf_wq); +hnae3_release_unload_lock (); }module_init (hclgevf_init);module_exit (hclgevf_exit);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 506/623 gpio: mxc: remove dead code after switch to DT-only
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmad Fatoum <[email protected]>
[ Upstream commit b049e7abe9001a780d58e78e3833dcceee22f396 ]
struct platform_device::id was only set by board code, but since i.MX became a devicetree-only platform, this will always be -1 (PLATFORM_DEVID_NONE).
Note: of_alias_get_id() returns a negative number on error and base treats all negative errors the same, so we need not add any additional error handling.
--- drivers/gpio/gpio-mxc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +1 -2
@@ -490,8 +490,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) port->gc.request = mxc_gpio_request; port->gc.free = mxc_gpio_free; port->gc.to_irq = mxc_gpio_to_irq; - port->gc.base = (pdev->id <0 ) ?of_alias_get_id (np,"gpio" ) *32 : - pdev->id *32 ; + port->gc.base =of_alias_get_id (np,"gpio" ) *32 ; err =devm_gpiochip_add_data (&pdev->dev, &port->gc, port);if (err)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 507/623 net: phy: marvell-88q2xxx: Fix temperature measurement with reset-gpios
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dimitri Fedrau <[email protected]>
[ Upstream commit a197004cf3c2e6c8cc0695c787a97e62e3229754 ]
When using temperature measurement on Marvell 88Q2XXX devices and the reset-gpios property is set in DT, the device does a hardware reset when interface is brought down and up again. That means that the content of the register MDIO_MMD_PCS_MV_TEMP_SENSOR2 is reset to default and that leads to permanent deactivation of the temperature measurement, because activation is done in mv88q2xxx_probe. To fix this move activation of temperature measurement to mv88q222x_config_init.
--- drivers/net/phy/marvell-88q2xxx.c | 33 ++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
drivers/net/phy/marvell-88q2xxx.c +26 -7
@@ -95,6 +95,10 @@#define MDIO_MMD_PCS_MV_TDR_OFF_CUTOFF 65246 +struct mv88q2xxx_priv { +bool enable_temp; +}; +struct mmd_val {int devad;u32 regnum;
@@ -710,17 +714,12 @@ static const struct hwmon_chip_info mv88q2xxx_hwmon_chip_info = {static int mv88q2xxx_hwmon_probe (struct phy_device *phydev) { +struct mv88q2xxx_priv *priv = phydev->priv;struct device *dev = &phydev->mdio.dev;struct device *hwmon;char *hwmon_name; -int ret; - -/* Enable temperature sense */ - ret =phy_modify_mmd (phydev,MDIO_MMD_PCS ,MDIO_MMD_PCS_MV_TEMP_SENSOR2 , -MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK ,0 ); -if (ret <0 ) -return ret; + priv->enable_temp = true; hwmon_name =devm_hwmon_sanitize_name (dev,dev_name (dev));if (IS_ERR (hwmon_name))return PTR_ERR (hwmon_name);
@@ -743,6 +742,14 @@ static int mv88q2xxx_hwmon_probe(struct phy_device *phydev)static int mv88q2xxx_probe (struct phy_device *phydev) { +struct mv88q2xxx_priv *priv; + + priv =devm_kzalloc (&phydev->mdio.dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + phydev->priv = priv; +return mv88q2xxx_hwmon_probe (phydev); }
@@ -810,6 +817,18 @@ static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev)static int mv88q222x_config_init (struct phy_device *phydev) { +struct mv88q2xxx_priv *priv = phydev->priv; +int ret; + +/* Enable temperature sense */ +if (priv->enable_temp) { + ret =phy_modify_mmd (phydev,MDIO_MMD_PCS , +MDIO_MMD_PCS_MV_TEMP_SENSOR2 , +MDIO_MMD_PCS_MV_TEMP_SENSOR2_DIS_MASK ,0 ); +if (ret <0 ) +return ret; + } +if (phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD ] ==PHY_ID_88Q2220_REVB0 )return mv88q222x_revb0_config_init (phydev);else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 508/623 net: fec: implement TSO descriptor cleanup
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dheeraj Reddy Jonnalagadda <[email protected]>
[ Upstream commit 61dc1fd9205bc9d9918aa933a847b08e80b4dc20 ]
Implement cleanup of descriptors in the TSO error path of fec_enet_txq_submit_tso(). The cleanup
- Unmaps DMA buffers for data descriptors skipping TSO header
- Clears all buffer descriptors
- Handles extended descriptors by clearing cbd_esc when enabled
--- drivers/net/ethernet/freescale/fec_main.c | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_main.c +30 -1
@@ -840,6 +840,8 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,struct fec_enet_private *fep =netdev_priv (ndev);int hdr_len, total_len, data_left;struct bufdesc *bdp = txq->bd.cur; +struct bufdesc *tmp_bdp; +struct bufdesc_ex *ebdp;struct tso_t tso;unsigned int index =0 ;int ret;
@@ -913,7 +915,34 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,return 0 ; err_release: -/* TODO: Release all used data descriptors for TSO */ +/* Release all used data descriptors for TSO */ + tmp_bdp = txq->bd.cur; + +while (tmp_bdp != bdp) { +/* Unmap data buffers */ +if (tmp_bdp->cbd_bufaddr && + !IS_TSO_HEADER (txq,fec32_to_cpu (tmp_bdp->cbd_bufaddr))) +dma_unmap_single (&fep->pdev->dev, +fec32_to_cpu (tmp_bdp->cbd_bufaddr), +fec16_to_cpu (tmp_bdp->cbd_datlen), +DMA_TO_DEVICE ); + +/* Clear standard buffer descriptor fields */ + tmp_bdp->cbd_sc =0 ; + tmp_bdp->cbd_datlen =0 ; + tmp_bdp->cbd_bufaddr =0 ; + +/* Handle extended descriptor if enabled */ +if (fep->bufdesc_ex) { + ebdp = (struct bufdesc_ex *)tmp_bdp; + ebdp->cbd_esc =0 ; + } + + tmp_bdp =fec_enet_get_nextdesc (tmp_bdp, &txq->bd); + } + +dev_kfree_skb_any (skb); +return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 509/623 ipmr: do not call mr_mfc_uses_dev() for unres entries
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 15a901361ec3fb1c393f91880e1cbf24ec0a88bd ]
syzbot found that calling mr_mfc_uses_dev() for unres entries would crash [1], because c->mfc_un.res.minvif / c->mfc_un.res.maxvif alias to "struct sk_buff_head unresolved", which contain two pointers.
This code never worked, lets remove it.
[1]
Unable to handle kernel paging request at virtual address ffff5fff2d536613 KASAN: maybe wild-memory-access in range [0xfffefff96a9b3098-0xfffefff96a9b309f] Modules linked in: CPU: 1 UID: 0 PID: 7321 Comm: syz.0.16 Not tainted 6.13.0-rc7-syzkaller-g1950a0af2d55 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mr_mfc_uses_dev net/ipv4/ipmr_base.c:290 [inline] pc : mr_table_dump+0x5a4/0x8b0 net/ipv4/ipmr_base.c:334 lr : mr_mfc_uses_dev net/ipv4/ipmr_base.c:289 [inline] lr : mr_table_dump+0x694/0x8b0 net/ipv4/ipmr_base.c:334 Call trace: mr_mfc_uses_dev net/ipv4/ipmr_base.c:290 [inline] (P) mr_table_dump+0x5a4/0x8b0 net/ipv4/ipmr_base.c:334 (P) mr_rtm_dumproute+0x254/0x454 net/ipv4/ipmr_base.c:382 ipmr_rtm_dumproute+0x248/0x4b4 net/ipv4/ipmr.c:2648 rtnl_dump_all+0x2e4/0x4e8 net/core/rtnetlink.c:4327 rtnl_dumpit+0x98/0x1d0 net/core/rtnetlink.c:6791 netlink_dump+0x4f0/0xbc0 net/netlink/af_netlink.c:2317 netlink_recvmsg+0x56c/0xe64 net/netlink/af_netlink.c:1973 sock_recvmsg_nosec net/socket.c:1033 [inline] sock_recvmsg net/socket.c:1055 [inline] sock_read_iter+0x2d8/0x40c net/socket.c:1125 new_sync_read fs/read_write.c:484 [inline] vfs_read+0x740/0x970 fs/read_write.c:565 ksys_read+0x15c/0x26c fs/read_write.c:708
--- net/ipv4/ipmr_base.c | 3 --- 1 file changed, 3 deletions(-)
net/ipv4/ipmr_base.c +0 -3
@@ -330,9 +330,6 @@ int mr_table_dump(struct mr_table *mrt, struct sk_buff *skb,list_for_each_entry (mfc, &mrt->mfc_unres_queue, list) {if (e < s_e) goto next_entry2; -if (filter->dev && - !mr_mfc_uses_dev (mrt, mfc, filter->dev)) - goto next_entry2; err =fill (mrt, skb,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, mfc,RTM_NEWROUTE , flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 510/623 PM: hibernate: Add error handling for syscore_suspend()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e20a70c572539a486dbd91b225fa6a194a5e2122 ]
In hibernation_platform_enter(), the code did not check the return value of syscore_suspend(), potentially leading to a situation where syscore_resume() would be called even if syscore_suspend() failed. This could cause unpredictable behavior or system instability.
Modify the code sequence in question to properly handle errors returned by syscore_suspend(). If an error occurs in the suspend path, the code now jumps to label 'Enable_irqs' skipping the syscore_resume() call and only enabling interrupts after setting the system state to SYSTEM_RUNNING.
--- kernel/power/hibernate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/power/hibernate.c +6 -1
@@ -608,7 +608,11 @@ int hibernation_platform_enter(void)local_irq_disable (); system_state =SYSTEM_SUSPEND ; -syscore_suspend (); + + error =syscore_suspend (); +if (error) + goto Enable_irqs; +if (pm_wakeup_pending ()) { error = -EAGAIN ; goto Power_up;
@@ -620,6 +624,7 @@ int hibernation_platform_enter(void) Power_up:syscore_resume (); + Enable_irqs: system_state =SYSTEM_RUNNING ;local_irq_enable ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 511/623 perf trace: Fix BPF loading failure (-E2BIG)
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Howard Chu <[email protected]>
[ Upstream commit 013eb043f37bd87c4d60d51034401a5a6d105bcf ]
As reported by Namhyung Kim and acknowledged by Qiao Zhao (link:
https://lore.kernel.org/linux-perf-users/[email protected]/),
on certain machines, perf trace failed to load the BPF program into the kernel. The verifier runs perf trace's BPF program for up to 1 million instructions, returning an E2BIG error, whereas the perf trace BPF program should be much less complex than that. This patch aims to fix the issue described above.
The E2BIG problem from clang-15 to clang-16 is cause by this line:
} else if (size < 0 && size >= -6) { /* buffer */
Specifically this check: size < 0. seems like clang generates a cool optimization to this sign check that breaks things.
Making 'size' s64, and use
} else if ((int)size < 0 && size >= -6) { /* buffer */
Solves the problem. This is some Hogwarts magic.
And the unbounded access of clang-12 and clang-14 (clang-13 works this time) is fixed by making variable 'aug_size' s64.
As for this:
-if (aug_size > TRACE_AUG_MAX_BUF)
- aug_size = TRACE_AUG_MAX_BUF;
+aug_size = args->args[index] > TRACE_AUG_MAX_BUF ? TRACE_AUG_MAX_BUF : args->args[index];
This makes the BPF skel generated by clang-18 work. Yes, new clangs introduce problems too.
Sorry, I only know that it works, but I don't know how it works. I'm not an expert in the BPF verifier. I really hope this is not a kernel version issue, as that would make the test case (kernel_nr) * (clang_nr), a true horror story. I will test it on more kernel versions in the future.
--- tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c +4 -7
@@ -431,9 +431,9 @@ static bool pid_filter__has(struct pids_filtered *pids, pid_t pid)static int augment_sys_enter (void *ctx,struct syscall_enter_args *args) {bool augmented, do_output = false; -int zero =0 , size, aug_size, index, - value_size =sizeof (struct augmented_arg ) - offsetof(struct augmented_arg , value); +int zero =0 , index, value_size =sizeof (struct augmented_arg ) - offsetof(struct augmented_arg , value);u64 output =0 ;/* has to be u64, otherwise it won't pass the verifier */ +s64 aug_size, size;unsigned int nr, *beauty_map;struct beauty_payload_enter *payload;void *arg, *payload_offset;
@@ -484,14 +484,11 @@ static int augment_sys_enter(void *ctx, struct syscall_enter_args *args) }else if (size >0 && size <= value_size) {/* struct */ if (!bpf_probe_read_user (((struct augmented_arg *)payload_offset)->value, size, arg)) augmented = true; - }else if (size <0 && size >=-6 ) {/* buffer */ + }else if ((int )size <0 && size >=-6 ) {/* buffer */ index = -(size +1 );barrier_var (index);// Prevent clang (noticed with v18) from removing the &= 7 trick. index &=7 ;// Satisfy the bounds checking with the verifier in some kernels. - aug_size = args->args[index]; - -if (aug_size >TRACE_AUG_MAX_BUF ) - aug_size =TRACE_AUG_MAX_BUF ; + aug_size = args->args[index] >TRACE_AUG_MAX_BUF ?TRACE_AUG_MAX_BUF : args->args[index];if (aug_size >0 ) {if (!bpf_probe_read_user (((struct augmented_arg *)payload_offset)->value, aug_size, arg))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 512/623 xfrm: Dont disable preemption while looking up cache state.
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Sewior <[email protected]>
[ Upstream commit 6c9b7db96db62ee9ad8d359d90ff468d462518c4 ]
For the state cache lookup xfrm_input_state_lookup() first disables preemption, to remain on the CPU and then retrieves a per-CPU pointer. Within the preempt-disable section it also acquires netns_xfrm::xfrm_state_lock, a spinlock_t. This lock must not be acquired with explicit disabled preemption (such as by get_cpu()) because this lock becomes a sleeping lock on PREEMPT_RT.
To remain on the same CPU is just an optimisation for the CPU local lookup. The actual modification of the per-CPU variable happens with netns_xfrm::xfrm_state_lock acquired.
Remove get_cpu() and use the state_cache_input on the current CPU.
--- net/xfrm/xfrm_state.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/xfrm/xfrm_state.c +1 -3
@@ -1150,9 +1150,8 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark,struct xfrm_hash_state_ptrs state_ptrs;struct hlist_head *state_cache_input;struct xfrm_state *x =NULL ; -int cpu =get_cpu (); - state_cache_input =per_cpu_ptr (net->xfrm.state_cache_input, cpu); + state_cache_input =raw_cpu_ptr (net->xfrm.state_cache_input);rcu_read_lock ();hlist_for_each_entry_rcu (x, state_cache_input, state_cache_input) {
@@ -1186,7 +1185,6 @@ struct xfrm_state *xfrm_input_state_lookup(struct net *net, u32 mark, out:rcu_read_unlock (); -put_cpu ();return x; }EXPORT_SYMBOL (xfrm_input_state_lookup);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 513/623 idpf: add read memory barrier when checking descriptor done bit
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emil Tantilov <[email protected]>
[ Upstream commit 396f0165672c6a74d7379027d344b83b5f05948c ]
Add read memory barrier to ensure the order of operations when accessing control queue descriptors. Specifically, we want to avoid cases where loads can be reordered:
1. Load #1 is dispatched to read descriptor flags.
2. Load #2 is dispatched to read some other field from the descriptor.
3. Load #2 completes, accessing memory/cache at a point in time when the DD flag is zero.
4. NIC DMA overwrites the descriptor, now the DD flag is one.
5. Any fields loaded before step 4 are now inconsistent with the actual descriptor state.
Add read memory barrier between steps 1 and 2, so that load #2 is not executed until load #1 has completed.
--- drivers/net/ethernet/intel/idpf/idpf_controlq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_controlq.c +6 -0
@@ -376,6 +376,9 @@ int idpf_ctlq_clean_sq(struct idpf_ctlq_info *cq, u16 *clean_count,if (!(le16_to_cpu (desc->flags) &IDPF_CTLQ_FLAG_DD ))break ; +/* Ensure no other fields are read until DD flag is checked */ +dma_rmb (); +/* strip off FW internal code */ desc_err =le16_to_cpu (desc->ret_val) &0xff ;
@@ -563,6 +566,9 @@ int idpf_ctlq_recv(struct idpf_ctlq_info *cq, u16 *num_q_msg,if (!(flags &IDPF_CTLQ_FLAG_DD ))break ; +/* Ensure no other fields are read until DD flag is checked */ +dma_rmb (); + q_msg[i].vmvf_type = (flags & (IDPF_CTLQ_FLAG_FTYPE_VM | IDPF_CTLQ_FLAG_FTYPE_PF)) >>
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 514/623 idpf: fix transaction timeouts on reset
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emil Tantilov <[email protected]>
[ Upstream commit 137da75ba72593598898a4e79da34f4b2da5d151 ]
Restore the call to idpf_vc_xn_shutdown() at the beginning of idpf_vc_core_deinit() provided the function is not called on remove. In the reset path the mailbox is destroyed, leading to all transactions timing out.
--- drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10 -1
@@ -3077,12 +3077,21 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)*/ void idpf_vc_core_deinit (struct idpf_adapter *adapter) { +bool remove_in_prog; +if (!test_bit (IDPF_VC_CORE_INIT , adapter->flags))return ; +/* Avoid transaction timeouts when called during reset */ + remove_in_prog =test_bit (IDPF_REMOVE_IN_PROG , adapter->flags); +if (!remove_in_prog) +idpf_vc_xn_shutdown (adapter->vcxn_mngr); +idpf_deinit_task (adapter);idpf_intr_rel (adapter); -idpf_vc_xn_shutdown (adapter->vcxn_mngr); + +if (remove_in_prog) +idpf_vc_xn_shutdown (adapter->vcxn_mngr);cancel_delayed_work_sync (&adapter->serv_task);cancel_delayed_work_sync (&adapter->mbx_task);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 515/623 idpf: Acquire the lock before accessing the xn->salt
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manoj Vishwanathan <[email protected]>
[ Upstream commit d15fe4edd7decdf14d8ad2b78df100ea23302065 ]
The transaction salt was being accessed before acquiring the idpf_vc_xn_lock when idpf has to forward the virtchnl reply.
--- drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +2 -1
@@ -612,14 +612,15 @@ idpf_vc_xn_forward_reply(struct idpf_adapter *adapter,return -EINVAL ; } xn = &adapter->vcxn_mngr->ring[xn_idx]; +idpf_vc_xn_lock (xn); salt =FIELD_GET (IDPF_VC_XN_SALT_M , msg_info);if (xn->salt != salt) {dev_err_ratelimited (&adapter->pdev->dev,"Transaction salt does not match (%02x != %02x)\n" , xn->salt, salt); +idpf_vc_xn_unlock (xn);return -EINVAL ; } -idpf_vc_xn_lock (xn);switch (xn->state) {case IDPF_VC_XN_WAITING :/* success */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 516/623 idpf: convert workqueues to unbound
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Leogrande <[email protected]>
[ Upstream commit 9a5b021cb8186f1854bac2812bd4f396bb1e881c ]
When a workqueue is created with WQ_UNBOUND, its work items are served by special worker-pools, whose host workers are not bound to any specific CPU. In the default configuration (i.e. when queue_delayed_work and friends do not specify which CPU to run the work item on), WQ_UNBOUND allows the work item to be executed on any CPU in the same node of the CPU it was enqueued on. While this solution potentially sacrifices locality, it avoids contention with other processes that might dominate the CPU time of the processor the work item was scheduled on.
This is not just a theoretical problem: in a particular scenario misconfigured process was hogging most of the time from CPU0, leaving less than 0.5% of its CPU time to the kworker. The IDPF workqueues that were using the kworker on CPU0 suffered large completion delays as a result, causing performance degradation, timeouts and eventual system crash.
Tested:
* I have also run a manual test to gauge the performance improvement. The test consists of an antagonist process (./stress --cpu 2) consuming as much of CPU 0 as possible. This process is run under taskset 01 to bind it to CPU0, and its priority is changed with chrt -pQ 9900 10000 ${pid} and renice -n -20 ${pid} after start.
Then, the IDPF driver is forced to prefer CPU0 by editing all calls to queue_delayed_work, mod_delayed_work, etc... to use CPU 0.
Finally, ktraces for the workqueue events are collected.
Without the current patch, the antagonist process can force arbitrary delays between workqueue_queue_work and workqueue_execute_start, that in my tests were as high as 30ms. With the current patch applied, the workqueue can be migrated to another unloaded CPU in the same node, and, keeping everything else equal, the maximum delay I could see was 6us.
--- drivers/net/ethernet/intel/idpf/idpf_main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_main.c +10 -5
@@ -174,7 +174,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_set_master (pdev);pci_set_drvdata (pdev, adapter); - adapter->init_wq =alloc_workqueue ("%s-%s-init" ,0 ,0 , + adapter->init_wq =alloc_workqueue ("%s-%s-init" , +WQ_UNBOUND |WQ_MEM_RECLAIM ,0 ,dev_driver_string (dev),dev_name (dev));if (!adapter->init_wq) {
@@ -183,7 +184,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_free; } - adapter->serv_wq =alloc_workqueue ("%s-%s-service" ,0 ,0 , + adapter->serv_wq =alloc_workqueue ("%s-%s-service" , +WQ_UNBOUND |WQ_MEM_RECLAIM ,0 ,dev_driver_string (dev),dev_name (dev));if (!adapter->serv_wq) {
@@ -192,7 +194,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_serv_wq_alloc; } - adapter->mbx_wq =alloc_workqueue ("%s-%s-mbx" ,0 ,0 , + adapter->mbx_wq =alloc_workqueue ("%s-%s-mbx" , +WQ_UNBOUND |WQ_MEM_RECLAIM ,0 ,dev_driver_string (dev),dev_name (dev));if (!adapter->mbx_wq) {
@@ -201,7 +204,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_mbx_wq_alloc; } - adapter->stats_wq =alloc_workqueue ("%s-%s-stats" ,0 ,0 , + adapter->stats_wq =alloc_workqueue ("%s-%s-stats" , +WQ_UNBOUND |WQ_MEM_RECLAIM ,0 ,dev_driver_string (dev),dev_name (dev));if (!adapter->stats_wq) {
@@ -210,7 +214,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_stats_wq_alloc; } - adapter->vc_event_wq =alloc_workqueue ("%s-%s-vc_event" ,0 ,0 , + adapter->vc_event_wq =alloc_workqueue ("%s-%s-vc_event" , +WQ_UNBOUND |WQ_MEM_RECLAIM ,0 ,dev_driver_string (dev),dev_name (dev));if (!adapter->vc_event_wq) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 517/623 ice: fix ice_parser_rt::bst_key array size
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemek Kitszel <[email protected]>
[ Upstream commit 18625e26fefced78f2ae28b25e80a07079821e04 ]
Fix &ice_parser_rt::bst_key size. It was wrongly set to 10 instead of 20 in the initial impl commit (see Fixes tag). All usage code assumed it was of size 20. That was also the initial size present up to v2 of the intro series [2], but halved by v3 [3] refactor described as "Replace magic hardcoded values with macros." The introducing series was so big that some ugliness was unnoticed, same for bugs :/
ICE_BST_KEY_TCAM_SIZE and ICE_BST_TCAM_KEY_SIZE were differing by one. There was tmp variable @j in the scope of edited function, but was not used in all places. This ugliness is now gone.
I'm moving ice_parser_rt::pg_prio a few positions up, to fill up one of the holes in order to compensate for the added 10 bytes to the ::bst_key, resulting in the same size of the whole as prior to the fix, and minimal changes in the offsets of the fields.
Extend also the debug dump print of the key to cover all bytes. To not have string with 20 "%02x" and 20 params, switch to ice_debug_array_w_prefix().
This fix obsoletes Ahmed's attempt at [1].
[1] https://lore.kernel.org/intel-wired-lan/[email protected]
[2] https://lore.kernel.org/intel-wired-lan/[email protected]
[3] https://lore.kernel.org/intel-wired-lan/[email protected]
--- drivers/net/ethernet/intel/ice/ice_parser.h | 6 ++---- drivers/net/ethernet/intel/ice/ice_parser_rt.c | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_parser.h +2 -4
@@ -257,7 +257,6 @@ ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,/*** ICE_SID_RXPARSER_BOOST_TCAM and ICE_SID_LBL_RXPARSER_TMEM sections ***/ #define ICE_BST_TCAM_TABLE_SIZE 256#define ICE_BST_TCAM_KEY_SIZE 20 -#define ICE_BST_KEY_TCAM_SIZE 19/* Boost TCAM item */ struct ice_bst_tcam_item {
@@ -401,7 +400,6 @@ u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag);#define ICE_PARSER_GPR_NUM 128#define ICE_PARSER_FLG_NUM 64#define ICE_PARSER_ERR_NUM 16 -#define ICE_BST_KEY_SIZE 10#define ICE_MARKER_ID_SIZE 9#define ICE_MARKER_MAX_SIZE \ (ICE_MARKER_ID_SIZE * BITS_PER_BYTE - 1)
@@ -431,13 +429,13 @@ struct ice_parser_rt {u8 pkt_buf[ICE_PARSER_MAX_PKT_LEN +ICE_PARSER_PKT_REV ];u16 pkt_len;u16 po; -u8 bst_key[ICE_BST_KEY_SIZE ]; +u8 bst_key[ICE_BST_TCAM_KEY_SIZE ];struct ice_pg_cam_key pg_key; +u8 pg_prio;struct ice_alu *alu0;struct ice_alu *alu1;struct ice_alu *alu2;struct ice_pg_cam_action *action; -u8 pg_prio;struct ice_gpr_pu pu;u8 markers[ICE_MARKER_ID_SIZE ];bool protocols[ICE_PO_PAIR_SIZE ];
drivers/net/ethernet/intel/ice/ice_parser_rt.c +5 -7
@@ -125,22 +125,20 @@ static void ice_bst_key_init(struct ice_parser_rt *rt,else key[idd] = imem->b_kb.prio; - idd =ICE_BST_KEY_TCAM_SIZE -1 ; + idd =ICE_BST_TCAM_KEY_SIZE -2 ;for (i = idd; i >=0 ; i--) {int j; j = ho + idd - i;if (j <ICE_PARSER_MAX_PKT_LEN ) - key[i] = rt->pkt_buf[ho + idd - i]; + key[i] = rt->pkt_buf[j];else key[i] =0 ; } -ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"Generated Boost TCAM Key:\n" ); -ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n" , - key[0 ], key[1 ], key[2 ], key[3 ], key[4 ], - key[5 ], key[6 ], key[7 ], key[8 ], key[9 ]); -ice_debug (rt->psr->hw,ICE_DBG_PARSER ,"\n" ); +ice_debug_array_w_prefix (rt->psr->hw,ICE_DBG_PARSER , +KBUILD_MODNAME ": Generated Boost TCAM Key" , + key,ICE_BST_TCAM_KEY_SIZE ); }static u16 ice_bit_rev_u16 (u16 v,int len)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 518/623 ice: remove invalid parameter of equalizer
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Polchlopek <[email protected]>
[ Upstream commit c5cc2a27e04f2fcd77c74ada9aef76a758a24697 ]
It occurred that in the commit 70838938e89c ("ice: Implement driver functionality to dump serdes equalizer values") the invalid DRATE parameter for reading has been added. The output of the command:
$ ethtool -d <ethX>
returns the garbage value in the place where DRATE value should be stored.
Remove mentioned parameter to prevent return of corrupted data to userspace.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.h | 1 - 3 files changed, 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -1
@@ -1491,7 +1491,6 @@ struct ice_aqc_dnl_equa_param {#define ICE_AQC_RX_EQU_POST1 (0x12 << ICE_AQC_RX_EQU_SHIFT)#define ICE_AQC_RX_EQU_BFLF (0x13 << ICE_AQC_RX_EQU_SHIFT)#define ICE_AQC_RX_EQU_BFHF (0x14 << ICE_AQC_RX_EQU_SHIFT) -#define ICE_AQC_RX_EQU_DRATE (0x15 << ICE_AQC_RX_EQU_SHIFT)#define ICE_AQC_RX_EQU_CTLE_GAINHF (0x20 << ICE_AQC_RX_EQU_SHIFT)#define ICE_AQC_RX_EQU_CTLE_GAINLF (0x21 << ICE_AQC_RX_EQU_SHIFT)#define ICE_AQC_RX_EQU_CTLE_GAINDC (0x22 << ICE_AQC_RX_EQU_SHIFT)
drivers/net/ethernet/intel/ice/ice_ethtool.c +0 -1
@@ -710,7 +710,6 @@ static int ice_get_tx_rx_equa(struct ice_hw *hw, u8 serdes_num, { ICE_AQC_RX_EQU_POST1, rx, &ptr->rx_equ_post1 }, { ICE_AQC_RX_EQU_BFLF, rx, &ptr->rx_equ_bflf }, { ICE_AQC_RX_EQU_BFHF, rx, &ptr->rx_equ_bfhf }, - { ICE_AQC_RX_EQU_DRATE, rx, &ptr->rx_equ_drate }, { ICE_AQC_RX_EQU_CTLE_GAINHF, rx, &ptr->rx_equ_ctle_gainhf }, { ICE_AQC_RX_EQU_CTLE_GAINLF, rx, &ptr->rx_equ_ctle_gainlf }, { ICE_AQC_RX_EQU_CTLE_GAINDC, rx, &ptr->rx_equ_ctle_gaindc },
drivers/net/ethernet/intel/ice/ice_ethtool.h +0 -1
@@ -15,7 +15,6 @@ struct ice_serdes_equalization_to_ethtool {int rx_equ_post1;int rx_equ_bflf;int rx_equ_bfhf; -int rx_equ_drate;int rx_equ_ctle_gainhf;int rx_equ_ctle_gainlf;int rx_equ_ctle_gaindc;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 519/623 iavf: allow changing VLAN state without calling PF
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Swiatkowski <[email protected]>
[ Upstream commit ee7d79433d783346430ee32f28c9df44a88b3bb6 ]
First case:
Quoted 3 lines
ip l a l $VF name vlanx type vlan id 100
ip l d vlanx
ip l a l $VF name vlanx type vlan id 100
As workqueue can be execute after sometime, there is a window to have call trace like that:
- iavf_del_vlan
- iavf_add_vlan
- iavf_del_vlans (wq)
It means that our VLAN 100 will change the state from IAVF_VLAN_ACTIVE to IAVF_VLAN_REMOVE (iavf_del_vlan). After that in iavf_add_vlan state won't be changed because VLAN 100 is on the filter list. The final result is that the VLAN 100 filter isn't added in hardware (no iavf_add_vlans call).
To fix that change the state if the filter wasn't removed yet directly to active. It is save as IAVF_VLAN_REMOVE means that virtchnl message wasn't sent yet.
Second case:
Quoted 1 line
ip l a l $VF name vlanx type vlan id 100
Any type of VF reset ex. change trust
Quoted 3 lines
ip l s $PF vf $VF_NUM trust on
ip l d vlanx
ip l a l $VF name vlanx type vlan id 100
In case of reset iavf driver is responsible for readding all filters that are being used. To do that all VLAN filters state are changed to IAVF_VLAN_ADD. Here is even longer window for changing VLAN state from kernel side, as workqueue isn't called immediately. We can have call trace like that:
- changing to IAVF_VLAN_ADD (after reset)
- iavf_del_vlan (called from kernel ops)
- iavf_del_vlans (wq)
Not exsisitng VLAN filters will be removed from hardware. It isn't a bug, ice driver will handle it fine. However, we can have call trace like that:
- changing to IAVF_VLAN_ADD (after reset)
- iavf_del_vlan (called from kernel ops)
- iavf_add_vlan (called from kernel ops)
- iavf_del_vlans (wq)
With fix for previous case we end up with no VLAN filters in hardware. We have to remove VLAN filters if the state is IAVF_VLAN_ADD and delete VLAN was called. It is save as IAVF_VLAN_ADD means that virtchnl message wasn't sent yet.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +17 -2
@@ -773,6 +773,11 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, f->state =IAVF_VLAN_ADD ; adapter->num_vlan_filters++;iavf_schedule_aq_request (adapter,IAVF_FLAG_AQ_ADD_VLAN_FILTER ); + }else if (f->state ==IAVF_VLAN_REMOVE ) { +/* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed. +* We can safely only change the state here. +*/ + f->state =IAVF_VLAN_ACTIVE ; } clearout:
@@ -793,8 +798,18 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, struct iavf_vlan vlan) f =iavf_find_vlan (adapter, vlan);if (f) { - f->state =IAVF_VLAN_REMOVE ; -iavf_schedule_aq_request (adapter,IAVF_FLAG_AQ_DEL_VLAN_FILTER ); +/* IAVF_ADD_VLAN means that VLAN wasn't even added yet. +* Remove it from the list. +*/ +if (f->state ==IAVF_VLAN_ADD ) { +list_del (&f->list); +kfree (f); + adapter->num_vlan_filters--; + }else { + f->state =IAVF_VLAN_REMOVE ; +iavf_schedule_aq_request (adapter, +IAVF_FLAG_AQ_DEL_VLAN_FILTER ); + } }spin_unlock_bh (&adapter->mac_vlan_list_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 520/623 s390/mm: Allow large pages for KASAN shadow mapping
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
[ Upstream commit e70452c4ba2ce1e24a3fdc18bd623edb7b56013c ]
Commit c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces") introduced a large_allowed() helper that restricts which mapping modes can use large pages. This change unintentionally prevented KASAN shadow mappings from using large pages, despite there being no reason to avoid them. In fact, large pages are preferred for performance.
Since commit d8073dc6bc04 ("s390/mm: Allow large pages only for aligned physical addresses"), both can_large_pud() and can_large_pmd() call _pa() to check if large page physical addresses are aligned. However, _pa() has a side effect: it allocates memory in POPULATE_KASAN_MAP_SHADOW mode.
Rename large_allowed() to large_page_mapping_allowed() and add POPULATE_KASAN_MAP_SHADOW to the allowed list to restore large page mappings for KASAN shadows.
While large_page_mapping_allowed() isn't strictly necessary with current mapping modes since disallowed modes either don't map anything or fail alignment and size checks, keep it for clarity.
Rename _pa() to resolve_pa_may_alloc() for clarity and to emphasize existing side effect. Rework can_large_pud()/can_large_pmd() to take the side effect into consideration and actually return physical address instead of just checking conditions.
--- arch/s390/boot/vmem.c | 74 +++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 24 deletions(-)
arch/s390/boot/vmem.c +50 -24
@@ -13,6 +13,7 @@#include "decompressor.h" #include "boot.h" +#define INVALID_PHYS_ADDR (~(phys_addr_t)0)struct ctlreg __bootdata_preserved (s390_invalid_asce );#ifdef CONFIG_PROC_FS
@@ -236,11 +237,12 @@ static pte_t *boot_pte_alloc(void)return pte; } -static unsigned long _pa (unsigned long addr,unsigned long size,enum populate_mode mode) +static unsigned long resolve_pa_may_alloc (unsigned long addr,unsigned long size, +enum populate_mode mode) {switch (mode) {case POPULATE_NONE : -return -1 ; +return INVALID_PHYS_ADDR ;case POPULATE_DIRECT :return addr;case POPULATE_LOWCORE :
@@ -258,33 +260,55 @@ static unsigned long _pa(unsigned long addr, unsigned long size, enum populate_mreturn addr;#endif default : -return -1 ; +return INVALID_PHYS_ADDR ; } } -static bool large_allowed (enum populate_mode mode) +static bool large_page_mapping_allowed (enum populate_mode mode) { -return (mode ==POPULATE_DIRECT ) || (mode ==POPULATE_IDENTITY ) || (mode ==POPULATE_KERNEL ); +switch (mode) { +case POPULATE_DIRECT : +case POPULATE_IDENTITY : +case POPULATE_KERNEL : +#ifdef CONFIG_KASAN +case POPULATE_KASAN_MAP_SHADOW : +#endif +return true; +default : +return false; + } } -static bool can_large_pud (pud_t *pu_dir,unsigned long addr,unsigned long end, -enum populate_mode mode) +static unsigned long try_get_large_pud_pa (pud_t *pu_dir,unsigned long addr,unsigned long end, +enum populate_mode mode) { -unsigned long size = end - addr; +unsigned long pa, size = end - addr; + +if (!machine.has_edat2 || !large_page_mapping_allowed (mode) || + !IS_ALIGNED (addr,PUD_SIZE ) || (size <PUD_SIZE )) +return INVALID_PHYS_ADDR ; -return machine.has_edat2 &&large_allowed (mode) && -IS_ALIGNED (addr,PUD_SIZE ) && (size >=PUD_SIZE ) && -IS_ALIGNED (_pa (addr, size, mode),PUD_SIZE ); + pa =resolve_pa_may_alloc (addr, size, mode); +if (!IS_ALIGNED (pa,PUD_SIZE )) +return INVALID_PHYS_ADDR ; + +return pa; } -static bool can_large_pmd (pmd_t *pm_dir,unsigned long addr,unsigned long end, -enum populate_mode mode) +static unsigned long try_get_large_pmd_pa (pmd_t *pm_dir,unsigned long addr,unsigned long end, +enum populate_mode mode) { -unsigned long size = end - addr; +unsigned long pa, size = end - addr; + +if (!machine.has_edat1 || !large_page_mapping_allowed (mode) || + !IS_ALIGNED (addr,PMD_SIZE ) || (size <PMD_SIZE )) +return INVALID_PHYS_ADDR ; + + pa =resolve_pa_may_alloc (addr, size, mode); +if (!IS_ALIGNED (pa,PMD_SIZE )) +return INVALID_PHYS_ADDR ; -return machine.has_edat1 &&large_allowed (mode) && -IS_ALIGNED (addr,PMD_SIZE ) && (size >=PMD_SIZE ) && -IS_ALIGNED (_pa (addr, size, mode),PMD_SIZE ); +return pa; } static void pgtable_pte_populate(pmd_t *pmd, unsigned long addr, unsigned long end,
@@ -298,7 +322,7 @@ static void pgtable_pte_populate(pmd_t *pmd, unsigned long addr, unsigned long eif (pte_none (*pte)) {if (kasan_pte_populate_zero_shadow (pte, mode))continue ; - entry =__pte (_pa (addr,PAGE_SIZE , mode)); + entry =__pte (resolve_pa_may_alloc (addr,PAGE_SIZE , mode)); entry =set_pte_bit (entry,PAGE_KERNEL );if (!machine.has_nx) entry =clear_pte_bit (entry,__pgprot (_PAGE_NOEXEC));
@@ -313,7 +337,7 @@ static void pgtable_pte_populate(pmd_t *pmd, unsigned long addr, unsigned long estatic void pgtable_pmd_populate (pud_t *pud,unsigned long addr,unsigned long end,enum populate_mode mode) { -unsigned long next, pages =0 ; +unsigned long pa, next, pages =0 ;pmd_t *pmd, entry;pte_t *pte;
@@ -323,8 +347,9 @@ static void pgtable_pmd_populate(pud_t *pud, unsigned long addr, unsigned long eif (pmd_none (*pmd)) {if (kasan_pmd_populate_zero_shadow (pmd, addr, next, mode))continue ; -if (can_large_pmd (pmd, addr, next, mode)) { - entry =__pmd (_pa (addr, _SEGMENT_SIZE, mode)); + pa =try_get_large_pmd_pa (pmd, addr, next, mode); +if (pa !=INVALID_PHYS_ADDR ) { + entry =__pmd (pa); entry =set_pmd_bit (entry,SEGMENT_KERNEL );if (!machine.has_nx) entry =clear_pmd_bit (entry,__pgprot (_SEGMENT_ENTRY_NOEXEC));
@@ -346,7 +371,7 @@ static void pgtable_pmd_populate(pud_t *pud, unsigned long addr, unsigned long estatic void pgtable_pud_populate (p4d_t *p4d,unsigned long addr,unsigned long end,enum populate_mode mode) { -unsigned long next, pages =0 ; +unsigned long pa, next, pages =0 ;pud_t *pud, entry;pmd_t *pmd;
@@ -356,8 +381,9 @@ static void pgtable_pud_populate(p4d_t *p4d, unsigned long addr, unsigned long eif (pud_none (*pud)) {if (kasan_pud_populate_zero_shadow (pud, addr, next, mode))continue ; -if (can_large_pud (pud, addr, next, mode)) { - entry =__pud (_pa (addr, _REGION3_SIZE, mode)); + pa =try_get_large_pud_pa (pud, addr, next, mode); +if (pa !=INVALID_PHYS_ADDR ) { + entry =__pud (pa); entry =set_pud_bit (entry,REGION3_KERNEL );if (!machine.has_nx) entry =clear_pud_bit (entry,__pgprot (_REGION_ENTRY_NOEXEC));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 521/623 net/ncsi: use dev_set_mac_address() for Get MC MAC Address handling
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Fertser <[email protected]>
[ Upstream commit 05d91cdb1f9108426b14975ef4eeddf15875ca05 ]
Copy of the rationale from 790071347a0a1a89e618eedcd51c687ea783aeb3:
Change ndo_set_mac_address to dev_set_mac_address because dev_set_mac_address provides a way to notify network layer about MAC change. In other case, services may not aware about MAC change and keep using old one which set from network adapter driver.
As example, DHCP client from systemd do not update MAC address without notification from net subsystem which leads to the problem with acquiring the right address from DHCP server.
Since dev_set_mac_address requires RTNL lock the operation can not be performed directly in the response handler, see 9e2bbab94b88295dcc57c7580393c9ee08d7314d.
The way of selecting the first suitable MAC address from the list is changed, instead of having the driver check it this patch just assumes any valid MAC should be good.
--- net/ncsi/ncsi-rsp.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
net/ncsi/ncsi-rsp.c +8 -10
@@ -1089,14 +1089,12 @@ static int ncsi_rsp_handler_netlink(struct ncsi_request *nr)static int ncsi_rsp_handler_gmcma (struct ncsi_request *nr) {struct ncsi_dev_priv *ndp = nr->ndp; +struct sockaddr *saddr = &ndp->pending_mac;struct net_device *ndev = ndp->ndev.dev;struct ncsi_rsp_gmcma_pkt *rsp; -struct sockaddr saddr; -int ret =-1 ;int i; rsp = (struct ncsi_rsp_gmcma_pkt *)skb_network_header (nr->rsp); - saddr.sa_family = ndev->type; ndev->priv_flags |=IFF_LIVE_ADDR_CHANGE ; netdev_info(ndev, "NCSI: Received %d provisioned MAC addresses\n",
@@ -1108,20 +1106,20 @@ static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr) rsp->addresses[i][4], rsp->addresses[i][5]); } + saddr->sa_family = ndev->type;for (i =0 ; i < rsp->address_count; i++) { -memcpy (saddr.sa_data, &rsp->addresses[i],ETH_ALEN ); - ret = ndev->netdev_ops->ndo_set_mac_address (ndev, &saddr); -if (ret <0 ) { +if (!is_valid_ether_addr (rsp->addresses[i])) {netdev_warn (ndev,"NCSI: Unable to assign %pM to device\n" , - saddr.sa_data); + rsp->addresses[i]);continue ; } -netdev_warn (ndev,"NCSI: Set MAC address to %pM\n" , saddr.sa_data); +memcpy (saddr->sa_data, rsp->addresses[i],ETH_ALEN ); +netdev_warn (ndev,"NCSI: Will set MAC address to %pM\n" , saddr->sa_data);break ; } - ndp->gma_flag = ret ==0 ; -return ret; + ndp->gma_flag =1 ; +return 0 ; } static struct ncsi_rsp_handler {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 522/623 net: rose: fix timer races against user threads
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5de7665e0a0746b5ad7943554b34db8f8614a196 ]
Rose timers only acquire the socket spinlock, without checking if the socket is owned by one user thread.
Add a check and rearm the timers if needed.
BUG: KASAN: slab-use-after-free in rose_timer_expiry+0x31d/0x360 net/rose/rose_timer.c:174 Read of size 2 at addr ffff88802f09b82a by task swapper/0/0 CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.13.0-rc5-syzkaller-00172-gd1bf27c4e176 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x169/0x550 mm/kasan/report.c:489 kasan_report+0x143/0x180 mm/kasan/report.c:602 rose_timer_expiry+0x31d/0x360 net/rose/rose_timer.c:174 call_timer_fn+0x187/0x650 kernel/time/timer.c:1793 expire_timers kernel/time/timer.c:1844 [inline] __run_timers kernel/time/timer.c:2418 [inline] __run_timer_base+0x66a/0x8e0 kernel/time/timer.c:2430 run_timer_base kernel/time/timer.c:2439 [inline] run_timer_softirq+0xb7/0x170 kernel/time/timer.c:2449 handle_softirqs+0x2d4/0x9b0 kernel/softirq.c:561 __do_softirq kernel/softirq.c:595 [inline] invoke_softirq kernel/softirq.c:435 [inline] __irq_exit_rcu+0xf7/0x220 kernel/softirq.c:662 irq_exit_rcu+0x9/0x30 kernel/softirq.c:678 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline] sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1049 </IRQ>
--- net/rose/rose_timer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/rose/rose_timer.c +15 -0
@@ -122,6 +122,10 @@ static void rose_heartbeat_expiry(struct timer_list *t)struct rose_sock *rose =rose_sk (sk);bh_lock_sock (sk); +if (sock_owned_by_user (sk)) { +sk_reset_timer (sk, &sk->sk_timer, jiffies +HZ /20 ); + goto out; + }switch (rose->state) {case ROSE_STATE_0 :/* Magic here: If we listen() and a new link dies before it
@@ -152,6 +156,7 @@ static void rose_heartbeat_expiry(struct timer_list *t) }rose_start_heartbeat (sk); +out:bh_unlock_sock (sk);sock_put (sk); }
@@ -162,6 +167,10 @@ static void rose_timer_expiry(struct timer_list *t)struct sock *sk = &rose->sock;bh_lock_sock (sk); +if (sock_owned_by_user (sk)) { +sk_reset_timer (sk, &rose->timer, jiffies +HZ /20 ); + goto out; + }switch (rose->state) {case ROSE_STATE_1 :/* T1 */ case ROSE_STATE_4 :/* T2 */
@@ -182,6 +191,7 @@ static void rose_timer_expiry(struct timer_list *t) }break ; } +out:bh_unlock_sock (sk);sock_put (sk); }
@@ -192,6 +202,10 @@ static void rose_idletimer_expiry(struct timer_list *t)struct sock *sk = &rose->sock;bh_lock_sock (sk); +if (sock_owned_by_user (sk)) { +sk_reset_timer (sk, &rose->idletimer, jiffies +HZ /20 ); + goto out; + }rose_clear_queues (sk);rose_write_internal (sk,ROSE_CLEAR_REQUEST );
@@ -207,6 +221,7 @@ static void rose_idletimer_expiry(struct timer_list *t) sk->sk_state_change (sk);sock_set_flag (sk,SOCK_DEAD ); } +out:bh_unlock_sock (sk);sock_put (sk); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 523/623 net: netdevsim: try to close UDP port harness races
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 50bf398e1ceacb9a7f85bd3bdca065ebe5cb6159 ]
syzbot discovered that we remove the debugfs files after we free the netdev. Try to clean up the relevant dir while the device is still around.
--- drivers/net/netdevsim/netdevsim.h | 1 + drivers/net/netdevsim/udp_tunnels.c | 23 +++++++++++-------- .../drivers/net/netdevsim/udp_tunnel_nic.sh | 16 ++++++------- 3 files changed, 23 insertions(+), 17 deletions(-)
drivers/net/netdevsim/netdevsim.h +1 -0
@@ -129,6 +129,7 @@ struct netdevsim {u32 sleep;u32 __ports[2 ][NSIM_UDP_TUNNEL_N_PORTS ];u32 (*ports)[NSIM_UDP_TUNNEL_N_PORTS ]; +struct dentry *ddir;struct debugfs_u32_array dfs_ports[2 ]; } udp_ports;
drivers/net/netdevsim/udp_tunnels.c +14 -9
@@ -112,9 +112,11 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,struct net_device *dev = file->private_data;struct netdevsim *ns =netdev_priv (dev); -memset (ns->udp_ports.ports,0 ,sizeof (ns->udp_ports.__ports));rtnl_lock (); -udp_tunnel_nic_reset_ntf (dev); +if (dev->reg_state ==NETREG_REGISTERED ) { +memset (ns->udp_ports.ports,0 ,sizeof (ns->udp_ports.__ports)); +udp_tunnel_nic_reset_ntf (dev); + }rtnl_unlock ();return count;
@@ -144,23 +146,23 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,else ns->udp_ports.ports = nsim_dev->udp_ports.__ports; -debugfs_create_u32 ("udp_ports_inject_error" ,0600 , - ns->nsim_dev_port->ddir, + ns->udp_ports.ddir =debugfs_create_dir ("udp_ports" , + ns->nsim_dev_port->ddir); + +debugfs_create_u32 ("inject_error" ,0600 , ns->udp_ports.ddir, &ns->udp_ports.inject_error); ns->udp_ports.dfs_ports[0 ].array = ns->udp_ports.ports[0 ]; ns->udp_ports.dfs_ports[0 ].n_elements =NSIM_UDP_TUNNEL_N_PORTS ; -debugfs_create_u32_array ("udp_ports_table0" ,0400 , - ns->nsim_dev_port->ddir, +debugfs_create_u32_array ("table0" ,0400 , ns->udp_ports.ddir, &ns->udp_ports.dfs_ports[0 ]); ns->udp_ports.dfs_ports[1 ].array = ns->udp_ports.ports[1 ]; ns->udp_ports.dfs_ports[1 ].n_elements =NSIM_UDP_TUNNEL_N_PORTS ; -debugfs_create_u32_array ("udp_ports_table1" ,0400 , - ns->nsim_dev_port->ddir, +debugfs_create_u32_array ("table1" ,0400 , ns->udp_ports.ddir, &ns->udp_ports.dfs_ports[1 ]); -debugfs_create_file ("udp_ports_reset" ,0200 , ns->nsim_dev_port->ddir, +debugfs_create_file ("reset" ,0200 , ns->udp_ports.ddir, dev, &nsim_udp_tunnels_info_reset_fops);/* Note: it's not normal to allocate the info struct like this!
@@ -196,6 +198,9 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev,void nsim_udp_tunnels_info_destroy (struct net_device *dev) { +struct netdevsim *ns =netdev_priv (dev); + +debugfs_remove_recursive (ns->udp_ports.ddir);kfree (dev->udp_tunnel_nic_info); dev->udp_tunnel_nic_info =NULL ; }
tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh +8 -8
@@ -142,7 +142,7 @@ function pre_ethtool { } function check_table { - local path=$NSIM_DEV_DFS/ports/$port/udp_ports_table$1 + local path=$NSIM_DEV_DFS/ports/$port/udp_ports/table$1 local -n expected=$2 local last=$3
@@ -212,7 +212,7 @@ function check_tables { } function print_table { - local path=$NSIM_DEV_DFS/ports/$port/udp_ports_table$1 + local path=$NSIM_DEV_DFS/ports/$port/udp_ports/table$1 read -a have < $path tree $NSIM_DEV_DFS/
@@ -641,7 +641,7 @@ for port in 0 1; do NSIM_NETDEV=`get_netdev_name old_netdevs` ip link set dev $NSIM_NETDEV up - echo 110 > $NSIM_DEV_DFS/ports/$port/udp_ports_inject_error + echo 110 > $NSIM_DEV_DFS/ports/$port/udp_ports/inject_error msg="1 - create VxLANs v6" exp0=( 0 0 0 0 )
@@ -663,7 +663,7 @@ for port in 0 1; do new_geneve gnv0 20000 msg="2 - destroy GENEVE" - echo 2 > $NSIM_DEV_DFS/ports/$port/udp_ports_inject_error + echo 2 > $NSIM_DEV_DFS/ports/$port/udp_ports/inject_error exp1=( `mke 20000 2` 0 0 0 ) del_dev gnv0
@@ -764,7 +764,7 @@ for port in 0 1; do msg="create VxLANs v4" new_vxlan vxlan0 10000 $NSIM_NETDEV - echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports_reset + echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports/reset check_tables msg="NIC device goes down"
@@ -775,7 +775,7 @@ for port in 0 1; do fi check_tables - echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports_reset + echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports/reset check_tables msg="NIC device goes up again"
@@ -789,7 +789,7 @@ for port in 0 1; do del_dev vxlan0 check_tables - echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports_reset + echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports/reset check_tables msg="destroy NIC"
@@ -896,7 +896,7 @@ msg="vacate VxLAN in overflow table" exp0=( `mke 10000 1` `mke 10004 1` 0 `mke 10003 1` ) del_dev vxlan2 -echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports_reset +echo 1 > $NSIM_DEV_DFS/ports/$port/udp_ports/reset check_tables msg="tunnels destroyed 2"
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 524/623 net/mlx5e: add missing cpu_to_node to kvzalloc_node in mlx5e_open_xdpredirect_sq
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit 979284535aaf12a287a2f43d9d5dfcbdc1dc4cac ]
kvzalloc_node is not doing a runtime check on the node argument (__alloc_pages_node_noprof does have a VM_BUG_ON, but it expands to nothing on !CONFIG_DEBUG_VM builds), so doing any ethtool/netlink operation that calls mlx5e_open on a CPU that's larger that MAX_NUMNODES triggers OOB access and panic (see the trace below).
Add missing cpu_to_node call to convert cpu id to node id.
[ 165.427394] mlx5_core 0000:5c:00.0 beth1: Link up [ 166.479327] BUG: unable to handle page fault for address: 0000000800000010 [ 166.494592] #PF: supervisor read access in kernel mode [ 166.505995] #PF: error_code(0x0000) - not-present page ... [ 166.816958] Call Trace: [ 166.822380] <TASK> [ 166.827034] ? __die_body+0x64/0xb0 [ 166.834774] ? page_fault_oops+0x2cd/0x3f0 [ 166.843862] ? exc_page_fault+0x63/0x130 [ 166.852564] ? asm_exc_page_fault+0x22/0x30 [ 166.861843] ? __kvmalloc_node_noprof+0x43/0xd0 [ 166.871897] ? get_partial_node+0x1c/0x320 [ 166.880983] ? deactivate_slab+0x269/0x2b0 [ 166.890069] ___slab_alloc+0x521/0xa90 [ 166.898389] ? __kvmalloc_node_noprof+0x43/0xd0 [ 166.908442] __kmalloc_node_noprof+0x216/0x3f0 [ 166.918302] ? __kvmalloc_node_noprof+0x43/0xd0 [ 166.928354] __kvmalloc_node_noprof+0x43/0xd0 [ 166.938021] mlx5e_open_channels+0x5e2/0xc00 [ 166.947496] mlx5e_open_locked+0x3e/0xf0 [ 166.956201] mlx5e_open+0x23/0x50 [ 166.963551] __dev_open+0x114/0x1c0 [ 166.971292] __dev_change_flags+0xa2/0x1b0 [ 166.980378] dev_change_flags+0x21/0x60 [ 166.988887] do_setlink+0x38d/0xf20 [ 166.996628] ? ep_poll_callback+0x1b9/0x240 [ 167.005910] ? __nla_validate_parse.llvm.10713395753544950386+0x80/0xd70 [ 167.020782] ? __wake_up_sync_key+0x52/0x80 [ 167.030066] ? __mutex_lock+0xff/0x550 [ 167.038382] ? security_capable+0x50/0x90 [ 167.047279] rtnl_setlink+0x1c9/0x210 [ 167.055403] ? ep_poll_callback+0x1b9/0x240 [ 167.064684] ? security_capable+0x50/0x90 [ 167.073579] rtnetlink_rcv_msg+0x2f9/0x310 [ 167.082667] ? rtnetlink_bind+0x30/0x30 [ 167.091173] netlink_rcv_skb+0xb1/0xe0 [ 167.099492] netlink_unicast+0x20f/0x2e0 [ 167.108191] netlink_sendmsg+0x389/0x420 [ 167.116896] __sys_sendto+0x158/0x1c0 [ 167.125024] __x64_sys_sendto+0x22/0x30 [ 167.133534] do_syscall_64+0x63/0x130 [ 167.141657] ? __irq_exit_rcu.llvm.17843942359718260576+0x52/0xd0 [ 167.155181] entry_SYSCALL_64_after_hwframe+0x4b/0x53
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -2087,7 +2087,7 @@ static struct mlx5e_xdpsq *mlx5e_open_xdpredirect_sq(struct mlx5e_channel *c,struct mlx5e_xdpsq *xdpsq;int err; - xdpsq =kvzalloc_node (sizeof (*xdpsq),GFP_KERNEL , c->cpu); + xdpsq =kvzalloc_node (sizeof (*xdpsq),GFP_KERNEL ,cpu_to_node (c->cpu));if (!xdpsq)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 525/623 tools: ynl: c: correct reverse decode of empty attrs
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 964417a5d4a06614ef7fb3ae69bb17c91a2dc016 ]
netlink reports which attribute was incorrect by sending back an attribute offset. Offset points to the address of struct nlattr, but to interpret the type we also need the nesting path. Attribute IDs have different meaning in different nests of the same message.
Correct the condition for "is the offset within current attribute". ynl_attr_data_len() does not include the attribute header, so the end offset was off by 4 bytes.
This means that we'd always skip over flags and empty nests.
The devmem tests, for example, issues an invalid request with empty queue nests, resulting in the following error:
YNL failed: Kernel error: missing attribute: .queues.ifindex
The message is incorrect, "queues" nest does not have an "ifindex" attribute defined. With this fix we decend correctly into the nest:
YNL failed: Kernel error: missing attribute: .queues.id
--- tools/net/ynl/lib/ynl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/net/ynl/lib/ynl.c +1 -1
@@ -95,7 +95,7 @@ ynl_err_walk(struct ynl_sock *ys, void *start, void *end, unsigned int off,ynl_attr_for_each_payload (start, data_len, attr) { astart_off = (char *)attr - (char *)start; - aend_off = astart_off +ynl_attr_data_len (attr); + aend_off = (char *)ynl_attr_data_end (attr) - (char *)start;if (aend_off <= off)continue ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 526/623 net: page_pool: dont try to stash the napi id
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 67e4bb2ced0f2d8fbd414f932daea94ba63ae4c4 ]
Page ppol tried to cache the NAPI ID in page pool info to avoid having a dependency on the life cycle of the NAPI instance. Since commit under Fixes the NAPI ID is not populated until napi_enable() and there's a good chance that page pool is created before NAPI gets enabled.
Protect the NAPI pointer with the existing page pool mutex, the reading path already holds it. napi_id itself we need to READ_ONCE(), it's protected by netdev_lock() which are not holding in page pool.
Before this patch napi IDs were missing for mlx5:
# ./cli.py --spec netlink/specs/netdev.yaml --dump page-pool-get
[{'id': 144, 'ifindex': 2, 'inflight': 3072, 'inflight-mem': 12582912},
{'id': 143, 'ifindex': 2, 'inflight': 5568, 'inflight-mem': 22806528}, {'id': 142, 'ifindex': 2, 'inflight': 5120, 'inflight-mem': 20971520}, {'id': 141, 'ifindex': 2, 'inflight': 4992, 'inflight-mem': 20447232},
...
After:
[{'id': 144, 'ifindex': 2, 'inflight': 3072, 'inflight-mem': 12582912,
'napi-id': 565},
{'id': 143, 'ifindex': 2, 'inflight': 4224, 'inflight-mem': 17301504,
'napi-id': 525},
{'id': 142, 'ifindex': 2, 'inflight': 4288, 'inflight-mem': 17563648,
'napi-id': 524},
...
--- include/net/page_pool/types.h | 1 - net/core/dev.c | 2 +- net/core/page_pool.c | 2 ++ net/core/page_pool_priv.h | 2 ++ net/core/page_pool_user.c | 15 +++++++++------ 5 files changed, 14 insertions(+), 8 deletions(-)
include/net/page_pool/types.h +0 -1
@@ -236,7 +236,6 @@ struct page_pool {struct {struct hlist_node list;u64 detach_time; -u32 napi_id;u32 id; } user; };
net/core/dev.c +1 -1
@@ -6573,7 +6573,7 @@ void napi_resume_irqs(unsigned int napi_id)static void __napi_hash_add_with_id (struct napi_struct *napi,unsigned int napi_id) { - napi->napi_id = napi_id; +WRITE_ONCE (napi->napi_id, napi_id);hlist_add_head_rcu (&napi->napi_hash_node, &napi_hash[napi->napi_id %HASH_SIZE (napi_hash)]); }
net/core/page_pool.c +2 -0
@@ -1108,7 +1108,9 @@ void page_pool_disable_direct_recycling(struct page_pool *pool)WARN_ON (!test_bit (NAPI_STATE_SCHED , &pool->p.napi->state));WARN_ON (READ_ONCE (pool->p.napi->list_owner) !=-1 ); +mutex_lock (&page_pools_lock);WRITE_ONCE (pool->p.napi,NULL ); +mutex_unlock (&page_pools_lock); }EXPORT_SYMBOL (page_pool_disable_direct_recycling);
net/core/page_pool_priv.h +2 -0
@@ -7,6 +7,8 @@#include "netmem_priv.h" +extern struct mutex page_pools_lock; +s32 page_pool_inflight (const struct page_pool *pool,bool strict);int page_pool_list (struct page_pool *pool);
net/core/page_pool_user.c +9 -6
@@ -3,6 +3,7 @@#include <linux/mutex.h> #include <linux/netdevice.h> #include <linux/xarray.h> +#include <net/busy_poll.h> #include <net/net_debug.h> #include <net/netdev_rx_queue.h> #include <net/page_pool/helpers.h>
@@ -14,10 +15,11 @@#include "netdev-genl-gen.h" static DEFINE_XARRAY_FLAGS(page_pools, XA_FLAGS_ALLOC1); -/* Protects: page_pools, netdevice->page_pools, pool->slow.netdev, pool->user. +/* Protects: page_pools, netdevice->page_pools, pool->p.napi, pool->slow.netdev, +* pool->user. * Ordering: inside rtnl_lock */ -static DEFINE_MUTEX (page_pools_lock); +DEFINE_MUTEX (page_pools_lock);/* Page pools are only reachable from user space (via netlink) if they are * linked to a netdev at creation time. Following page pool "visibility"
@@ -216,6 +218,7 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool, {struct net_devmem_dmabuf_binding *binding = pool->mp_priv;size_t inflight, refsz; +unsigned int napi_id;void *hdr; hdr =genlmsg_iput (rsp, info);
@@ -229,8 +232,10 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool, nla_put_u32(rsp, NETDEV_A_PAGE_POOL_IFINDEX, pool->slow.netdev->ifindex)) goto err_cancel; -if (pool->user.napi_id && -nla_put_uint (rsp,NETDEV_A_PAGE_POOL_NAPI_ID , pool->user.napi_id)) + + napi_id = pool->p.napi ?READ_ONCE (pool->p.napi->napi_id) :0 ; +if (napi_id >=MIN_NAPI_ID && +nla_put_uint (rsp,NETDEV_A_PAGE_POOL_NAPI_ID , napi_id)) goto err_cancel; inflight =page_pool_inflight (pool, false);
@@ -319,8 +324,6 @@ int page_pool_list(struct page_pool *pool)if (pool->slow.netdev) {hlist_add_head (&pool->user.list, &pool->slow.netdev->page_pools); - pool->user.napi_id = pool->p.napi ? pool->p.napi->napi_id :0 ; -netdev_nl_page_pool_event (pool,NETDEV_CMD_PAGE_POOL_ADD_NTF ); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 527/623 selftests: mptcp: extend CFLAGS to keep options from environment
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit 23b3a7c4a7583eac9e3976355928a832c87caa0f ]
Package build environments like Fedora rpmbuild introduced hardening options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS and LDFLAGS.
mptcp Makefile currently overrides CFLAGS but not LDFLAGS, which leads
to a mismatch and build failure, for example:
make[1]: *** [../../lib.mk:222: tools/testing/selftests/net/mptcp/mptcp_sockopt] Error 1
/usr/bin/ld: /tmp/ccqyMVdb.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
--- tools/testing/selftests/net/mptcp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/Makefile +1 -1
@@ -2,7 +2,7 @@ top_srcdir = ../../../../.. -CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) +CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \ simult_flows.sh mptcp_sockopt.sh userspace_pm.sh
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 528/623 selftests: net/{lib,openvswitch}: extend CFLAGS to keep options from environment
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit 9b06d5b956131bde535f5c045cf8c1ff6bfba76c ]
Package build environments like Fedora rpmbuild introduced hardening options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS and LDFLAGS.
Some Makefiles currently override CFLAGS but not LDFLAGS, which leads to a mismatch and build failure, for example:
/usr/bin/ld: /tmp/ccd2apay.o: relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [../../lib.mk:222: tools/testing/selftests/net/lib/csum] Error 1
openvswitch/Makefile CFLAGS currently do not appear to be used, but fix it anyway for the case when new tests are introduced in future.
--- tools/testing/selftests/net/lib/Makefile | 2 +- tools/testing/selftests/net/openvswitch/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/lib/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS = -Wall -Wl,--no-as-needed -O2 -g +CFLAGS += -Wall -Wl,--no-as-needed -O2 -g CFLAGS += -I../../../../../usr/include/ $(KHDR_INCLUDES) # Additional include paths needed by kselftest.h CFLAGS += -I../../
tools/testing/selftests/net/openvswitch/Makefile +1 -1
@@ -2,7 +2,7 @@ top_srcdir = ../../../../.. -CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) +CFLAGS += -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) TEST_PROGS := openvswitch.sh
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 529/623 rxrpc, afs: Fix peer hash locking vs RCU callback
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 79d458c13056559d49b5e41fbc4b6890e68cf65b ]
In its address list, afs now retains pointers to and refs on one or more rxrpc_peer objects. The address list is freed under RCU and at this time, it puts the refs on those peers.
Now, when an rxrpc_peer object runs out of refs, it gets removed from the peer hash table and, for that, rxrpc has to take a spinlock. However, it is now being called from afs's RCU cleanup, which takes place in BH context - but it is just taking an ordinary spinlock.
The put may also be called from non-BH context, and so there exists the possibility of deadlock if the BH-based RCU cleanup happens whilst the hash spinlock is held. This led to the attached lockdep complaint.
Fix this by changing spinlocks of rxnet->peer_hash_lock back to BH-disabling locks.
================================
WARNING: inconsistent lock state
6.13.0-rc5-build2+ #1223 Tainted: G E
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
swapper/1/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
ffff88810babe228 (&rxnet->peer_hash_lock){+.?.}-{3:3}, at: rxrpc_put_peer+0xcb/0x180
{SOFTIRQ-ON-W} state was registered at:
mark_usage+0x164/0x180
__lock_acquire+0x544/0x990
lock_acquire.part.0+0x103/0x280
_raw_spin_lock+0x2f/0x40
rxrpc_peer_keepalive_worker+0x144/0x440
process_one_work+0x486/0x7c0
process_scheduled_works+0x73/0x90
worker_thread+0x1c8/0x2a0
kthread+0x19b/0x1b0
ret_from_fork+0x24/0x40
ret_from_fork_asm+0x1a/0x30
irq event stamp: 972402
hardirqs last enabled at (972402): [<ffffffff8244360e>] _raw_spin_unlock_irqrestore+0x2e/0x50
hardirqs last disabled at (972401): [<ffffffff82443328>] _raw_spin_lock_irqsave+0x18/0x60
softirqs last enabled at (972300): [<ffffffff810ffbbe>] handle_softirqs+0x3ee/0x430
softirqs last disabled at (972313): [<ffffffff810ffc54>] __irq_exit_rcu+0x44/0x110
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&rxnet->peer_hash_lock);
<Interrupt>
lock(&rxnet->peer_hash_lock);
*** DEADLOCK ***
1 lock held by swapper/1/0:
#0: ffffffff83576be0 (rcu_callback){....}-{0:0}, at: rcu_lock_acquire+0x7/0x30
stack backtrace:
CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Tainted: G E 6.13.0-rc5-build2+ #1223
Tainted: [E]=UNSIGNED_MODULE
Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
Call Trace:
<IRQ>
dump_stack_lvl+0x57/0x80
print_usage_bug.part.0+0x227/0x240
valid_state+0x53/0x70
mark_lock_irq+0xa5/0x2f0
mark_lock+0xf7/0x170
mark_usage+0xe1/0x180
__lock_acquire+0x544/0x990
lock_acquire.part.0+0x103/0x280
_raw_spin_lock+0x2f/0x40
rxrpc_put_peer+0xcb/0x180
afs_free_addrlist+0x46/0x90 [kafs]
rcu_do_batch+0x2d2/0x640
rcu_core+0x2f7/0x350
handle_softirqs+0x1ee/0x430
__irq_exit_rcu+0x44/0x110
irq_exit_rcu+0xa/0x30
sysvec_apic_timer_interrupt+0x7f/0xa0
</IRQ>--- net/rxrpc/peer_event.c | 16 ++++++++-------- net/rxrpc/peer_object.c | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-)
net/rxrpc/peer_event.c +8 -8
@@ -238,7 +238,7 @@ static void rxrpc_peer_keepalive_dispatch(struct rxrpc_net *rxnet,bool use;int slot; -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);while (!list_empty (collector)) { peer = list_entry(collector->next,
@@ -249,7 +249,7 @@ static void rxrpc_peer_keepalive_dispatch(struct rxrpc_net *rxnet,continue ; use =__rxrpc_use_local (peer->local, rxrpc_local_use_peer_keepalive); -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock);if (use) { keepalive_at = peer->last_tx_at +RXRPC_KEEPALIVE_TIME ;
@@ -269,17 +269,17 @@ static void rxrpc_peer_keepalive_dispatch(struct rxrpc_net *rxnet,*/ slot += cursor; slot &= mask; -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);list_add_tail (&peer->keepalive_link, &rxnet->peer_keepalive[slot & mask]); -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock);rxrpc_unuse_local (peer->local, rxrpc_local_unuse_peer_keepalive); }rxrpc_put_peer (peer, rxrpc_peer_put_keepalive); -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock); } -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock); }/*
@@ -309,7 +309,7 @@ void rxrpc_peer_keepalive_worker(struct work_struct *work)* second; the bucket at cursor + 1 goes at now + 1s and so * on... */ -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);list_splice_init (&rxnet->peer_keepalive_new, &collector); stop = cursor +ARRAY_SIZE (rxnet->peer_keepalive);
@@ -321,7 +321,7 @@ void rxrpc_peer_keepalive_worker(struct work_struct *work) } base = now; -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock); rxnet->peer_keepalive_base = base; rxnet->peer_keepalive_cursor = cursor;
net/rxrpc/peer_object.c +6 -6
@@ -313,10 +313,10 @@ void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer) hash_key =rxrpc_peer_hash_key (local, &peer->srx);rxrpc_init_peer (local, peer, hash_key); -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);hash_add_rcu (rxnet->peer_hash, &peer->hash_link, hash_key);list_add_tail (&peer->keepalive_link, &rxnet->peer_keepalive_new); -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock); }/*
@@ -348,7 +348,7 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local,return NULL ; } -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);/* Need to check that we aren't racing with someone else */ peer =__rxrpc_lookup_peer_rcu (local, srx, hash_key);
@@ -361,7 +361,7 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local, &rxnet->peer_keepalive_new); } -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock);if (peer)rxrpc_free_peer (candidate);
@@ -411,10 +411,10 @@ static void __rxrpc_put_peer(struct rxrpc_peer *peer)ASSERT (hlist_empty (&peer->error_targets)); -spin_lock (&rxnet->peer_hash_lock); +spin_lock_bh (&rxnet->peer_hash_lock);hash_del_rcu (&peer->hash_link);list_del_init (&peer->keepalive_link); -spin_unlock (&rxnet->peer_hash_lock); +spin_unlock_bh (&rxnet->peer_hash_lock);rxrpc_free_peer (peer); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 530/623 vxlan: Fix uninit-value in vxlan_vnifilter_dump()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
[ Upstream commit 5066293b9b7046a906eff60e3949a887ae185a43 ]
KMSAN reported an uninit-value access in vxlan_vnifilter_dump() [1].
If the length of the netlink message payload is less than sizeof(struct tunnel_msg), vxlan_vnifilter_dump() accesses bytes beyond the message. This can lead to uninit-value access. Fix this by returning an error in such situations.
[1]
BUG: KMSAN: uninit-value in vxlan_vnifilter_dump+0x328/0x920 drivers/net/vxlan/vxlan_vnifilter.c:422 vxlan_vnifilter_dump+0x328/0x920 drivers/net/vxlan/vxlan_vnifilter.c:422 rtnl_dumpit+0xd5/0x2f0 net/core/rtnetlink.c:6786 netlink_dump+0x93e/0x15f0 net/netlink/af_netlink.c:2317 __netlink_dump_start+0x716/0xd60 net/netlink/af_netlink.c:2432 netlink_dump_start include/linux/netlink.h:340 [inline] rtnetlink_dump_start net/core/rtnetlink.c:6815 [inline] rtnetlink_rcv_msg+0x1256/0x14a0 net/core/rtnetlink.c:6882 netlink_rcv_skb+0x467/0x660 net/netlink/af_netlink.c:2542 rtnetlink_rcv+0x35/0x40 net/core/rtnetlink.c:6944 netlink_unicast_kernel net/netlink/af_netlink.c:1321 [inline] netlink_unicast+0xed6/0x1290 net/netlink/af_netlink.c:1347 netlink_sendmsg+0x1092/0x1230 net/netlink/af_netlink.c:1891 sock_sendmsg_nosec net/socket.c:711 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:726 ____sys_sendmsg+0x7f4/0xb50 net/socket.c:2583 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2637 __sys_sendmsg net/socket.c:2669 [inline] __do_sys_sendmsg net/socket.c:2674 [inline] __se_sys_sendmsg net/socket.c:2672 [inline] __x64_sys_sendmsg+0x211/0x3e0 net/socket.c:2672 x64_sys_call+0x3878/0x3d90 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd9/0x1d0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was created at:
slab_post_alloc_hook mm/slub.c:4110 [inline] slab_alloc_node mm/slub.c:4153 [inline] kmem_cache_alloc_node_noprof+0x800/0xe80 mm/slub.c:4205 kmalloc_reserve+0x13b/0x4b0 net/core/skbuff.c:587 __alloc_skb+0x347/0x7d0 net/core/skbuff.c:678 alloc_skb include/linux/skbuff.h:1323 [inline] netlink_alloc_large_skb+0xa5/0x280 net/netlink/af_netlink.c:1196 netlink_sendmsg+0xac9/0x1230 net/netlink/af_netlink.c:1866 sock_sendmsg_nosec net/socket.c:711 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:726 ____sys_sendmsg+0x7f4/0xb50 net/socket.c:2583 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2637 __sys_sendmsg net/socket.c:2669 [inline] __do_sys_sendmsg net/socket.c:2674 [inline] __se_sys_sendmsg net/socket.c:2672 [inline] __x64_sys_sendmsg+0x211/0x3e0 net/socket.c:2672 x64_sys_call+0x3878/0x3d90 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xd9/0x1d0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 0 UID: 0 PID: 30991 Comm: syz.4.10630 Not tainted 6.12.0-10694-gc44daa7e3c73 #29 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-3.fc41 04/01/2014
--- drivers/net/vxlan/vxlan_vnifilter.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/vxlan/vxlan_vnifilter.c +5 -0
@@ -411,6 +411,11 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, struct netlink_callback *cbstruct tunnel_msg *tmsg;struct net_device *dev; +if (cb->nlh->nlmsg_len <nlmsg_msg_size (sizeof (struct tunnel_msg ))) { +NL_SET_ERR_MSG (cb->extack,"Invalid msg length" ); +return -EINVAL ; + } + tmsg =nlmsg_data (cb->nlh);if (tmsg->flags & ~TUNNEL_MSG_VALID_USER_FLAGS ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 531/623 net: davicom: fix UAF in dm9000_drv_remove
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit 19e65c45a1507a1a2926649d2db3583ed9d55fd9 ]
dm is netdev private data and it cannot be
used after free_netdev() call. Using dm after free_netdev() can cause UAF bug. Fix it by moving free_netdev() at the end of the function.
This is similar to the issue fixed in commit ad297cd2db89 ("net: qcom/emac: fix UAF in emac_remove").
This bug is detected by our static analysis tool.
--- drivers/net/ethernet/davicom/dm9000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/davicom/dm9000.c +2 -1
@@ -1777,10 +1777,11 @@ static void dm9000_drv_remove(struct platform_device *pdev)unregister_netdev (ndev);dm9000_release_board (pdev, dm); -free_netdev (ndev);/* free device structure */ if (dm->power_supply)regulator_disable (dm->power_supply); +free_netdev (ndev);/* free device structure */ +dev_dbg (&pdev->dev,"released and freed device\n" ); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 532/623 perf annotate: Use an array for the disassembler preference
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit bde4ccfd5ab5361490514fc4af7497989cfbee17 ]
Prior to this change a string was used which could cause issues with an unrecognized disassembler in symbol__disassembler. Change to initializing an array of perf_disassembler enum values. If a value already exists then adding it a second time is ignored to avoid array out of bounds problems present in the previous code, it also allows a statically sized array and removes memory allocation needs. Errors in the disassembler string are reported when the config is parsed during perf annotate or perf top start up. If the array is uninitialized after processing the config file the default llvm, capstone then objdump values are added but without a need to parse a string.
--- tools/perf/util/annotate.c | 76 +++++++++++++++++++++++++++++++--- tools/perf/util/annotate.h | 15 ++++--- tools/perf/util/disasm.c | 83 +++++++------------------------------- 3 files changed, 96 insertions(+), 78 deletions(-)
tools/perf/util/annotate.c +71 -5
@@ -2102,6 +2102,57 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,return 0 ; } +const char *const perf_disassembler__strs[] = { + [PERF_DISASM_UNKNOWN ] ="unknown" , + [PERF_DISASM_LLVM ] ="llvm" , + [PERF_DISASM_CAPSTONE ] ="capstone" , + [PERF_DISASM_OBJDUMP ] ="objdump" , +}; + + +static void annotation_options__add_disassembler (struct annotation_options *options, +enum perf_disassembler dis) +{ +for (u8 i =0 ; i <ARRAY_SIZE (options->disassemblers); i++) { +if (options->disassemblers[i] == dis) { +/* Disassembler is already present then don't add again. */ +return ; + } +if (options->disassemblers[i] ==PERF_DISASM_UNKNOWN ) { +/* Found a free slot. */ + options->disassemblers[i] = dis; +return ; + } + } +pr_err ("Failed to add disassembler %d\n" , dis); +} + +static int annotation_options__add_disassemblers_str (struct annotation_options *options, +const char *str) +{ +while (str && *str !='\0' ) { +const char *comma =strchr (str,',' ); +int len = comma ? comma - str : (int )strlen (str); +bool match = false; + +for (u8 i =0 ; i <ARRAY_SIZE (perf_disassembler__strs); i++) { +const char *dis_str = perf_disassembler__strs[i]; + +if (len == (int )strlen (dis_str) && !strncmp (str, dis_str, len)) { +annotation_options__add_disassembler (options, i); + match = true; +break ; + } + } +if (!match) { +pr_err ("Invalid disassembler '%.*s'\n" , len, str); +return -1 ; + } + str = comma ? comma +1 :NULL ; + } +return 0 ; +} +static int annotation__config (const char *var,const char *value,void *data) {struct annotation_options *opt = data;
@@ -2117,11 +2168,10 @@ static int annotation__config(const char *var, const char *value, void *data)else if (opt->offset_level <ANNOTATION__MIN_OFFSET_LEVEL ) opt->offset_level =ANNOTATION__MIN_OFFSET_LEVEL ; }else if (!strcmp (var,"annotate.disassemblers" )) { - opt->disassemblers_str =strdup (value); -if (!opt->disassemblers_str) { -pr_err ("Not enough memory for annotate.disassemblers\n" ); -return -1 ; - } +int err =annotation_options__add_disassemblers_str (opt, value); + +if (err) +return err; }else if (!strcmp (var,"annotate.hide_src_code" )) { opt->hide_src_code =perf_config_bool ("hide_src_code" , value); }else if (!strcmp (var,"annotate.jump_arrows" )) {
@@ -2187,9 +2237,25 @@ void annotation_options__exit(void)zfree (&annotate_opts.objdump_path); } +static void annotation_options__default_init_disassemblers (struct annotation_options *options) +{ +if (options->disassemblers[0 ] !=PERF_DISASM_UNKNOWN ) { +/* Already initialized. */ +return ; + } +#ifdef HAVE_LIBLLVM_SUPPORT +annotation_options__add_disassembler (options,PERF_DISASM_LLVM ); +#endif +#ifdef HAVE_LIBCAPSTONE_SUPPORT +annotation_options__add_disassembler (options,PERF_DISASM_CAPSTONE ); +#endif +annotation_options__add_disassembler (options,PERF_DISASM_OBJDUMP ); +} +void annotation_config__init (void ) {perf_config (annotation__config, &annotate_opts); +annotation_options__default_init_disassemblers (&annotate_opts); }static unsigned int parse_percent_type (char *str1,char *str2)
tools/perf/util/annotate.h +10 -5
@@ -34,8 +34,13 @@ struct annotated_data_type;#define ANNOTATION__BR_CNTR_WIDTH 30#define ANNOTATION_DUMMY_LEN 256 -// llvm, capstone, objdump -#define MAX_DISASSEMBLERS 3 +enum perf_disassembler { +PERF_DISASM_UNKNOWN =0 , +PERF_DISASM_LLVM , +PERF_DISASM_CAPSTONE , +PERF_DISASM_OBJDUMP , +}; +#define MAX_DISASSEMBLERS (PERF_DISASM_OBJDUMP + 1)struct annotation_options { bool hide_src_code,
@@ -52,14 +57,12 @@ struct annotation_options { annotate_src, full_addr;u8 offset_level; -u8 nr_disassemblers; +u8 disassemblers[MAX_DISASSEMBLERS ];int min_pcnt;int max_lines;int context;char *objdump_path;char *disassembler_style; -const char *disassemblers_str; -const char *disassemblers[MAX_DISASSEMBLERS ];const char *prefix;const char *prefix_strip;unsigned int percent_type;
@@ -134,6 +137,8 @@ struct disasm_line {struct annotation_line al; }; +extern const char *const perf_disassembler__strs[]; +void annotation_line__add (struct annotation_line *al,struct list_head *head); static inline double annotation_data__percent(struct annotation_data *data,
tools/perf/util/disasm.c +15 -68
106 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 533/623 ptp: Properly handle compat ioctls
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 19ae40f572a9ce1ade9954990af709a03fd37010 ]
Pointer arguments passed to ioctls need to pass through compat_ptr() to work correctly on s390; as explained in Documentation/driver-api/ioctl.rst. Detect compat mode at runtime and call compat_ptr() for those commands which do take pointer arguments.
--- drivers/ptp/ptp_chardev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/ptp/ptp_chardev.c +4 -0
@@ -4,6 +4,7 @@* * Copyright (C) 2010 OMICRON electronics GmbH */ +#include <linux/compat.h> #include <linux/module.h> #include <linux/posix-clock.h> #include <linux/poll.h>
@@ -176,6 +177,9 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,struct timespec64 ts;int enable, err =0 ; +if (in_compat_syscall () && cmd !=PTP_ENABLE_PPS && cmd !=PTP_ENABLE_PPS2 ) + arg = (unsigned long )compat_ptr (arg); + tsevq = pccontext->private_clkdata;switch (cmd) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 534/623 ethtool: Fix set RXNFC command with symmetric RSS hash
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 4f5a52adeb1ad675ca33f1e1eacd9c0bbaf393d4 ]
The sanity check that both source and destination are set when symmetric RSS hash is requested is only relevant for ETHTOOL_SRXFH (rx-flow-hash), it should not be performed on any other commands (e.g. ETHTOOL_SRXCLSRLINS/ETHTOOL_SRXCLSRLDEL).
This resolves accessing uninitialized 'info.data' field, and fixes false errors in rule insertion:
# ethtool --config-ntuple eth2 flow-type ip4 dst-ip 255.255.255.255 action -1 loc 0 rmgr: Cannot insert RX class rule: Invalid argument Cannot insert classification rule
--- net/ethtool/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/ioctl.c +1 -1
@@ -998,7 +998,7 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, ethtool_get_flow_spec_ring(info.fs.ring_cookie))return -EINVAL ; -if (ops->get_rxfh) { +if (cmd ==ETHTOOL_SRXFH && ops->get_rxfh) {struct ethtool_rxfh_param rxfh = {}; rc = ops->get_rxfh (dev, &rxfh);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 535/623 net: stmmac: Limit the number of MTL queues to hardware capability
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
[ Upstream commit f5fb35a3d6b36d378b2e2ecbfb9caa337d5428e6 ]
The number of MTL queues to use is specified by the parameter "snps,{tx,rx}-queues-to-use" from stmmac_platform layer.
However, the maximum numbers of queues are constrained by upper limits determined by the capability of each hardware feature. It's appropriate to limit the values not to exceed the upper limit values and display a warning message.
This only works if the hardware capability has the upper limit values.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +15 -0
@@ -7175,6 +7175,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv)if (priv->dma_cap.tsoen)dev_info (priv->device,"TSO supported\n" ); +if (priv->dma_cap.number_rx_queues && + priv->plat->rx_queues_to_use > priv->dma_cap.number_rx_queues) { +dev_warn (priv->device, +"Number of Rx queues (%u) exceeds dma capability\n" , + priv->plat->rx_queues_to_use); + priv->plat->rx_queues_to_use = priv->dma_cap.number_rx_queues; + } +if (priv->dma_cap.number_tx_queues && + priv->plat->tx_queues_to_use > priv->dma_cap.number_tx_queues) { +dev_warn (priv->device, +"Number of Tx queues (%u) exceeds dma capability\n" , + priv->plat->tx_queues_to_use); + priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues; + } + priv->hw->vlan_fail_q_en = (priv->plat->flags &STMMAC_FLAG_VLAN_FAIL_Q_EN ); priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 536/623 net: stmmac: Limit FIFO size by hardware capability
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
[ Upstream commit 044f2fbaa2725696ecbf1f02ba7ab0a8ccb7e1ae ]
Tx/Rx FIFO size is specified by the parameter "{tx,rx}-fifo-depth" from stmmac_platform layer.
However, these values are constrained by upper limits determined by the capabilities of each hardware feature. There is a risk that the upper bits will be truncated due to the calculation, so it's appropriate to limit them to the upper limit values and display a warning message.
This only works if the hardware capability has the upper limit values.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +15 -0
@@ -7190,6 +7190,21 @@ static int stmmac_hw_init(struct stmmac_priv *priv) priv->plat->tx_queues_to_use = priv->dma_cap.number_tx_queues; } +if (priv->dma_cap.rx_fifo_size && + priv->plat->rx_fifo_size > priv->dma_cap.rx_fifo_size) { +dev_warn (priv->device, +"Rx FIFO size (%u) exceeds dma capability\n" , + priv->plat->rx_fifo_size); + priv->plat->rx_fifo_size = priv->dma_cap.rx_fifo_size; + } +if (priv->dma_cap.tx_fifo_size && + priv->plat->tx_fifo_size > priv->dma_cap.tx_fifo_size) { +dev_warn (priv->device, +"Tx FIFO size (%u) exceeds dma capability\n" , + priv->plat->tx_fifo_size); + priv->plat->tx_fifo_size = priv->dma_cap.tx_fifo_size; + } + priv->hw->vlan_fail_q_en = (priv->plat->flags &STMMAC_FLAG_VLAN_FAIL_Q_EN ); priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 537/623 bonding: Correctly support GSO ESP offload
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Ratiu <[email protected]>
[ Upstream commit 9e6c4e6b605c1fa3e24f74ee0b641e95f090188a ]
The referenced fix is incomplete. It correctly computes bond_dev->gso_partial_features across slaves, but unfortunately netdev_fix_features discards gso_partial_features from the feature set if NETIF_F_GSO_PARTIAL isn't set in bond_dev->features.
This is visible with ethtool -k bond0 | grep esp:
tx-esp-segmentation: off [requested on]
esp-hw-offload: on
esp-tx-csum-hw-offload: on
This patch reworks the bonding GSO offload support by:
- making aggregating gso_partial_features across slaves similar to the other feature sets (this part is a no-op).
- advertising the default partial gso features on empty bond devs, same as with other feature sets (also a no-op).
- adding NETIF_F_GSO_PARTIAL to hw_enc_features filtered across slaves.
- adding NETIF_F_GSO_PARTIAL to features in bond_setup()
With all of these, 'ethtool -k bond0 | grep esp' now reports:
tx-esp-segmentation: on
esp-hw-offload: on
esp-tx-csum-hw-offload: on
--- drivers/net/bonding/bond_main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/bonding/bond_main.c +10 -9
@@ -1538,17 +1538,20 @@ static netdev_features_t bond_fix_features(struct net_device *dev, NETIF_F_HIGHDMA | NETIF_F_LRO)#define BOND_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ - NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE) + NETIF_F_RXCSUM | NETIF_F_GSO_SOFTWARE | \ + NETIF_F_GSO_PARTIAL)#define BOND_MPLS_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ NETIF_F_GSO_SOFTWARE) +#define BOND_GSO_PARTIAL_FEATURES (NETIF_F_GSO_ESP) +static void bond_compute_features (struct bonding *bond) { +netdev_features_t gso_partial_features =BOND_GSO_PARTIAL_FEATURES ;unsigned int dst_release_flag =IFF_XMIT_DST_RELEASE |IFF_XMIT_DST_RELEASE_PERM ; -netdev_features_t gso_partial_features =NETIF_F_GSO_ESP ;netdev_features_t vlan_features =BOND_VLAN_FEATURES ;netdev_features_t enc_features =BOND_ENC_FEATURES ;#ifdef CONFIG_XFRM_OFFLOAD
@@ -1582,8 +1585,9 @@ static void bond_compute_features(struct bonding *bond) BOND_XFRM_FEATURES);#endif /* CONFIG_XFRM_OFFLOAD */ -if (slave->dev->hw_enc_features &NETIF_F_GSO_PARTIAL ) - gso_partial_features &= slave->dev->gso_partial_features; + gso_partial_features =netdev_increment_features (gso_partial_features, + slave->dev->gso_partial_features, +BOND_GSO_PARTIAL_FEATURES ); mpls_features = netdev_increment_features(mpls_features, slave->dev->mpls_features,
@@ -1598,12 +1602,8 @@ static void bond_compute_features(struct bonding *bond) } bond_dev->hard_header_len = max_hard_header_len; -if (gso_partial_features &NETIF_F_GSO_ESP ) - bond_dev->gso_partial_features |=NETIF_F_GSO_ESP ; -else - bond_dev->gso_partial_features &= ~NETIF_F_GSO_ESP ; - done: + bond_dev->gso_partial_features = gso_partial_features; bond_dev->vlan_features = vlan_features; bond_dev->hw_enc_features = enc_features |NETIF_F_GSO_ENCAP_ALL | NETIF_F_HW_VLAN_CTAG_TX |
@@ -6046,6 +6046,7 @@ void bond_setup(struct net_device *bond_dev) bond_dev->hw_features |=NETIF_F_GSO_ENCAP_ALL ; bond_dev->features |= bond_dev->hw_features; bond_dev->features |=NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; + bond_dev->features |=NETIF_F_GSO_PARTIAL ;#ifdef CONFIG_XFRM_OFFLOAD bond_dev->hw_features |=BOND_XFRM_FEATURES ;/* Only enable XFRM features if this is an active-backup config */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 538/623 s390/sclp: Initialize sclp subsystem via arch_cpu_finalize_init()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 3bcc8a1af581af152d43e42b53db3534018301b5 ]
With the switch to GENERIC_CPU_DEVICES an early call to the sclp subsystem was added to smp_prepare_cpus(). This will usually succeed since the sclp subsystem is implicitly initialized early enough if an sclp based console is present.
If no such console is present the initialization happens with an arch_initcall(); in such cases calls to the sclp subsystem will fail. For CPU detection this means that the fallback sigp loop will be used permanently to detect CPUs instead of the preferred READ_CPU_INFO sclp request.
Fix this by adding an explicit early sclp_init() call via arch_cpu_finalize_init().
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/sclp.h | 1 + arch/s390/kernel/setup.c | 5 +++++ drivers/s390/char/sclp.c | 12 ++---------- 4 files changed, 9 insertions(+), 10 deletions(-)
arch/s390/Kconfig +1 -0
@@ -72,6 +72,7 @@ config S390 select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM select ARCH_ENABLE_MEMORY_HOTREMOVE select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 + select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEBUG_VM_PGTABLE
arch/s390/include/asm/sclp.h +1 -0
@@ -137,6 +137,7 @@ void sclp_early_printk(const char *s);void __sclp_early_printk (const char *s,unsigned int len);void sclp_emergency_printk (const char *s); +int sclp_init (void );int sclp_early_get_memsize (unsigned long *mem);int sclp_early_get_hsa_size (unsigned long *hsa_size);int _sclp_get_core_info (struct sclp_core_info *info);
arch/s390/kernel/setup.c +5 -0
@@ -1006,3 +1006,8 @@ void __init setup_arch(char **cmdline_p)/* Add system specific data to the random pool */ setup_randomness (); } + +void __init arch_cpu_finalize_init (void ) +{ +sclp_init (); +}
drivers/s390/char/sclp.c +2 -10
@@ -245,7 +245,6 @@ static void sclp_request_timeout(bool force_restart);static void sclp_process_queue (void );static void __sclp_make_read_req (void );static int sclp_init_mask (int calculate); -static int sclp_init (void );static void __sclp_queue_read_req (void )
@@ -1251,8 +1250,7 @@ static struct platform_driver sclp_pdrv = {/* Initialize SCLP driver. Return zero if driver is operational, non-zero * otherwise. */ -static int -sclp_init (void ) +int sclp_init (void ) {unsigned long flags;int rc =0 ;
@@ -1305,13 +1303,7 @@ sclp_init(void)static __init int sclp_initcall (void ) { -int rc; - - rc =platform_driver_register (&sclp_pdrv); -if (rc) -return rc; - -return sclp_init (); +return platform_driver_register (&sclp_pdrv); }arch_initcall (sclp_initcall);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 539/623 perf trace: Fix runtime error of index out of bounds
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Howard Chu <[email protected]>
[ Upstream commit c7b87ce0dd10b64b68a0b22cb83bbd556e28fe81 ]
libtraceevent parses and returns an array of argument fields, sometimes larger than RAW_SYSCALL_ARGS_NUM (6) because it includes "__syscall_nr", idx will traverse to index 6 (7th element) whereas sc->fmt->arg holds 6 elements max, creating an out-of-bounds access. This runtime error is found by UBsan. The error message:
$ sudo UBSAN_OPTIONS=print_stacktrace=1 ./perf trace -a --max-events=1
builtin-trace.c:1966:35: runtime error: index 6 out of bounds for type 'syscall_arg_fmt [6]'
#0 0x5c04956be5fe in syscall__alloc_arg_fmts /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:1966
#1 0x5c04956c0510 in trace__read_syscall_info /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:2110
#2 0x5c04956c372b in trace__syscall_info /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:2436
#3 0x5c04956d2f39 in trace__init_syscalls_bpf_prog_array_maps /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:3897
#4 0x5c04956d6d25 in trace__run /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:4335
#5 0x5c04956e112e in cmd_trace /home/howard/hw/linux-perf/tools/perf/builtin-trace.c:5502
#6 0x5c04956eda7d in run_builtin /home/howard/hw/linux-perf/tools/perf/perf.c:351
#7 0x5c04956ee0a8 in handle_internal_command /home/howard/hw/linux-perf/tools/perf/perf.c:404
#8 0x5c04956ee37f in run_argv /home/howard/hw/linux-perf/tools/perf/perf.c:448
#9 0x5c04956ee8e9 in main /home/howard/hw/linux-perf/tools/perf/perf.c:556
#10 0x79eb3622a3b7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x79eb3622a47a in __libc_start_main_impl ../csu/libc-start.c:360
#12 0x5c04955422d4 in _start (/home/howard/hw/linux-perf/tools/perf/perf+0x4e02d4) (BuildId: 5b6cab2d59e96a4341741765ad6914a4d784dbc6)0.000 ( 0.014 ms): Chrome_ChildIO/117244 write(fd: 238, buf: !, count: 1) = 1
--- tools/perf/builtin-trace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +5 -1
@@ -2122,8 +2122,12 @@ static int trace__read_syscall_info(struct trace *trace, int id)return PTR_ERR (sc->tp_format); } +/* +* The tracepoint format contains __syscall_nr field, so it's one more +* than the actual number of syscall arguments. +*/ if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ? -RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields)) +RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields -1 ))return -ENOMEM ; sc->args = sc->tp_format->format.fields;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 540/623 perf test: Skip syscall enum test if no landlock syscall
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 72d81e10628be6a948463259cbb6d3b670b20054 ]
The perf trace enum augmentation test specifically targets landlock_ add_rule syscall but IIUC it's an optional and can be opt-out by a kernel config.
Currently trace_landlock() runs perf test -w landlock before the actual testing to check the availability but it's not enough since the workload always returns 0. Instead it could check if perf trace output has 'landlock' string.
--- tools/perf/tests/shell/trace_btf_enum.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/perf/tests/shell/trace_btf_enum.sh +6 -2
@@ -26,8 +26,12 @@ check_vmlinux() { trace_landlock() { echo "Tracing syscall ${syscall}" - # test flight just to see if landlock_add_rule and libbpf are available - $TESTPROG + # test flight just to see if landlock_add_rule is available + if ! perf trace $TESTPROG 2>&1 | grep -q landlock + then + echo "No landlock system call found, skipping to non-syscall tracing." + return + fi if perf trace -e $syscall $TESTPROG 2>&1 | \ grep -q -E ".*landlock_add_rule\(ruleset_fd: 11, rule_type: (LANDLOCK_RULE_PATH_BENEATH|LANDLOCK_RULE_NET_PORT), rule_attr: 0x[a-f0-9]+, flags: 45\) = -1.*"
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 541/623 PM: sleep: core: Synchronize runtime PM status of parents and children
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 3775fc538f535a7c5adaf11990c7932a0bd1f9eb ]
Commit 6e176bf8d461 ("PM: sleep: core: Do not skip callbacks in the resume phase") overlooked the case in which the parent of a device with DPM_FLAG_SMART_SUSPEND set did not use that flag and could be runtime- suspended before a transition into a system-wide sleep state. In that case, if the child is resumed during the subsequent transition from that state into the working state, its runtime PM status will be set to RPM_ACTIVE, but the runtime PM status of the parent will not be updated accordingly, even though the parent will be resumed too, because of the dev_pm_skip_suspend() check in device_resume_noirq().
Address this problem by tracking the need to set the runtime PM status to RPM_ACTIVE during system-wide resume transitions for devices with DPM_FLAG_SMART_SUSPEND set and all of the devices depended on by them.
--- drivers/base/power/main.c | 29 ++++++++++++++++++++--------- include/linux/pm.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/base/power/main.c +20 -9
@@ -642,13 +642,15 @@ static void device_resume_noirq(struct device *dev, pm_message_t state, bool asy* so change its status accordingly. * * Otherwise, the device is going to be resumed, so set its PM-runtime -* status to "active", but do that only if DPM_FLAG_SMART_SUSPEND is set -* to avoid confusing drivers that don't use it. +* status to "active" unless its power.set_active flag is clear, in +* which case it is not necessary to update its PM-runtime status. */ -if (skip_resume) +if (skip_resume) {pm_runtime_set_suspended (dev); -else if (dev_pm_skip_suspend (dev)) + }else if (dev->power.set_active) {pm_runtime_set_active (dev); + dev->power.set_active = false; + }if (dev->pm_domain) { info ="noirq power domain " ;
@@ -1175,18 +1177,24 @@ static pm_message_t resume_event(pm_message_t sleep_state)return PMSG_ON ; } -static void dpm_superior_set_must_resume (struct device *dev) +static void dpm_superior_set_must_resume (struct device *dev,bool set_active) {struct device_link *link;int idx; -if (dev->parent) +if (dev->parent) { dev->parent->power.must_resume = true; +if (set_active) + dev->parent->power.set_active = true; + } idx =device_links_read_lock (); -list_for_each_entry_rcu_locked (link, &dev->links.suppliers, c_node) +list_for_each_entry_rcu_locked (link, &dev->links.suppliers, c_node) { link->supplier->power.must_resume = true; +if (set_active) + link->supplier->power.set_active = true; + }device_links_read_unlock (idx); }
@@ -1264,8 +1272,11 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state, bool asy dev->power.may_skip_resume)) dev->power.must_resume = true; -if (dev->power.must_resume) -dpm_superior_set_must_resume (dev); +if (dev->power.must_resume) { + dev->power.set_active = dev->power.set_active || +dev_pm_test_driver_flags (dev,DPM_FLAG_SMART_SUSPEND ); +dpm_superior_set_must_resume (dev, dev->power.set_active); + } Complete:complete_all (&dev->power.completion);
include/linux/pm.h +1 -0
@@ -683,6 +683,7 @@ struct dev_pm_info { bool no_pm_callbacks:1; /* Owned by the PM core */ bool async_in_progress:1; /* Owned by the PM core */ bool must_resume:1; /* Owned by the PM core */ + bool set_active:1; /* Owned by the PM core */ bool may_skip_resume:1; /* Set by subsystems */#else bool should_wakeup:1;
Signature · 1 line
2.39.5
Re: [PATCH 6.13 541/623] PM: sleep: core: Synchronize runtime PM status of parents and children
Quoted 22 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit
3775fc538f535a7c5adaf11990c7932a0bd1f9eb]Commit
6e176bf8d461("PM: sleep: core: Do not skip callbacks in the resume phase") overlooked the case in which the parent of a device withDPM_FLAG_SMART_SUSPENDset did not use that flag and could be runtime- suspended before a transition into a system-wide sleep state. In that case, if the child is resumed during the subsequent transition from that state into the working state, its runtime PM status will be set toRPM_ACTIVE, but the runtime PM status of the parent will not be updated accordingly, even though the parent will be resumed too, because of thedev_pm_skip_suspend()check indevice_resume_noirq().Address this problem by tracking the need to set the runtime PM status to
RPM_ACTIVEduring system-wide resume transitions for devices withDPM_FLAG_SMART_SUSPENDset and all of the devices depended on by them.
Quoted 9 lines
Fixes 6e176bf8d461 ("PM: sleep: core: Do not skip callbacks in the resume phase")Reported-by Johan Hovold <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Johan Hovold <[email protected]>Tested-by Johan Hovold <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This patch appears to be causing trouble and should not be backported, at least not until this has been resolved:
https://lore.kernel.org/all/[email protected]/
Please drop from all stable queues.
Johan
Greg Kroah-Hartman
maintainerRe: [PATCH 6.13 541/623] PM: sleep: core: Synchronize runtime PM status of parents and children
Quoted 33 lines · Johan Hovold
Quoted 22 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit
3775fc538f535a7c5adaf11990c7932a0bd1f9eb]Commit
6e176bf8d461("PM: sleep: core: Do not skip callbacks in the resume phase") overlooked the case in which the parent of a device withDPM_FLAG_SMART_SUSPENDset did not use that flag and could be runtime- suspended before a transition into a system-wide sleep state. In that case, if the child is resumed during the subsequent transition from that state into the working state, its runtime PM status will be set toRPM_ACTIVE, but the runtime PM status of the parent will not be updated accordingly, even though the parent will be resumed too, because of thedev_pm_skip_suspend()check indevice_resume_noirq().Address this problem by tracking the need to set the runtime PM status to
RPM_ACTIVEduring system-wide resume transitions for devices withDPM_FLAG_SMART_SUSPENDset and all of the devices depended on by them.Quoted 9 lines
Fixes 6e176bf8d461 ("PM: sleep: core: Do not skip callbacks in the resume phase")Reported-by Johan Hovold <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Johan Hovold <[email protected]>Tested-by Johan Hovold <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 6 lines
This patch appears to be causing trouble and should not be backported, at least not until this has been resolved:
https://lore.kernel.org/all/[email protected]/Please drop from all stable queues.
Already done, and -rc2 releases were sent out yesterday with it removed.
thanks,
greg k-h
Re: [PATCH 6.13 541/623] PM: sleep: core: Synchronize runtime PM status of parents and children
Quoted 10 lines · Greg Kroah-Hartman
Quoted 6 lines · Johan Hovold
This patch appears to be causing trouble and should not be backported, at least not until this has been resolved:
https://lore.kernel.org/all/[email protected]/Please drop from all stable queues.
Already done, and -rc2 releases were sent out yesterday with it removed.
Ah, good. I found Jon's stable test report now.
Johan
Greg Kroah-Hartman
maintainerPATCH 542/623 Bluetooth: btusb: mediatek: Add locks for usb_driver_claim_interface()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit e9087e828827e5a5c85e124ce77503f2b81c3491 ]
The documentation for usb_driver_claim_interface() says that "the device lock" is needed when the function is called from places other than probe(). This appears to be the lock for the USB interface device. The Mediatek btusb code gets called via this path:
Workqueue: hci0 hci_power_on [bluetooth] Call trace: usb_driver_claim_interface btusb_mtk_claim_iso_intf btusb_mtk_setup hci_dev_open_sync hci_power_on process_scheduled_works worker_thread kthread
With the above call trace the device lock hasn't been claimed. Claim it.
Without this fix, we'd sometimes see the error "Failed to claim iso interface". Sometimes we'd even see worse errors, like a NULL pointer dereference (where intf->dev.driver was NULL) with a trace like:
Call trace: usb_suspend_both usb_runtime_suspend __rpm_callback rpm_suspend pm_runtime_work process_scheduled_works
Both errors appear to be fixed with the proper locking.
--- drivers/bluetooth/btusb.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/bluetooth/btusb.c +7 -0
@@ -2638,8 +2638,15 @@ static void btusb_mtk_claim_iso_intf(struct btusb_data *data)struct btmtk_data *btmtk_data =hci_get_priv (data->hdev);int err; +/* +* The function usb_driver_claim_interface() is documented to need +* locks held if it's not called from a probe routine. The code here +* is called from the hci_power_on workqueue, so grab the lock. +*/ +device_lock (&btmtk_data->isopkt_intf->dev); err =usb_driver_claim_interface (&btusb_driver, btmtk_data->isopkt_intf, data); +device_unlock (&btmtk_data->isopkt_intf->dev);if (err <0 ) { btmtk_data->isopkt_intf =NULL ;bt_dev_err (data->hdev,"Failed to claim iso interface" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 543/623 Bluetooth: btnxpuart: Fix glitches seen in dual A2DP streaming
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neeraj Sanjay Kale <[email protected]>
[ Upstream commit 7de119bb79a63f6a1959b83117a98734914fb0b0 ]
This fixes a regression caused by previous commit for fixing truncated ACL data, which is causing some intermittent glitches when running two A2DP streams.
serdev_device_write_buf() is the root cause of the glitch, which is reverted, and the TX work will continue to write until the queue is empty.
This change fixes both issues. No A2DP streaming glitches or truncated ACL data issue observed.
--- drivers/bluetooth/btnxpuart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bluetooth/btnxpuart.c +1 -2
@@ -1381,13 +1381,12 @@ static void btnxpuart_tx_work(struct work_struct *work)while ((skb =nxp_dequeue (nxpdev))) { len =serdev_device_write_buf (serdev, skb->data, skb->len); -serdev_device_wait_until_sent (serdev,0 ); hdev->stat.byte_tx += len;skb_pull (skb, len);if (skb->len >0 ) {skb_queue_head (&nxpdev->txq, skb); -break ; +continue ; }switch (hci_skb_pkt_type (skb)) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 544/623 vsock: Keep the binding until socket destruction
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit fcdd2242c0231032fc84e1404315c245ae56322a ]
Preserve sockets bindings; this includes both resulting from an explicit bind() and those implicitly bound through autobind during connect().
Prevents socket unbinding during a transport reassignment, which fixes a use-after-free:
1. vsock_create() (refcnt=1) calls vsock_insert_unbound() (refcnt=2)
2. transport->release() calls vsock_remove_bound() without checking if sk was bound and moved to bound list (refcnt=1)
3. vsock_bind() assumes sk is in unbound list and before __vsock_insert_bound(vsock_bound_sockets()) calls __vsock_remove_bound() which does:
list_del_init(&vsk->bound_table); // nop
sock_put(&vsk->sk); // refcnt=0
BUG: KASAN: slab-use-after-free in __vsock_bind+0x62e/0x730 Read of size 4 at addr ffff88816b46a74c by task a.out/2057 dump_stack_lvl+0x68/0x90 print_report+0x174/0x4f6 kasan_report+0xb9/0x190 __vsock_bind+0x62e/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e Allocated by task 2057: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 __kasan_slab_alloc+0x85/0x90 kmem_cache_alloc_noprof+0x131/0x450 sk_prot_alloc+0x5b/0x220 sk_alloc+0x2c/0x870 __vsock_create.constprop.0+0x2e/0xb60 vsock_create+0xe4/0x420 __sock_create+0x241/0x650 __sys_socket+0xf2/0x1a0 __x64_sys_socket+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e Freed by task 2057: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 kasan_save_free_info+0x37/0x60 __kasan_slab_free+0x4b/0x70 kmem_cache_free+0x1a1/0x590 __sk_destruct+0x388/0x5a0 __vsock_bind+0x5e1/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 7 PID: 2057 at lib/refcount.c:25 refcount_warn_saturate+0xce/0x150 RIP: 0010:refcount_warn_saturate+0xce/0x150 __vsock_bind+0x66d/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: underflow; use-after-free.
WARNING: CPU: 7 PID: 2057 at lib/refcount.c:28 refcount_warn_saturate+0xee/0x150 RIP: 0010:refcount_warn_saturate+0xee/0x150 vsock_remove_bound+0x187/0x1e0 __vsock_release+0x383/0x4a0 vsock_release+0x90/0x120 __sock_release+0xa3/0x250 sock_close+0x14/0x20 __fput+0x359/0xa80 task_work_run+0x107/0x1d0 do_exit+0x847/0x2560 do_group_exit+0xb8/0x250 __x64_sys_exit_group+0x3a/0x50 x64_sys_call+0xfec/0x14f0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- net/vmw_vsock/af_vsock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/vmw_vsock/af_vsock.c +6 -2
@@ -337,7 +337,10 @@ EXPORT_SYMBOL_GPL(vsock_find_connected_socket);void vsock_remove_sock (struct vsock_sock *vsk) { -vsock_remove_bound (vsk); +/* Transport reassignment must not remove the binding. */ +if (sock_flag (sk_vsock (vsk),SOCK_DEAD )) +vsock_remove_bound (vsk); +vsock_remove_connected (vsk); }EXPORT_SYMBOL_GPL (vsock_remove_sock);
@@ -821,12 +824,13 @@ static void __vsock_release(struct sock *sk, int level)*/ lock_sock_nested (sk, level); +sock_orphan (sk); +if (vsk->transport) vsk->transport->release (vsk);else if (sock_type_connectible (sk->sk_type))vsock_remove_sock (vsk); -sock_orphan (sk); sk->sk_shutdown =SHUTDOWN_MASK ;skb_queue_purge (&sk->sk_receive_queue);
Signature · 1 line
2.39.5
Re: [PATCH 6.13 544/623] vsock: Keep the binding until socket destruction
Quoted 8 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit
fcdd2242c0231032fc84e1404315c245ae56322a]
Hi Greg,
This patch introduced a bug[1], Michal has already sent a patch to fix it [2], but has not been merged yet. Should we wait and merge them together? WDYT?
Thanks,
Luigi
[1]https://lore.kernel.org/all/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
Quoted 129 lines
Preserve sockets bindings; this includes both resulting from an explicit
bind()and those implicitly bound through autobind duringconnect().Prevents socket unbinding during a transport reassignment, which fixes a use-after-free:
1.
vsock_create()(refcnt=1) callsvsock_insert_unbound()(refcnt=2)
2.transport->release()callsvsock_remove_bound()without checking if sk was bound and moved to bound list (refcnt=1)
3.vsock_bind()assumes sk is in unbound list and before__vsock_insert_bound(vsock_bound_sockets()) calls __vsock_remove_bound() which does: list_del_init(&vsk->bound_table); // nop sock_put(&vsk->sk); // refcnt=0BUG: KASAN: slab-use-after-free in __vsock_bind+0x62e/0x730 Read of size 4 at addr ffff88816b46a74c by task a.out/2057 dump_stack_lvl+0x68/0x90 print_report+0x174/0x4f6 kasan_report+0xb9/0x190 __vsock_bind+0x62e/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e Allocated by task 2057: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 __kasan_slab_alloc+0x85/0x90 kmem_cache_alloc_noprof+0x131/0x450 sk_prot_alloc+0x5b/0x220 sk_alloc+0x2c/0x870 __vsock_create.constprop.0+0x2e/0xb60 vsock_create+0xe4/0x420 __sock_create+0x241/0x650 __sys_socket+0xf2/0x1a0 __x64_sys_socket+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e Freed by task 2057: kasan_save_stack+0x1e/0x40 kasan_save_track+0x10/0x30 kasan_save_free_info+0x37/0x60 __kasan_slab_free+0x4b/0x70 kmem_cache_free+0x1a1/0x590 __sk_destruct+0x388/0x5a0 __vsock_bind+0x5e1/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: addition on 0; use-after-free.WARNING: CPU: 7 PID: 2057 at lib/refcount.c:25 refcount_warn_saturate+0xce/0x150 RIP: 0010:refcount_warn_saturate+0xce/0x150 __vsock_bind+0x66d/0x730 vsock_bind+0x97/0xe0 __sys_bind+0x154/0x1f0 __x64_sys_bind+0x6e/0xb0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
refcount_t: underflow; use-after-free.WARNING: CPU: 7 PID: 2057 at lib/refcount.c:28 refcount_warn_saturate+0xee/0x150 RIP: 0010:refcount_warn_saturate+0xee/0x150 vsock_remove_bound+0x187/0x1e0 __vsock_release+0x383/0x4a0 vsock_release+0x90/0x120 __sock_release+0xa3/0x250 sock_close+0x14/0x20 __fput+0x359/0xa80 task_work_run+0x107/0x1d0 do_exit+0x847/0x2560 do_group_exit+0xb8/0x250 __x64_sys_exit_group+0x3a/0x50 x64_sys_call+0xfec/0x14f0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7eFixes c0cfa2d8a788 ("vsock: add multi-transports support")Reviewed-by Stefano Garzarella <[email protected]>Signed-off-by Michal Luczaj <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
net/vmw_vsock/af_vsock.c| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)net/vmw_vsock/af_vsock.c +6
-2@@ -337,7 +337,10 @@ EXPORT_SYMBOL_GPL(vsock_find_connected_socket);void vsock_remove_sock (struct vsock_sock *vsk) { -vsock_remove_bound (vsk); +/* Transport reassignment must not remove the binding. */ +if (sock_flag (sk_vsock (vsk),SOCK_DEAD )) +vsock_remove_bound (vsk); +vsock_remove_connected (vsk); }EXPORT_SYMBOL_GPL (vsock_remove_sock);@@ -821,12 +824,13 @@ static void __vsock_release(struct sock *sk, int level)*/ lock_sock_nested (sk, level); +sock_orphan (sk); +if (vsk->transport) vsk->transport->release (vsk);else if (sock_type_connectible (sk->sk_type))vsock_remove_sock (vsk); -sock_orphan (sk); sk->sk_shutdown =SHUTDOWN_MASK ;skb_queue_purge (&sk->sk_receive_queue);Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerRe: [PATCH 6.13 544/623] vsock: Keep the binding until socket destruction
Quoted 7 lines · Luigi Leonardi
Quoted 6 lines · Greg Kroah-Hartman
6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
Quoted 7 lines
Quoted 2 lines
[ Upstream commit
fcdd2242c0231032fc84e1404315c245ae56322a]Hi Greg,
This patch introduced a bug[1], Michal has already sent a patch to fix it [2], but has not been merged yet. Should we wait and merge them together? WDYT?
Yes, please submit both of these to stable@vger when they hit Linus's tree. I'll go drop this now from all queues.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 545/623 vsock: Allow retrying on connect() failure
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit aa388c72113b7458127b709bdd7d3628af26e9b4 ]
sk_err is set when a (connectible) connect() fails. Effectively, this makes an otherwise still healthy SS_UNCONNECTED socket impossible to use for any subsequent connection attempts.
Clear sk_err upon trying to establish a connection.
--- net/vmw_vsock/af_vsock.c | 5 +++++ 1 file changed, 5 insertions(+)
net/vmw_vsock/af_vsock.c +5 -0
@@ -1523,6 +1523,11 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,if (err <0 ) goto out; +/* sk_err might have been set as a result of an earlier +* (failed) connect attempt. +*/ + sk->sk_err =0 ; +/* Mark sock as connecting and set the error code to in * progress in case this is a non-blocking connect. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 546/623 bgmac: reduce max frame size to support just MTU 1500
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
[ Upstream commit 752e5fcc2e77358936d36ef8e522d6439372e201 ]
bgmac allocates new replacement buffer before handling each received frame. Allocating & DMA-preparing 9724 B each time consumes a lot of CPU time. Ideally bgmac should just respect currently set MTU but it isn't the case right now. For now just revert back to the old limited frame size.
This change bumps NAT masquerade speed by ~95%.
Since commit 8218f62c9c9b ("mm: page_frag: use initial zero offset for page_frag_alloc_align()"), the bgmac driver fails to open its network interface successfully and runs out of memory in the following call stack:
bgmac_open
-> bgmac_dma_init
-> bgmac_dma_rx_skb_for_slot
-> netdev_alloc_fragBGMAC_RX_ALLOC_SIZE = 10048 and PAGE_FRAG_CACHE_MAX_SIZE = 32768.
Eventually we land into __page_frag_alloc_align() with the following parameters across multiple successive calls:
__page_frag_alloc_align: fragsz=10048, align_mask=-1, size=32768, offset=0 __page_frag_alloc_align: fragsz=10048, align_mask=-1, size=32768, offset=10048 __page_frag_alloc_align: fragsz=10048, align_mask=-1, size=32768, offset=20096 __page_frag_alloc_align: fragsz=10048, align_mask=-1, size=32768, offset=30144
So in that case we do indeed have offset + fragsz (40192) > size (32768) and so we would eventually return NULL. Reverting to the older 1500 bytes MTU allows the network driver to be usable again.
--- drivers/net/ethernet/broadcom/bgmac.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bgmac.h +1 -2
@@ -328,8 +328,7 @@#define BGMAC_RX_FRAME_OFFSET 30/* There are 2 unused bytes between header and real data */ #define BGMAC_RX_BUF_OFFSET (NET_SKB_PAD + NET_IP_ALIGN - \ BGMAC_RX_FRAME_OFFSET) -/* Jumbo frame size with FCS */ -#define BGMAC_RX_MAX_FRAME_SIZE 9724 +#define BGMAC_RX_MAX_FRAME_SIZE 1536#define BGMAC_RX_BUF_SIZE (BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE)#define BGMAC_RX_ALLOC_SIZE (SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 547/623 tcp: correct handling of extreme memory squeeze
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Maloy <[email protected]>
[ Upstream commit 8c670bdfa58e48abad1d5b6ca1ee843ca91f7303 ]
Testing with iperf3 using the "pasta" protocol splicer has revealed a problem in the way tcp handles window advertising in extreme memory squeeze situations.
Under memory pressure, a socket endpoint may temporarily advertise a zero-sized window, but this is not stored as part of the socket data. The reasoning behind this is that it is considered a temporary setting which shouldn't influence any further calculations.
However, if we happen to stall at an unfortunate value of the current window size, the algorithm selecting a new value will consistently fail to advertise a non-zero window once we have freed up enough memory. This means that this side's notion of the current window size is different from the one last advertised to the peer, causing the latter to not send any data to resolve the sitution.
The problem occurs on the iperf3 server side, and the socket in question is a completely regular socket with the default settings for the fedora40 kernel. We do not use SO_PEEK or SO_RCVBUF on the socket.
The following excerpt of a logging session, with own comments added, shows more in detail what is happening:
// tcp_v4_rcv(->)
// tcp_rcv_established(->)
[5201<->39222]: ==== Activating log @ net/ipv4/tcp_input.c/tcp_data_queue()/5257 ====
[5201<->39222]: tcp_data_queue(->)
[5201<->39222]: DROPPING skb [265600160..265665640], reason: SKB_DROP_REASON_PROTO_MEM
[rcv_nxt 265600160, rcv_wnd 262144, snt_ack 265469200, win_now 131184]
[copied_seq 259909392->260034360 (124968), unread 5565800, qlen 85, ofoq 0]
[OFO queue: gap: 65480, len: 0]
[5201<->39222]: tcp_data_queue(<-)
[5201<->39222]: __tcp_transmit_skb(->)
[tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160]
[5201<->39222]: tcp_select_window(->)
[5201<->39222]: (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_NOMEM) ? --> TRUE
[tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160]
returning 0[5201<->39222]: tcp_select_window(<-)
[5201<->39222]: ADVERTISING WIN 0, ACK_SEQ: 265600160
[5201<->39222]: [__tcp_transmit_skb(<-)
[5201<->39222]: tcp_rcv_established(<-)
[5201<->39222]: tcp_v4_rcv(<-)
// Receive queue is at 85 buffers and we are out of memory. // We drop the incoming buffer, although it is in sequence, and decide // to send an advertisement with a window of zero.
// We don't update tp->rcv_wnd and tp->rcv_wup accordingly, which means // we unconditionally shrink the window.
[5201<->39222]: tcp_recvmsg_locked(->)
[5201<->39222]: __tcp_cleanup_rbuf(->) tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160
[5201<->39222]: [new_win = 0, win_now = 131184, 2 * win_now = 262368]
[5201<->39222]: [new_win >= (2 * win_now) ? --> time_to_ack = 0]
[5201<->39222]: NOT calling tcp_send_ack()
[tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160]
[5201<->39222]: __tcp_cleanup_rbuf(<-)
[rcv_nxt 265600160, rcv_wnd 262144, snt_ack 265469200, win_now 131184]
[copied_seq 260040464->260040464 (0), unread 5559696, qlen 85, ofoq 0]
returning 6104 bytes[5201<->39222]: tcp_recvmsg_locked(<-)
// After each read, the algorithm for calculating the new receive // window in __tcp_cleanup_rbuf() finds it is too small to advertise // or to update tp->rcv_wnd.
// Meanwhile, the peer thinks the window is zero, and will not send // any more data to trigger an update from the interrupt mode side.
[5201<->39222]: tcp_recvmsg_locked(->)
[5201<->39222]: __tcp_cleanup_rbuf(->) tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160
[5201<->39222]: [new_win = 262144, win_now = 131184, 2 * win_now = 262368]
[5201<->39222]: [new_win >= (2 * win_now) ? --> time_to_ack = 0]
[5201<->39222]: NOT calling tcp_send_ack()
[tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160]
[5201<->39222]: __tcp_cleanup_rbuf(<-)
[rcv_nxt 265600160, rcv_wnd 262144, snt_ack 265469200, win_now 131184]
[copied_seq 260099840->260171536 (71696), unread 5428624, qlen 83, ofoq 0]
returning 131072 bytes[5201<->39222]: tcp_recvmsg_locked(<-)
// The above pattern repeats again and again, since nothing changes // between the reads.
[...]
[5201<->39222]: tcp_recvmsg_locked(->)
[5201<->39222]: __tcp_cleanup_rbuf(->) tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160
[5201<->39222]: [new_win = 262144, win_now = 131184, 2 * win_now = 262368]
[5201<->39222]: [new_win >= (2 * win_now) ? --> time_to_ack = 0]
[5201<->39222]: NOT calling tcp_send_ack()
[tp->rcv_wup: 265469200, tp->rcv_wnd: 262144, tp->rcv_nxt 265600160]
[5201<->39222]: __tcp_cleanup_rbuf(<-)
[rcv_nxt 265600160, rcv_wnd 262144, snt_ack 265469200, win_now 131184]
[copied_seq 265600160->265600160 (0), unread 0, qlen 0, ofoq 0]
returning 54672 bytes[5201<->39222]: tcp_recvmsg_locked(<-)
// The receive queue is empty, but no new advertisement has been sent. // The peer still thinks the receive window is zero, and sends nothing. // We have ended up in a deadlock situation.
Note that well behaved endpoints will send win0 probes, so the problem will not occur.
Furthermore, we have observed that in these situations this side may send out an updated 'th->ack_seq´ which is not stored in tp->rcv_wup as it should be. Backing ack_seq seems to be harmless, but is of course still wrong from a protocol viewpoint.
We fix this by updating the socket state correctly when a packet has been dropped because of memory exhaustion and we have to advertize a zero window.
Further testing shows that the connection recovers neatly from the squeeze situation, and traffic can continue indefinitely.
--- net/ipv4/tcp_output.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/ipv4/tcp_output.c +6 -3
@@ -265,11 +265,14 @@ static u16 tcp_select_window(struct sock *sk)u32 cur_win, new_win;/* Make the window 0 if we failed to queue the data because we -* are out of memory. The window is temporary, so we don't store -* it on the socket. +* are out of memory. */ -if (unlikely (inet_csk (sk)->icsk_ack.pending &ICSK_ACK_NOMEM )) +if (unlikely (inet_csk (sk)->icsk_ack.pending &ICSK_ACK_NOMEM )) { + tp->pred_flags =0 ; + tp->rcv_wnd =0 ; + tp->rcv_wup = tp->rcv_nxt;return 0 ; + } cur_win =tcp_receive_window (tp); new_win =__tcp_select_window (sk);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 548/623 net: xdp: Disallow attaching device-bound programs in generic mode
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 3595599fa8360bb3c7afa7ee50c810b4a64106ea ]
Device-bound programs are used to support RX metadata kfuncs. These kfuncs are driver-specific and rely on the driver context to read the metadata. This means they can't work in generic XDP mode. However, there is no check to disallow such programs from being attached in generic mode, in which case the metadata kfuncs will be called in an invalid context, leading to crashes.
Fix this by adding a check to disallow attaching device-bound programs in generic mode.
--- net/core/dev.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/dev.c +4 -0
@@ -9699,6 +9699,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extackNL_SET_ERR_MSG (extack,"Program bound to different device" );return -EINVAL ; } +if (bpf_prog_is_dev_bound (new_prog->aux) && mode ==XDP_MODE_SKB ) { +NL_SET_ERR_MSG (extack,"Can't attach device-bound programs in generic mode" ); +return -EINVAL ; + }if (new_prog->expected_attach_type ==BPF_XDP_DEVMAP ) {NL_SET_ERR_MSG (extack,"BPF_XDP_DEVMAP programs can not be attached to a device" );return -EINVAL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 549/623 net: ravb: Fix missing rtnl lock in suspend/resume path
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kory Maincent <[email protected]>
[ Upstream commit 2c2ebb2b49573e5f8726112ad06b1dffc3c9ea03 ]
Fix the suspend/resume path by ensuring the rtnl lock is held where required. Calls to ravb_open, ravb_close and wol operations must be performed under the rtnl lock to prevent conflicts with ongoing ndo operations.
Without this fix, the following warning is triggered:
[ 39.032969] ============================= [ 39.032983] WARNING: suspicious RCU usage [ 39.033019] ----------------------------- [ 39.033033] drivers/net/phy/phy_device.c:2004 suspicious rcu_dereference_protected() usage! ... [ 39.033597] stack backtrace: [ 39.033613] CPU: 0 UID: 0 PID: 174 Comm: python3 Not tainted 6.13.0-rc7-next-20250116-arm64-renesas-00002-g35245dfdc62c #7 [ 39.033623] Hardware name: Renesas SMARC EVK version 2 based on r9a08g045s33 (DT) [ 39.033628] Call trace: [ 39.033633] show_stack+0x14/0x1c (C) [ 39.033652] dump_stack_lvl+0xb4/0xc4 [ 39.033664] dump_stack+0x14/0x1c [ 39.033671] lockdep_rcu_suspicious+0x16c/0x22c [ 39.033682] phy_detach+0x160/0x190 [ 39.033694] phy_disconnect+0x40/0x54 [ 39.033703] ravb_close+0x6c/0x1cc [ 39.033714] ravb_suspend+0x48/0x120 [ 39.033721] dpm_run_callback+0x4c/0x14c [ 39.033731] device_suspend+0x11c/0x4dc [ 39.033740] dpm_suspend+0xdc/0x214 [ 39.033748] dpm_suspend_start+0x48/0x60 [ 39.033758] suspend_devices_and_enter+0x124/0x574 [ 39.033769] pm_suspend+0x1ac/0x274 [ 39.033778] state_store+0x88/0x124 [ 39.033788] kobj_attr_store+0x14/0x24 [ 39.033798] sysfs_kf_write+0x48/0x6c [ 39.033808] kernfs_fop_write_iter+0x118/0x1a8 [ 39.033817] vfs_write+0x27c/0x378 [ 39.033825] ksys_write+0x64/0xf4 [ 39.033833] __arm64_sys_write+0x18/0x20 [ 39.033841] invoke_syscall+0x44/0x104 [ 39.033852] el0_svc_common.constprop.0+0xb4/0xd4 [ 39.033862] do_el0_svc+0x18/0x20 [ 39.033870] el0_svc+0x3c/0xf0 [ 39.033880] el0t_64_sync_handler+0xc0/0xc4 [ 39.033888] el0t_64_sync+0x154/0x158 [ 39.041274] ravb 11c30000.ethernet eth0: Link is Down
--- drivers/net/ethernet/renesas/ravb_main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/net/ethernet/renesas/ravb_main.c +14 -8
@@ -3217,10 +3217,15 @@ static int ravb_suspend(struct device *dev)netif_device_detach (ndev); -if (priv->wol_enabled) -return ravb_wol_setup (ndev); +rtnl_lock (); +if (priv->wol_enabled) { + ret =ravb_wol_setup (ndev); +rtnl_unlock (); +return ret; + } ret =ravb_close (ndev); +rtnl_unlock ();if (ret)return ret;
@@ -3245,19 +3250,20 @@ static int ravb_resume(struct device *dev)if (!netif_running (ndev))return 0 ; +rtnl_lock ();/* If WoL is enabled restore the interface. */ -if (priv->wol_enabled) { +if (priv->wol_enabled) ret =ravb_wol_restore (ndev); -if (ret) -return ret; - }else { +else ret =pm_runtime_force_resume (dev); -if (ret) -return ret; +if (ret) { +rtnl_unlock (); +return ret; }/* Reopening the interface will restore the device to the working state. */ ret =ravb_open (ndev); +rtnl_unlock ();if (ret <0 ) goto out_rpm_put;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 550/623 net: sh_eth: Fix missing rtnl lock in suspend/resume path
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kory Maincent <[email protected]>
[ Upstream commit b95102215a8d0987789715ce11c0d4ec031cbfbe ]
Fix the suspend/resume path by ensuring the rtnl lock is held where required. Calls to sh_eth_close, sh_eth_open and wol operations must be performed under the rtnl lock to prevent conflicts with ongoing ndo operations.
--- drivers/net/ethernet/renesas/sh_eth.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +4 -0
@@ -3494,10 +3494,12 @@ static int sh_eth_suspend(struct device *dev)netif_device_detach (ndev); +rtnl_lock ();if (mdp->wol_enabled) ret =sh_eth_wol_setup (ndev);else ret =sh_eth_close (ndev); +rtnl_unlock ();return ret; }
@@ -3511,10 +3513,12 @@ static int sh_eth_resume(struct device *dev)if (!netif_running (ndev))return 0 ; +rtnl_lock ();if (mdp->wol_enabled) ret =sh_eth_wol_restore (ndev);else ret =sh_eth_open (ndev); +rtnl_unlock ();if (ret <0 )return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 551/623 net: hsr: fix fill_frame_info() regression vs VLAN packets
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 0f5697f1a3f99bc2b674b8aa3c5da822c5673c11 ]
Stephan Wurm reported that my recent patch broke VLAN support.
Apparently skb->mac_len is not correct for VLAN traffic as shown by debug traces [1].
Use instead pskb_may_pull() to make sure the expected header is present in skb->head.
Many thanks to Stephan for his help.
[1]
kernel: skb len=170 headroom=2 headlen=170 tailroom=20
mac=(2,14) mac_len=14 net=(16,-1) trans=-1
shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0))
csum(0x0 start=0 offset=0 ip_summed=0 complete_sw=0 valid=0 level=0)
hash(0x0 sw=0 l4=0) proto=0x0000 pkttype=0 iif=0
priority=0x0 mark=0x0 alloc_cpu=0 vlan_all=0x0
encapsulation=0 inner(proto=0x0000, mac=0, net=0, trans=0)kernel: dev name=prp0 feat=0x0000000000007000
kernel: sk family=17 type=3 proto=0
kernel: skb headroom: 00000000: 74 00
kernel: skb linear: 00000000: 01 0c cd 01 00 01 00 d0 93 53 9c cb 81 00 80 00
kernel: skb linear: 00000010: 88 b8 00 01 00 98 00 00 00 00 61 81 8d 80 16 52
kernel: skb linear: 00000020: 45 47 44 4e 43 54 52 4c 2f 4c 4c 4e 30 24 47 4f
kernel: skb linear: 00000030: 24 47 6f 43 62 81 01 14 82 16 52 45 47 44 4e 43
kernel: skb linear: 00000040: 54 52 4c 2f 4c 4c 4e 30 24 44 73 47 6f 6f 73 65
kernel: skb linear: 00000050: 83 07 47 6f 49 64 65 6e 74 84 08 67 8d f5 93 7e
kernel: skb linear: 00000060: 76 c8 00 85 01 01 86 01 00 87 01 00 88 01 01 89
kernel: skb linear: 00000070: 01 00 8a 01 02 ab 33 a2 15 83 01 00 84 03 03 00
kernel: skb linear: 00000080: 00 91 08 67 8d f5 92 77 4b c6 1f 83 01 00 a2 1a
kernel: skb linear: 00000090: a2 06 85 01 00 83 01 00 84 03 03 00 00 91 08 67
kernel: skb linear: 000000a0: 8d f5 92 77 4b c6 1f 83 01 00
kernel: skb tailroom: 00000000: 80 18 02 00 fe 4e 00 00 01 01 08 0a 4f fd 5e d1
kernel: skb tailroom: 00000010: 4f fd 5e cd
--- net/hsr/hsr_forward.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/hsr/hsr_forward.c +5 -2
@@ -700,9 +700,12 @@ static int fill_frame_info(struct hsr_frame_info *frame, frame->is_vlan = true;if (frame->is_vlan) { - if (skb->mac_len < offsetofend(struct hsr_vlan_ethhdr, vlanhdr)) +/* Note: skb->mac_len might be wrong here. */ +if (!pskb_may_pull (skb, +skb_mac_offset (skb) + + offsetofend(struct hsr_vlan_ethhdr, vlanhdr)))return -EINVAL ; - vlan_hdr = (struct hsr_vlan_ethhdr *)ethhdr; + vlan_hdr = (struct hsr_vlan_ethhdr *)skb_mac_header (skb); proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 552/623 genksyms: fix memory leak when the same symbol is added from source
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 45c9c4101d3d2fdfa00852274bbebba65fcc3cf2 ]
When a symbol that is already registered is added again, __add_symbol() returns without freeing the symbol definition, making it unreachable.
The following test cases demonstrate different memory leak points.
[Test Case 1]
Forward declaration with exactly the same definition
$ cat foo.c
#include <linux/export.h>
void foo(void);
void foo(void) {}
EXPORT_SYMBOL(foo);[Test Case 2]
Forward declaration with a different definition (e.g. attribute)
$ cat foo.c
#include <linux/export.h>
void foo(void);
__attribute__((__section__(".ref.text"))) void foo(void) {}
EXPORT_SYMBOL(foo);[Test Case 3]
Preserving an overridden symbol (compile with KBUILD_PRESERVE=1)
$ cat foo.c
#include <linux/export.h>
void foo(void);
void foo(void) { }
EXPORT_SYMBOL(foo);$ cat foo.symref override foo void foo ( int )
The memory leaks in Test Case 1 and 2 have existed since the introduction of genksyms into the kernel tree. [1]
The memory leak in Test Case 3 was introduced by commit 5dae9a550a74 ("genksyms: allow to ignore symbol checksum changes").
When multiple init_declarators are reduced to an init_declarator_list, the decl_spec must be duplicated. Otherwise, the following Test Case 4 would result in a double-free bug.
[Test Case 4]
$ cat foo.c #include <linux/export.h>
extern int foo, bar;
int foo, bar; EXPORT_SYMBOL(foo);
In this case, 'foo' and 'bar' share the same decl_spec, 'int'. It must be unshared before being passed to add_symbol().
--- scripts/genksyms/genksyms.c | 3 +++ scripts/genksyms/parse.y | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
scripts/genksyms/genksyms.c +3 -0
@@ -239,6 +239,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, "unchanged\n"); } sym->is_declared =1 ; +free_list (defn,NULL );return sym; }else if (!sym->is_declared) {if (sym->is_override && flag_preserve) {
@@ -247,6 +248,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,print_type_name (type, name);fprintf (stderr," modversion change\n" ); sym->is_declared =1 ; +free_list (defn,NULL );return sym; }else { status = is_unknown_symbol(sym) ?
@@ -254,6 +256,7 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type, } }else {error_with_pos ("redefinition of %s" , name); +free_list (defn,NULL );return sym; }break ;
scripts/genksyms/parse.y +12 -2
@@ -152,14 +152,19 @@ simple_declaration: ; init_declarator_list_opt: - /* empty */ { $$ = NULL; } - | init_declarator_list + /* empty */ { $$ = NULL; } + | init_declarator_list { free_list(decl_spec, NULL); $$ = $1; } ; init_declarator_list: init_declarator { struct string_list *decl = *$1; *$1 = NULL; + + /* avoid sharing among multiple init_declarators */ + if (decl_spec) + decl_spec = copy_list_range(decl_spec, NULL); + add_symbol(current_name, is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL;
@@ -170,6 +175,11 @@ init_declarator_list: *$3 = NULL; free_list(*$2, NULL); *$2 = decl_spec; + + /* avoid sharing among multiple init_declarators */ + if (decl_spec) + decl_spec = copy_list_range(decl_spec, NULL); + add_symbol(current_name, is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 553/623 genksyms: fix memory leak when the same symbol is read from *.symref file
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit be2fa44b5180a1f021efb40c55fdf63c249c3209 ]
When a symbol that is already registered is read again from *.symref file, __add_symbol() removes the previous one from the hash table without freeing it.
[Test Case]
$ cat foo.c
#include <linux/export.h>
void foo(void);
void foo(void) {}
EXPORT_SYMBOL(foo);$ cat foo.symref foo void foo ( void ) foo void foo ( void )
When a symbol is removed from the hash table, it must be freed along with its ->name and ->defn members. However, sym->name cannot be freed because it is sometimes shared with node->string, but not always. If sym->name and node->string share the same memory, free(sym->name) could lead to a double-free bug.
To resolve this issue, always assign a strdup'ed string to sym->name.
--- scripts/genksyms/genksyms.c | 8 ++++++-- scripts/genksyms/genksyms.h | 2 +- scripts/genksyms/parse.y | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-)
scripts/genksyms/genksyms.c +6 -2
@@ -272,11 +272,15 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,break ; } } + +free_list (sym->defn,NULL ); +free (sym->name); +free (sym); --nsyms; } sym =xmalloc (sizeof (*sym)); - sym->name = name; + sym->name =xstrdup (name); sym->type = type; sym->defn = defn; sym->expansion_trail =NULL ;
@@ -483,7 +487,7 @@ static void read_reference(FILE *f) defn = def; def =read_node (f); } - subsym =add_reference_symbol (xstrdup (sym->string), sym->tag, + subsym =add_reference_symbol (sym->string, sym->tag, defn, is_extern); subsym->is_override = is_override;free_node (sym);
scripts/genksyms/genksyms.h +1 -1
@@ -32,7 +32,7 @@ struct string_list {struct symbol {struct symbol *hash_next; -const char *name; +char *name;enum symbol_type type;struct string_list *defn;struct symbol *expansion_trail;
scripts/genksyms/parse.y +2 -2
@@ -482,12 +482,12 @@ enumerator_list: enumerator: IDENT { - const char *name = strdup((*$1)->string); + const char *name = (*$1)->string; add_symbol(name, SYM_ENUM_CONST, NULL, 0); } | IDENT '=' EXPRESSION_PHRASE { - const char *name = strdup((*$1)->string); + const char *name = (*$1)->string; struct string_list *expr = copy_list_range(*$3, *$2); add_symbol(name, SYM_ENUM_CONST, expr, 0); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 554/623 hostfs: fix string handling in __dentry_name()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 60a6002432448bb3f291d80768ae98d62efc9c77 ]
strcpy() should not be used with destination potentially overlapping the source; what's more, strscpy() in there is pointless - we already know the amount we want to copy; might as well use memcpy().
--- fs/hostfs/hostfs_kern.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
fs/hostfs/hostfs_kern.c +6 -21
@@ -95,32 +95,17 @@ __uml_setup("hostfs=", hostfs_args,static char *__dentry_name (struct dentry *dentry,char *name) {char *p =dentry_path_raw (dentry, name,PATH_MAX ); -char *root; -size_t len; -struct hostfs_fs_info *fsi; - - fsi = dentry->d_sb->s_fs_info; - root = fsi->host_root_path; - len =strlen (root); -if (IS_ERR (p)) { -__putname (name); -return NULL ; - } - -/* -* This function relies on the fact that dentry_path_raw() will place -* the path name at the end of the provided buffer. -*/ -BUG_ON (p +strlen (p) +1 != name +PATH_MAX ); +struct hostfs_fs_info *fsi = dentry->d_sb->s_fs_info; +char *root = fsi->host_root_path; +size_t len =strlen (root); -strscpy (name, root,PATH_MAX ); -if (len > p - name) { +if (IS_ERR (p) || len > p - name) {__putname (name);return NULL ; } -if (p > name + len) -strcpy (name + len, p); +memcpy (name, root, len); +memmove (name + len, p, name +PATH_MAX - p);return name; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 555/623 tools/power turbostat: Fix PMT mmaped file size rounding
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patryk Wlazlyn <[email protected]>
[ Upstream commit 2f60f03934a50bc1fb69bb4f47a25cddd6807b0b ]
This (the old code) is just not how you round up to a page size. Noticed on a recent Intel platform. Previous ones must have been reporting sizes already aligned to a page and so the bug was missed when testing.
--- tools/power/x86/turbostat/turbostat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +3 -1
@@ -95,6 +95,8 @@#define INTEL_ECORE_TYPE 0x20#define INTEL_PCORE_TYPE 0x40 +#define ROUND_UP_TO_PAGE_SIZE (n) (((n) + 0x1000UL-1UL) & ~(0x1000UL-1UL)) +enum counter_scope {SCOPE_CPU ,SCOPE_CORE ,SCOPE_PACKAGE };enum counter_type {COUNTER_ITEMS ,COUNTER_CYCLES ,COUNTER_SECONDS ,COUNTER_USEC ,COUNTER_K2M };enum counter_format {FORMAT_RAW ,FORMAT_DELTA ,FORMAT_PERCENT ,FORMAT_AVERAGE };
@@ -8924,7 +8926,7 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)if (fd_pmt ==-1 ) goto loop_cleanup_and_break; - mmap_size = (size +0x1000UL ) & (~0x1000UL ); + mmap_size =ROUND_UP_TO_PAGE_SIZE (size); mmio =mmap (0 , mmap_size,PROT_READ ,MAP_SHARED , fd_pmt,0 );if (mmio !=MAP_FAILED ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 556/623 kbuild: Fix signing issue for external modules
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Torsten Hilbrich <[email protected]>
[ Upstream commit 25ff08aa43e373a61c3e36fc7d7cae88ed0fc2d7 ]
When running the sign script the kernel is within the source directory of external modules. This caused issues when the kernel uses relative paths, like:
make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+
Working around it by using absolute pathes here.
--- scripts/Makefile.modinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.modinst +1 -1
@@ -105,7 +105,7 @@ else sig-key := $(CONFIG_MODULE_SIG_KEY) endif quiet_cmd_sign = SIGN $@ - cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \ + cmd_sign = $(objtree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(objtree)/certs/signing_key.x509 $@ \ $(if $(KBUILD_EXTMOD),|| true) ifeq ($(sign-only),)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 557/623 RISC-V: Mark riscv_v_init() as __init
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palmer Dabbelt <[email protected]>
[ Upstream commit 9d87cf525fd2e1a5fcbbb40ee3df216d1d266c88 ]
This trips up with Xtheadvector enabled, but as far as I can tell it's just been an issue since the original patchset.
--- arch/riscv/kernel/vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/vector.c +1 -1
@@ -309,7 +309,7 @@ static int __init riscv_v_sysctl_init(void)static int __init riscv_v_sysctl_init (void ) {return 0 ; }#endif /* ! CONFIG_SYSCTL */ -static int riscv_v_init (void ) +static int __init riscv_v_init (void ) {return riscv_v_sysctl_init (); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 558/623 ASoC: rockchip: i2s_tdm: Re-add the set_sysclk callback
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit 5323186e2e8d33c073fad51e24f18e2d6dbae2da ]
In commit9e2ab4b18ebd ("ASoC: rockchip: i2s-tdm: Fix inaccurate sampling rates"), the set_sysclk callback was removed as considered unused as the mclk rate can be set in the hw_params callback.
The difference between hw_params and set_sysclk is that the former is called with the audio sampling rate set in the params (e.g.: 48000 Hz) while the latter is called with a clock rate already computed with
sampling_rate * mclk-fs (e.g.: 48000 * 256)
For HDMI audio using the Rockchip I2S TDM driver, the mclk-fs value must be set to 128 instead of the default 256, and that value is set in the device tree at the machine driver level (like a simple-audio-card compatible node).
Therefore, the i2s_tdm driver has no idea that another mclk-fs value can be configured and simply computes the mclk rate in the hw_params callback with DEFAULT_MCLK_FS * params_rate(params), which is wrong for HDMI audio.
Re-add the set_sysclk callback so that the mclk rate is computed by the machine driver which has the correct mclk-fs value set in its device tree node.
--- sound/soc/rockchip/rockchip_i2s_tdm.c | 31 +++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
sound/soc/rockchip/rockchip_i2s_tdm.c +29 -2
@@ -22,7 +22,6 @@#define DRV_NAME "rockchip-i2s-tdm" -#define DEFAULT_MCLK_FS 256#define CH_GRP_MAX 4/* The max channel 8 / 2 */ #define MULTIPLEX_CH_MAX 10
@@ -70,6 +69,8 @@ struct rk_i2s_tdm_dev {bool has_playback;bool has_capture;struct snd_soc_dai_driver *dai; +unsigned int mclk_rx_freq; +unsigned int mclk_tx_freq; };static int to_ch_num (unsigned int val)
@@ -645,6 +646,27 @@ static int rockchip_i2s_trcm_mode(struct snd_pcm_substream *substream,return 0 ; } +static int rockchip_i2s_tdm_set_sysclk (struct snd_soc_dai *cpu_dai,int stream, +unsigned int freq,int dir) +{ +struct rk_i2s_tdm_dev *i2s_tdm =to_info (cpu_dai); + +if (i2s_tdm->clk_trcm) { + i2s_tdm->mclk_tx_freq = freq; + i2s_tdm->mclk_rx_freq = freq; + }else { +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) + i2s_tdm->mclk_tx_freq = freq; +else + i2s_tdm->mclk_rx_freq = freq; + } + +dev_dbg (i2s_tdm->dev,"The target mclk_%s freq is: %d\n" , + stream ?"rx" :"tx" , freq); + +return 0 ; +} +static int rockchip_i2s_tdm_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params,struct snd_soc_dai *dai)
@@ -659,15 +681,19 @@ static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream,if (i2s_tdm->clk_trcm ==TRCM_TX ) { mclk = i2s_tdm->mclk_tx; + mclk_rate = i2s_tdm->mclk_tx_freq; }else if (i2s_tdm->clk_trcm ==TRCM_RX ) { mclk = i2s_tdm->mclk_rx; + mclk_rate = i2s_tdm->mclk_rx_freq; }else if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { mclk = i2s_tdm->mclk_tx; + mclk_rate = i2s_tdm->mclk_tx_freq; }else { mclk = i2s_tdm->mclk_rx; + mclk_rate = i2s_tdm->mclk_rx_freq; } - err =clk_set_rate (mclk,DEFAULT_MCLK_FS *params_rate (params)); + err =clk_set_rate (mclk, mclk_rate);if (err)return err;
@@ -827,6 +853,7 @@ static const struct snd_soc_dai_ops rockchip_i2s_tdm_dai_ops = { .hw_params = rockchip_i2s_tdm_hw_params, .set_bclk_ratio = rockchip_i2s_tdm_set_bclk_ratio, .set_fmt = rockchip_i2s_tdm_set_fmt, + .set_sysclk = rockchip_i2s_tdm_set_sysclk, .set_tdm_slot = rockchip_dai_tdm_slot, .trigger = rockchip_i2s_tdm_trigger, };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 559/623 io_uring/msg_ring: dont leave potentially dangling ->tctx pointer
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 69a62e03f896a7382671877b6ad6aab87c53e9c3 ]
For remote posting of messages, req->tctx is assigned even though it is never used. Rather than leave a dangling pointer, just clear it to NULL and use the previous check for a valid submitter_task to gate on whether or not the request should be terminated.
--- io_uring/msg_ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/msg_ring.c +2 -2
@@ -89,8 +89,7 @@ static void io_msg_tw_complete(struct io_kiocb *req, struct io_tw_state *ts)static int io_msg_remote_post (struct io_ring_ctx *ctx,struct io_kiocb *req,int res,u32 cflags,u64 user_data) { - req->tctx =READ_ONCE (ctx->submitter_task->io_uring); -if (!req->tctx) { +if (!READ_ONCE (ctx->submitter_task)) {kmem_cache_free (req_cachep, req);return -EOWNERDEAD ; }
@@ -98,6 +97,7 @@ static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,io_req_set_res (req, res, cflags);percpu_ref_get (&ctx->refs); req->ctx = ctx; + req->tctx =NULL ; req->io_task_work.func = io_msg_tw_complete;io_req_task_work_add_remote (req, ctx,IOU_F_TWQ_LAZY_WAKE );return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 560/623 io_uring/uring_cmd: use cached cmd_op in io_uring_cmd_sock()
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit d58d82bd0efd6c8edd452fc2f6c6dd052ec57cb2 ]
io_uring_cmd_sock() does a normal read of cmd->sqe->cmd_op, where it really should be using a READ_ONCE() as ->sqe may still be pointing to the original SQE. Since the prep side already does this READ_ONCE() and stores it locally, use that value rather than re-read it.
--- io_uring/uring_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/uring_cmd.c +1 -1
@@ -362,7 +362,7 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)if (!prot || !prot->ioctl)return -EOPNOTSUPP ; -switch (cmd->sqe->cmd_op) { +switch (cmd->cmd_op) {case SOCKET_URING_OP_SIOCINQ : ret = prot->ioctl (sk,SIOCINQ , &arg);if (ret)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 561/623 io_uring/register: use atomic_read/write for sq_flags migration
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit a23ad06bfee5e51cd9e51aebf11401e7b4b5d00a ]
A previous commit changed all of the migration from the old to the new ring for resizing to use READ/WRITE_ONCE. However, ->sq_flags is an atomic_t, and while most archs won't complain on this, some will indeed flag this:
io_uring/register.c:554:9: sparse: sparse: cast to non-scalar io_uring/register.c:554:9: sparse: sparse: cast from non-scalar
Just use atomic_set/atomic_read for handling this case.
--- io_uring/register.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/register.c +1 -1
@@ -553,7 +553,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) ctx->cqe_cached = ctx->cqe_sentinel =NULL ;WRITE_ONCE (n.rings->sq_dropped,READ_ONCE (o.rings->sq_dropped)); -WRITE_ONCE (n.rings->sq_flags,READ_ONCE (o.rings->sq_flags)); +atomic_set (&n.rings->sq_flags,atomic_read (&o.rings->sq_flags));WRITE_ONCE (n.rings->cq_flags,READ_ONCE (o.rings->cq_flags));WRITE_ONCE (n.rings->cq_overflow,READ_ONCE (o.rings->cq_overflow));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 562/623 ASoC: amd: acp: Fix possible deadlock
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Baluta <[email protected]>
[ Upstream commit 3ff53862c322aa7bb115d84348d5a641dc905d87 ]
On error path, function acp_i2s_set_tdm_slot returns without releasing the lock and this could result in potential deadlocks in the future.
Error reported by sparse:sound/soc/amd/acp/acp-i2s.c:95:12: error: context imbalance in 'acp_i2s_set_tdm_slot' - different lock contexts for basic block
--- sound/soc/amd/acp/acp-i2s.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/amd/acp/acp-i2s.c +1 -0
@@ -181,6 +181,7 @@ static int acp_i2s_set_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, u32 rx_masbreak ;default :dev_err (dev,"Unknown chip revision %d\n" , chip->acp_rev); +spin_unlock_irq (&adata->acp_lock);return -EINVAL ; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 563/623 tools/power turbostat: Fix forked child affinity regression
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit b32c36975da48afc9089f8b61f7b2dcc40e479d2 ]
In "one-shot" mode, turbostat
1. takes a counter snapshot
2. forks and waits for a child
3. takes the end counter snapshot and prints the result.
But turbostat counter snapshots currently use affinity to travel around the system so that counter reads are "local", and this affinity must be cleared between #1 and #2 above.
The offending commit removed that reset that allowed the child to run on cpu_present_set.
Fix that issue, and improve upon the original by using cpu_possible_set for the child. This allows the child to also run on CPUs that hotplug online during its runtime.
--- tools/power/x86/turbostat/turbostat.c | 54 ++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-)
tools/power/x86/turbostat/turbostat.c +52 -2
@@ -1096,8 +1096,8 @@ int backwards_count;char *progname;#define CPU_SUBSET_MAXCPUS 1024/* need to use before probe... */ -cpu_set_t *cpu_present_set, *cpu_effective_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset; -size_t cpu_present_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size; +cpu_set_t *cpu_present_set, *cpu_possible_set, *cpu_effective_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset; +size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size;#define MAX_ADDED_THREAD_COUNTERS 24#define MAX_ADDED_CORE_COUNTERS 8#define MAX_ADDED_PACKAGE_COUNTERS 16
@@ -8294,6 +8294,33 @@ int dir_filter(const struct dirent *dirp)return 0 ; } +char *possible_file ="/sys/devices/system/cpu/possible" ; +char possible_buf[1024 ]; + +int initialize_cpu_possible_set (void ) +{ +FILE *fp; + + fp =fopen (possible_file,"r" ); +if (!fp) { +warn ("open %s" , possible_file); +return -1 ; + } +if (fread (possible_buf,sizeof (char ),1024 , fp) ==0 ) { +warn ("read %s" , possible_file); + goto err; + } +if (parse_cpu_str (possible_buf, cpu_possible_set, cpu_possible_setsize)) { +warnx ("%s: cpu str malformat %s\n" , possible_file, cpu_effective_str); + goto err; + } +return 0 ; + +err: +fclose (fp); +return -1 ; +} +void topology_probe (bool startup) {int i;
@@ -8325,6 +8352,16 @@ void topology_probe(bool startup)CPU_ZERO_S (cpu_present_setsize, cpu_present_set);for_all_proc_cpus (mark_cpu_present); +/* +* Allocate and initialize cpu_possible_set +*/ + cpu_possible_set =CPU_ALLOC ((topo.max_cpu_num +1 )); +if (cpu_possible_set ==NULL ) +err (3 ,"CPU_ALLOC" ); + cpu_possible_setsize =CPU_ALLOC_SIZE ((topo.max_cpu_num +1 )); +CPU_ZERO_S (cpu_possible_setsize, cpu_possible_set); +initialize_cpu_possible_set (); +/* * Allocate and initialize cpu_effective_set */
@@ -9165,6 +9202,18 @@ void turbostat_init() } } +void affinitize_child (void ) +{ +/* Prefer cpu_possible_set, if available */ +if (sched_setaffinity (0 , cpu_possible_setsize, cpu_possible_set)) { +warn ("sched_setaffinity cpu_possible_set" ); + +/* Otherwise, allow child to run on same cpu set as turbostat */ +if (sched_setaffinity (0 , cpu_allowed_setsize, cpu_allowed_set)) +warn ("sched_setaffinity cpu_allowed_set" ); + } +} +int fork_it (char **argv) {pid_t child_pid;
@@ -9180,6 +9229,7 @@ int fork_it(char **argv) child_pid =fork ();if (!child_pid) {/* child */ +affinitize_child ();execvp (argv[0 ], argv);err (errno,"exec %s" , argv[0 ]); }else {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 564/623 cifs: Validate EAs for WSL reparse points
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit ef201e8759d20bf82b5943101147072de12bc524 ]
Major and minor numbers for char and block devices are mandatory for stat. So check that the WSL EA $LXDEV is present for WSL CHR and BLK reparse points.
WSL reparse point tag determinate type of the file. But file type is present also in the WSL EA $LXMOD. So check that both file types are same.
--- fs/smb/client/reparse.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
fs/smb/client/reparse.c +18 -4
@@ -747,11 +747,12 @@ int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,return parse_reparse_point (buf, plen, cifs_sb, full_path, true, data); } -static void wsl_to_fattr (struct cifs_open_info_data *data, +static bool wsl_to_fattr (struct cifs_open_info_data *data,struct cifs_sb_info *cifs_sb,u32 tag,struct cifs_fattr *fattr) {struct smb2_file_full_ea_info *ea; +bool have_xattr_dev = false;u32 next =0 ;switch (tag) {
@@ -794,13 +795,24 @@ static void wsl_to_fattr(struct cifs_open_info_data *data, fattr->cf_uid =wsl_make_kuid (cifs_sb, v); else if (!strncmp(name, SMB2_WSL_XATTR_GID, nlen)) fattr->cf_gid = wsl_make_kgid(cifs_sb, v); - else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) + else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) { +/* File type in reparse point tag and in xattr mode must match. */ +if (S_DT (fattr->cf_mode) !=S_DT (le32_to_cpu (*(__le32 *)v))) +return false; fattr->cf_mode = (umode_t )le32_to_cpu (*(__le32 *)v); - else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) + } else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) { fattr->cf_rdev =reparse_mkdev (v); + have_xattr_dev = true; + } }while (next); out: + +/* Major and minor numbers for char and block devices are mandatory. */ +if (!have_xattr_dev && (tag ==IO_REPARSE_TAG_LX_CHR || tag ==IO_REPARSE_TAG_LX_BLK )) +return false; + fattr->cf_dtype =S_DT (fattr->cf_mode); +return true; } static bool posix_reparse_to_fattr(struct cifs_sb_info *cifs_sb,
@@ -874,7 +886,9 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,case IO_REPARSE_TAG_AF_UNIX :case IO_REPARSE_TAG_LX_CHR :case IO_REPARSE_TAG_LX_BLK : -wsl_to_fattr (data, cifs_sb, tag, fattr); + ok =wsl_to_fattr (data, cifs_sb, tag, fattr); +if (!ok) +return false;break ;case IO_REPARSE_TAG_NFS : ok =posix_reparse_to_fattr (cifs_sb, fattr, data);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 565/623 cifs: Fix getting and setting SACLs over SMB1
In reply to Greg Kroah-Hartman6.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit 8b19dfb34d17e77a0809d433cc128b779282131b ]
SMB1 callback get_cifs_acl_by_fid() currently ignores its last argument and therefore ignores request for SACL_SECINFO. Fix this issue by correctly propagating info argument from get_cifs_acl() and get_cifs_acl_by_fid() to CIFSSMBGetCIFSACL() function and pass SACL_SECINFO when requested.
For accessing SACLs it is needed to open object with SYSTEM_SECURITY access. Pass this flag when trying to get or set SACLs.
Same logic is in the SMB2+ code path.
This change fixes getting and setting of "system.cifs_ntsd_full" and "system.smb3_ntsd_full" xattrs over SMB1 as currently it silentely ignored SACL part of passed xattr buffer.
--- fs/smb/client/cifsacl.c | 25 +++++++++++++++---------- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/cifssmb.c | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-)
fs/smb/client/cifsacl.c +15 -10
@@ -1395,7 +1395,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY struct smb_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb,const struct cifs_fid *cifsfid,u32 *pacllen, -u32 __maybe_unused unused) +u32 info) {struct smb_ntsd *pntsd =NULL ;unsigned int xid;
@@ -1407,7 +1407,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, xid =get_xid (); rc =CIFSSMBGetCIFSACL (xid,tlink_tcon (tlink), cifsfid->netfid, &pntsd, - pacllen); + pacllen, info);free_xid (xid);cifs_put_tlink (tlink);
@@ -1419,7 +1419,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, }static struct smb_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb, -const char *path,u32 *pacllen) +const char *path,u32 *pacllen,u32 info) {struct smb_ntsd *pntsd =NULL ;int oplock =0 ;
@@ -1446,9 +1446,12 @@ static struct smb_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, .fid = &fid, }; +if (info &SACL_SECINFO ) + oparms.desired_access |=SYSTEM_SECURITY ; + rc =CIFS_open (xid, &oparms, &oplock,NULL );if (!rc) { - rc =CIFSSMBGetCIFSACL (xid, tcon, fid.netfid, &pntsd, pacllen); + rc =CIFSSMBGetCIFSACL (xid, tcon, fid.netfid, &pntsd, pacllen, info);CIFSSMBClose (xid, tcon, fid.netfid); }
@@ -1472,7 +1475,7 @@ struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,if (inode) open_file =find_readable_file (CIFS_I (inode), true);if (!open_file) -return get_cifs_acl_by_path (cifs_sb, path, pacllen); +return get_cifs_acl_by_path (cifs_sb, path, pacllen, info); pntsd =get_cifs_acl_by_fid (cifs_sb, &open_file->fid, pacllen, info);cifsFileInfo_put (open_file);
@@ -1485,7 +1488,7 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, {int oplock =0 ;unsigned int xid; -int rc, access_flags; +int rc, access_flags =0 ;struct cifs_tcon *tcon;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct tcon_link *tlink =cifs_sb_tlink (cifs_sb);
@@ -1498,10 +1501,12 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, tcon =tlink_tcon (tlink); xid =get_xid (); -if (aclflag ==CIFS_ACL_OWNER || aclflag ==CIFS_ACL_GROUP ) - access_flags =WRITE_OWNER ; -else - access_flags =WRITE_DAC ; +if (aclflag &CIFS_ACL_OWNER || aclflag &CIFS_ACL_GROUP ) + access_flags |=WRITE_OWNER ; +if (aclflag &CIFS_ACL_SACL ) + access_flags |=SYSTEM_SECURITY ; +if (aclflag &CIFS_ACL_DACL ) + access_flags |=WRITE_DAC ; oparms = (struct cifs_open_parms ) { .tcon = tcon,
fs/smb/client/cifsproto.h +1 -1
@@ -560,7 +560,7 @@ extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,const struct nls_table *nls_codepage, struct cifs_sb_info *cifs_sb);extern int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon, -__u16 fid,struct smb_ntsd **acl_inf,__u32 *buflen); +__u16 fid,struct smb_ntsd **acl_inf,__u32 *buflen,__u32 info);extern int CIFSSMBSetCIFSACL (const unsigned int ,struct cifs_tcon *,__u16 ,struct smb_ntsd *pntsd,__u32 len,int aclflag); extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
fs/smb/client/cifssmb.c +2 -2
@@ -3375,7 +3375,7 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata,/* Get Security Descriptor (by handle) from remote server for a file or dir */ int CIFSSMBGetCIFSACL (const unsigned int xid,struct cifs_tcon *tcon,__u16 fid, -struct smb_ntsd **acl_inf,__u32 *pbuflen) +struct smb_ntsd **acl_inf,__u32 *pbuflen,__u32 info) {int rc =0 ;int buf_type =0 ;
@@ -3398,7 +3398,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid, pSMB->MaxSetupCount =0 ; pSMB->Fid = fid;/* file handle always le */ pSMB->AclFlags =cpu_to_le32 (CIFS_ACL_OWNER |CIFS_ACL_GROUP | -CIFS_ACL_DACL ); +CIFS_ACL_DACL | info); pSMB->ByteCount =cpu_to_le16 (11 );/* 3 bytes pad + 8 bytes parm */ inc_rfc1001_len (pSMB,11 ); iov[0 ].iov_base = (char *)pSMB;
Signature · 1 line
2.39.5