5.15.121-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 282/532 extcon: Fix kernel doc of property capability fields to avoid warnings
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 73346b9965ebda2feb7fef8629e9b28baee820e3 ]
Kernel documentation has to be synchronized with a code, otherwise the validator is not happy:
Function parameter or member 'usb_bits' not described in 'extcon_cable' Function parameter or member 'chg_bits' not described in 'extcon_cable' Function parameter or member 'jack_bits' not described in 'extcon_cable' Function parameter or member 'disp_bits' not described in 'extcon_cable'
Describe the fields added in the past.
--- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/extcon/extcon.c +4 -0
@@ -200,6 +200,10 @@ static const struct __extcon_info {* @chg_propval: the array of charger connector properties * @jack_propval: the array of jack connector properties * @disp_propval: the array of display connector properties +* @usb_bits: the bit array of the USB connector property capabilities +* @chg_bits: the bit array of the charger connector property capabilities +* @jack_bits: the bit array of the jack connector property capabilities +* @disp_bits: the bit array of the display connector property capabilities */ struct extcon_cable {struct extcon_dev *edev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 283/532 usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
In reply to Greg Kroah-HartmanFrom: Li Yang <[email protected]>
[ Upstream commit 342161c11403ea00e9febc16baab1d883d589d04 ]
Smatch reports:drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
warn: missing unwind goto?
After geting irq, if ret < 0, it will return without error handling to free memory.
Just add error handling to fix this problem.
--- drivers/usb/phy/phy-tahvo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/phy/phy-tahvo.c +1 -1
@@ -395,7 +395,7 @@ static int tahvo_usb_probe(struct platform_device *pdev) tu->irq = ret =platform_get_irq (pdev,0 );if (ret <0 ) -return ret; + goto err_remove_phy; ret =request_threaded_irq (tu->irq,NULL , tahvo_usb_vbus_interrupt,IRQF_ONESHOT ,"tahvo-vbus" , tu);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 284/532 usb: hide unused usbfs_notify_suspend/resume functions
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 8e6bd945e6dde64fbc60ec3fe252164493a8d3a2 ]
The declaration is in an #ifdef, which causes warnings when building with 'make W=1' and without CONFIG_PM:
drivers/usb/core/devio.c:742:6: error: no previous prototype for 'usbfs_notify_suspend' drivers/usb/core/devio.c:747:6: error: no previous prototype for 'usbfs_notify_resume'
Use the same #ifdef check around the function definitions to avoid the warnings and slightly shrink the USB core.
--- drivers/usb/core/devio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/core/devio.c +2 -0
@@ -735,6 +735,7 @@ static int driver_resume(struct usb_interface *intf)return 0 ; } +#ifdef CONFIG_PM /* The following routines apply to the entire device, not interfaces */ void usbfs_notify_suspend (struct usb_device *udev) {
@@ -753,6 +754,7 @@ void usbfs_notify_resume(struct usb_device *udev) }mutex_unlock (&usbfs_mutex); } +#endif struct usb_driver usbfs_driver = { .name ="usbfs" ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 285/532 serial: 8250: lock port for stop_rx() in omap8250_irq()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit ca73a892c5bec4b08a2fa22b3015e98ed905abb7 ]
The uarts_ops stop_rx() callback expects that the port->lock is taken and interrupts are disabled.
--- drivers/tty/serial/8250/8250_omap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_omap.c +2 -0
@@ -655,7 +655,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) up->ier = port->serial_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { +spin_lock (&port->lock); port->ops->stop_rx (port); +spin_unlock (&port->lock); }else {/* Keep restarting the timer until * the input overrun subsides.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 286/532 serial: 8250: lock port for UART_IER access in omap8250_irq()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit 25614735a647693c1260f253dc3ab32127697806 ]
omap8250_irq() accesses UART_IER. This register is modified twice by each console write (serial8250_console_write()) under the port lock. omap8250_irq() must also take the port lock to guanentee synchronized access to UART_IER.
Since the port lock is already being taken for the stop_rx() callback and since it is safe to call cancel_delayed_work() while holding the port lock, simply extend the port lock region to include UART_IER access.
--- drivers/tty/serial/8250/8250_omap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +3 -2
@@ -653,17 +653,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)if ((lsr &UART_LSR_OE ) && up->overrun_backoff_time_ms >0 ) {unsigned long delay; +/* Synchronize UART_IER access against the console. */ +spin_lock (&port->lock); up->ier = port->serial_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { -spin_lock (&port->lock); port->ops->stop_rx (port); -spin_unlock (&port->lock); }else {/* Keep restarting the timer until * the input overrun subsides. */ cancel_delayed_work (&up->overrun_backoff); } +spin_unlock (&port->lock); delay =msecs_to_jiffies (up->overrun_backoff_time_ms);schedule_delayed_work (&up->overrun_backoff, delay);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 287/532 kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 30480b988f88c279752f3202a26b6fee5f586aef ]
The root->ino_idr is supposed to be protected by kernfs_idr_lock, fix it.
--- fs/kernfs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/kernfs/dir.c +2 -0
@@ -637,7 +637,9 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,return kn; err_out3: +spin_lock (&kernfs_idr_lock);idr_remove (&root->ino_idr, (u32 )kernfs_ino (kn)); +spin_unlock (&kernfs_idr_lock); err_out2:kmem_cache_free (kernfs_node_cache, kn); err_out1:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 288/532 coresight: Fix loss of connection info when a module is unloaded
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit c45b2835e7b205783bdfe08cc98fa86a7c5eeb74 ]
child_fwnode should be a read only property based on the DT or ACPI. If it's cleared on the parent device when a child is unloaded, then when the child is loaded again the connection won't be remade.
child_dev should be cleared instead which signifies that the connection should be remade when the child_fwnode registers a new coresight_device.
Similarly the reference count shouldn't be decremented as long as the parent device exists. The correct place to drop the reference is in coresight_release_platform_data() which is already done.
Reproducible on Juno with the following steps:
# load all coresight modules. $ cd /sys/bus/coresight/devices/ $ echo 1 > tmc_etr0/enable_sink $ echo 1 > etm0/enable_source # Works fine ^
$ echo 0 > etm0/enable_source $ rmmod coresight-funnel $ modprobe coresight-funnel $ echo 1 > etm0/enable_source -bash: echo: write error: Invalid argument
--- drivers/hwtracing/coresight/coresight-core.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/hwtracing/coresight/coresight-core.c +2 -7
@@ -1421,13 +1421,8 @@ static int coresight_remove_match(struct device *dev, void *data)if (csdev->dev.fwnode == conn->child_fwnode) { iterator->orphan = true;coresight_remove_links (iterator, conn); -/* -* Drop the reference to the handle for the remote -* device acquired in parsing the connections from -* platform data. -*/ -fwnode_handle_put (conn->child_fwnode); - conn->child_fwnode =NULL ; + + conn->child_dev =NULL ;/* No need to continue */ break ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 289/532 mfd: rt5033: Drop rt5033-battery sub-device
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 43db1344e0f8c1eb687a1d6cd5b0de3009ab66cb ]
The fuel gauge in the RT5033 PMIC (rt5033-battery) has its own I2C bus and interrupt lines. Therefore, it is not part of the MFD device and needs to be specified separately in the device tree.
--- drivers/mfd/rt5033.c | 3 --- 1 file changed, 3 deletions(-)
drivers/mfd/rt5033.c +0 -3
@@ -41,9 +41,6 @@ static const struct mfd_cell rt5033_devs[] = { { .name = "rt5033-charger", .of_compatible = "richtek,rt5033-charger", - }, { - .name = "rt5033-battery", - .of_compatible = "richtek,rt5033-battery", }, { .name = "rt5033-led", .of_compatible = "richtek,rt5033-led",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 290/532 media: venus: helpers: Fix ALIGN() of non power of two
In reply to Greg Kroah-HartmanFrom: Rikard Falkeborn <[email protected]>
[ Upstream commit 927e78ac8bc58155316cf6f46026e1912bbbbcfc ]
ALIGN() expects its second argument to be a power of 2, otherwise incorrect results are produced for some inputs. The output can be both larger or smaller than what is expected.
For example, ALIGN(304, 192) equals 320 instead of 384, and ALIGN(65, 192) equals 256 instead of 192.
However, nestling two ALIGN() as is done in this case seem to only produce results equal to or bigger than the expected result if ALIGN() had handled non powers of two, and that in turn results in framesizes that are either the correct size or too large.
Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN() is sufficient.
--- drivers/media/platform/qcom/venus/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/helpers.c +2 -2
@@ -981,8 +981,8 @@ static u32 get_framesize_raw_yuv420_tp10_ubwc(u32 width, u32 height)u32 extradata =SZ_16K ;u32 size; - y_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); - uv_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); + y_stride =ALIGN (width *4 /3 ,256 ); + uv_stride =ALIGN (width *4 /3 ,256 ); y_sclines =ALIGN (height,16 ); uv_sclines =ALIGN ((height +1 ) >>1 ,16 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 291/532 media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1657f2934daf89e8d9fa4b2697008909eb22c73e ]
Ideally, strlen(cur->string.pointer) and strlen(out) would be the same. But this code is using strscpy() to avoid a potential buffer overflow. So in the same way we should take the strlen() of the smaller string to avoid a buffer overflow in the caller, gmin_get_var_int().
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -1
@@ -1198,7 +1198,7 @@ static int gmin_get_config_dsm_var(struct device *dev,dev_info (dev,"found _DSM entry for '%s': %s\n" , var, cur->string.pointer);strscpy (out, cur->string.pointer, *out_len); - *out_len =strlen (cur->string.pointer); + *out_len =strlen (out);ACPI_FREE (obj);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 292/532 KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes
In reply to Greg Kroah-HartmanFrom: Nico Boehr <[email protected]>
[ Upstream commit 285cff4c0454340a4dc53f46e67f2cb1c293bd74 ]
The KVM_S390_GET_CMMA_BITS ioctl may return incorrect values when userspace specifies a start_gfn outside of memslots.
This can occur when a VM has multiple memslots with a hole in between:
+-----+----------+--------+--------+
| ... | Slot N-1 | <hole> | Slot N |
+-----+----------+--------+--------+
^ ^ ^ ^
| | | |
GFN A A+B | |
A+B+C |
A+B+C+DWhen userspace specifies a GFN in [A+B, A+B+C), it would expect to get the CMMA values of the first dirty page in Slot N. However, userspace may get a start_gfn of A+B+C+D with a count of 0, hence completely skipping over any dirty pages in slot N.
The error is in kvm_s390_next_dirty_cmma(), which assumes gfn_to_memslot_approx() will return the memslot _below_ the specified GFN when the specified GFN lies outside a memslot. In reality it may return either the memslot below or above the specified GFN.
When a memslot above the specified GFN is returned this happens:
- ofs is calculated, but since the memslot's base_gfn is larger than the specified cur_gfn, ofs will underflow to a huge number.
- ofs is passed to find_next_bit(). Since ofs will exceed the memslot's number of pages, the number of pages in the memslot is returned, completely skipping over all bits in the memslot userspace would be interested in.
Fix this by resetting ofs to zero when a memslot _above_ cur_gfn is returned (cur_gfn < ms->base_gfn).
Message-Id: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/s390/kvm/kvm-s390.c +4 -0
@@ -2030,6 +2030,10 @@ static unsigned long kvm_s390_next_dirty_cmma(struct kvm_memslots *slots, ms = slots->memslots + slotidx; ofs =0 ; } + +if (cur_gfn < ms->base_gfn) + ofs =0 ; + ofs =find_next_bit (kvm_second_dirty_bitmap (ms), ms->npages, ofs);while ((slotidx >0 ) && (ofs >= ms->npages)) { slotidx--;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 293/532 usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 8fd95da2cfb5046c4bb5a3cdc9eb7963ba8b10dd ]
In the probe, some resources are allocated with dwc3_qcom_of_register_core() or dwc3_qcom_acpi_register_core(). The corresponding resources are already coorectly freed in the error handling path of the probe, but not in the remove function.
Fix it.
Message-ID: <c0215a84cdf18fb3514c81842783ec53cf149deb.1685891059.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +5 -1
@@ -873,11 +873,15 @@ static int dwc3_qcom_probe(struct platform_device *pdev)static int dwc3_qcom_remove (struct platform_device *pdev) {struct dwc3_qcom *qcom =platform_get_drvdata (pdev); +struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;int i;device_remove_software_node (&qcom->dwc3->dev); -of_platform_depopulate (dev); +if (np) +of_platform_depopulate (&pdev->dev); +else +platform_device_put (pdev);for (i = qcom->num_clocks -1 ; i >=0 ; i--) {clk_disable_unprepare (qcom->clks[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 294/532 usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4a944da707123686d372ec01ea60056902fadf35 ]
If dwc3_qcom_create_urs_usb_platdev() fails, some resources still need to be released, as already done in the other error handling path of the probe.
Message-ID: <b69fa8dd68d816e7d24c88d3eda776ceb28c5dc5.1685890571.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +3 -2
@@ -791,9 +791,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)if (IS_ERR_OR_NULL (qcom->urs_usb)) {dev_err (dev,"failed to create URS USB platdev\n" );if (!qcom->urs_usb) -return -ENODEV ; + ret = -ENODEV ;else -return PTR_ERR (qcom->urs_usb); + ret =PTR_ERR (qcom->urs_usb); + goto clk_disable; } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 295/532 usb: common: usb-conn-gpio: Set last role to unknown before initial detection
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit edd60d24bd858cef165274e4cd6cab43bdc58d15 ]
Currently if we bootup a device without cable connected, then usb-conn-gpio won't call set_role() since last_role is same as current role. This happens because during probe last_role gets initialised to zero.
To avoid this, added a new constant in enum usb_role, last_role is set to USB_ROLE_UNKNOWN before performing initial detection.
While at it, also handle default case for the usb_role switch in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid build warnings.
Message-ID: <[email protected]>
--- drivers/usb/cdns3/core.c | 2 ++ drivers/usb/common/usb-conn-gpio.c | 3 +++ drivers/usb/musb/jz4740.c | 2 ++ drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++ include/linux/usb/role.h | 1 + 5 files changed, 10 insertions(+)
drivers/usb/cdns3/core.c +2 -0
@@ -252,6 +252,8 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; +default : +break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +3 -0
@@ -272,6 +272,9 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info); +/* Set last role to unknown before performing the initial detection */ + info->last_role =USB_ROLE_UNKNOWN ; +/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +2 -0
@@ -91,6 +91,8 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; +default : +break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +2 -0
@@ -97,6 +97,8 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; +default : +break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +1 -0
@@ -11,6 +11,7 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST ,USB_ROLE_DEVICE , + USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 296/532 usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 01052b91c9808e3c3b068ae2721cb728ec9aa4c0 ]
If dwc3_meson_g12a_otg_init() fails, resources allocated by the previous of_platform_populate() call should be released, as already done in the error handling path.
Message-ID: <9d28466de1808ccc756b4cc25fc72c482d133d13.1686403934.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-meson-g12a.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +4 -1
@@ -805,7 +805,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret =dwc3_meson_g12a_otg_init (pdev, priv);if (ret) - goto err_phys_power; + goto err_plat_depopulate;pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -813,6 +813,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)return 0 ; +err_plat_depopulate: +of_platform_depopulate (dev); + err_phys_power:for (i =0 ; i <PHY_COUNT ; ++i)phy_power_off (priv->phys[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 297/532 mfd: intel-lpss: Add missing check for platform_get_resource
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d918e0d5824495a75d00b879118b098fcab36fdb ]
Add the missing check for platform_get_resource and return error if it fails.
--- drivers/mfd/intel-lpss-acpi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/intel-lpss-acpi.c +3 -0
@@ -148,6 +148,9 @@ static int intel_lpss_acpi_probe(struct platform_device *pdev)return -ENOMEM ; info->mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!info->mem) +return -ENODEV ; + info->irq =platform_get_irq (pdev,0 ); ret =intel_lpss_probe (&pdev->dev, info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 298/532 Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit df49f2a0ac4a34c0cb4b5c233fcfa0add644c43c ]
This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.
Heikki reports that this should not be a global flag just to work around one broken driver and should be fixed differently, so revert it.
--- drivers/usb/cdns3/core.c | 2 -- drivers/usb/common/usb-conn-gpio.c | 3 --- drivers/usb/musb/jz4740.c | 2 -- drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 -- include/linux/usb/role.h | 1 - 5 files changed, 10 deletions(-)
drivers/usb/cdns3/core.c +0 -2
@@ -252,8 +252,6 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; -default : -break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +0 -3
@@ -272,9 +272,6 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info); -/* Set last role to unknown before performing the initial detection */ - info->last_role =USB_ROLE_UNKNOWN ; -/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +0 -2
@@ -91,8 +91,6 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; -default : -break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +0 -2
@@ -97,8 +97,6 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; -default : -break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +0 -1
@@ -11,7 +11,6 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST , USB_ROLE_DEVICE, - USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 299/532 serial: 8250_omap: Use force_suspend and resume for system suspend
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 20a41a62618df85f3a2981008edec5cadd785e0a ]
We should not rely on autosuspend timeout for system suspend. Instead, let's use force_suspend and force_resume functions. Otherwise the serial port controller device may not be idled on suspend.
As we are doing a register write on suspend to configure the serial port, we still need to runtime PM resume the port on suspend.
While at it, let's switch to pm_runtime_resume_and_get() and check for errors returned. And let's add the missing line break before return to the suspend function while at it.
Message-ID: <[email protected]>
--- drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_omap.c +15 -5
@@ -1521,25 +1521,35 @@ static int omap8250_suspend(struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev);struct uart_8250_port *up =serial8250_get_port (priv->line); +int err;serial8250_suspend_port (priv->line); -pm_runtime_get_sync (dev); + err =pm_runtime_resume_and_get (dev); +if (err) +return err;if (!device_may_wakeup (dev)) priv->wer =0 ;serial_out (up,UART_OMAP_WER , priv->wer); -pm_runtime_mark_last_busy (dev); -pm_runtime_put_autosuspend (dev); - + err =pm_runtime_force_suspend (dev);flush_work (&priv->qos_work); -return 0 ; + +return err; }static int omap8250_resume (struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev); +int err; + err =pm_runtime_force_resume (dev); +if (err) +return err;serial8250_resume_port (priv->line); +/* Paired with pm_runtime_resume_and_get() in omap8250_suspend() */ +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); +return 0 ; }#else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 300/532 test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation
In reply to Greg Kroah-HartmanFrom: Mirsad Goran Todorovac <[email protected]>
[ Upstream commit 7dae593cd226a0bca61201cf85ceb9335cf63682 ]
In a couple of situations like
name = kstrndup(buf, count, GFP_KERNEL); if (!name) return -ENOSPC;
the error is not actually "No space left on device", but "Out of memory".
It is semantically correct to return -ENOMEM in all failed kstrndup() and kzalloc() cases in this driver, as it is not a problem with disk space, but with kernel memory allocator failing allocation.
The semantically correct should be:
name = kstrndup(buf, count, GFP_KERNEL);
if (!name)
return -ENOMEM;Message-ID: <[email protected]>
--- lib/test_firmware.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/test_firmware.c +6 -6
@@ -183,7 +183,7 @@ static int __kstrncpy(char **dst, const char *name, size_t count, gfp_t gfp) { *dst =kstrndup (name, count, gfp);if (!*dst) -return -ENOSPC ; +return -ENOMEM ;return count; }
@@ -606,7 +606,7 @@ static ssize_t trigger_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);
@@ -654,7 +654,7 @@ static ssize_t trigger_request_platform_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("inserting test platform fw '%s'\n" , name); efi_embedded_fw.name = name;
@@ -707,7 +707,7 @@ static ssize_t trigger_async_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);
@@ -752,7 +752,7 @@ static ssize_t trigger_custom_fallback_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s' using custom fallback mechanism\n" , name);
@@ -803,7 +803,7 @@ static int test_fw_run_batch_request(void *data) test_buf =kzalloc (TEST_FIRMWARE_BUF_SIZE ,GFP_KERNEL );if (!test_buf) -return -ENOSPC ; +return -ENOMEM ;if (test_fw_config->partial) req->rc = request_partial_firmware_into_buf
Signature · 1 line
2.39.2
Re: [PATCH 5.15 300/532] test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation
Quoted 94 lines · Greg Kroah-Hartman
From: Mirsad Goran Todorovac <[email protected]>
[ Upstream commit
7dae593cd226a0bca61201cf85ceb9335cf63682]In a couple of situations like
name = kstrndup(buf, count, GFP_KERNEL); if (!name) return -ENOSPC;the error is not actually "No space left on device", but "Out of memory".
It is semantically correct to return
-ENOMEMin all failedkstrndup()andkzalloc()cases in this driver, as it is not a problem with disk space, but with kernel memory allocator failing allocation.The semantically correct should be:
name = kstrndup(buf, count, GFP_KERNEL); if (!name) return -ENOMEM;Cc Dan Carpenter <[email protected]>Cc Takashi Iwai <[email protected]>Cc Kees Cook <[email protected]>Cc "Luis R. Rodriguez" <[email protected]>Cc Scott Branden <[email protected]>Cc Hans de Goede <[email protected]>Cc Brian Norris <[email protected]>Fixes c92316bf8e948 ("test_firmware: add batched firmware tests")Fixes 0a8adf584759c ("test: add firmware_class loader test")Fixes 548193cba2a7d ("test_firmware: add support for firmware_request_platform")Fixes eb910947c82f9 ("test: firmware_class: add asynchronous request trigger")Fixes 061132d2b9c95 ("test_firmware: add test custom fallback trigger")Fixes 7feebfa487b92 ("test_firmware: add support for request_firmware_into_buf")Signed-off-by Mirsad Goran Todorovac <[email protected]>Reviewed-by Dan Carpenter <[email protected]>Message-ID: <[email protected]>
Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- lib/test_firmware.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)lib/test_firmware.c +5
-5@@ -183,7 +183,7 @@ static int __kstrncpy(char **dst, const char *name, size_t count, gfp_t gfp) { *dst =kstrndup (name, count, gfp);if (!*dst) -return -ENOSPC ; +return -ENOMEM ;return count; }@@ -606,7 +606,7 @@ static ssize_t trigger_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);@@ -654,7 +654,7 @@ static ssize_t trigger_request_platform_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("inserting test platform fw '%s'\n" , name); efi_embedded_fw.name = name;@@ -707,7 +707,7 @@ static ssize_t trigger_async_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);@@ -752,7 +752,7 @@ static ssize_t trigger_custom_fallback_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s' using custom fallback mechanism\n" , name);
lib/test_firmware.c static int test_fw_run_batch_request(void *data) · line 809
Quoted 8 lines
lib/test_firmware.c +1
-1@@ -803,7 +803,7 @@ static int test_fw_run_batch_request(void *data) test_buf =kzalloc (TEST_FIRMWARE_BUF_SIZE ,GFP_KERNEL );if (!test_buf) -return -ENOSPC ; +return -ENOMEM ;if (test_fw_config->partial) req->rc = request_partial_firmware_into_buf
Just to note: this patch went to 5.10, 5.15 and 6.4, but not to 6.1 LTS.
Is there a particular reason for that, or is it a patchwork glitch?
Thanks,
Mirsad
Signature · 9 lines
Mirsad Todorovac System engineer Faculty of Graphic Arts | Academy of Fine Arts University of Zagreb Republic of Croatia, the European Union Sistem inženjer Grafički fakultet | Akademija likovnih umjetnosti Sveučilište u Zagrebu
Greg Kroah-Hartman
maintainerPATCH 301/532 nvmem: rmem: Use NVMEM_DEVID_AUTO
In reply to Greg Kroah-HartmanFrom: Phil Elwell <[email protected]>
[ Upstream commit 09dd7b993eddb3b48634fd5ddf27aa799785a9ee ]
It is reasonable to declare multiple nvmem blocks. Unless a unique 'id' is passed in for each block there may be name clashes.
Avoid this by using the magic token NVMEM_DEVID_AUTO.
Message-ID: <[email protected]>
--- drivers/nvmem/rmem.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/rmem.c +1 -0
@@ -71,6 +71,7 @@ static int rmem_probe(struct platform_device *pdev) config.dev = dev; config.priv = priv; config.name ="rmem" ; + config.id =NVMEM_DEVID_AUTO ; config.size = mem->size; config.reg_read = rmem_read;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 302/532 mfd: stmfx: Fix error path in stmfx_chip_init
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit f592cf624531286f8b52e40dcfc157a5a7fb115c ]
In error path, disable vdd regulator if it exists, but don't overload ret. Because if regulator_disable() is successful, stmfx_chip_init will exit successfully while chip init failed.
--- drivers/mfd/stmfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/stmfx.c +1 -1
@@ -387,7 +387,7 @@ static int stmfx_chip_init(struct i2c_client *client) err:if (stmfx->vdd) -return regulator_disable (stmfx->vdd); +regulator_disable (stmfx->vdd);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 303/532 mfd: stmfx: Nullify stmfx->vdd in case of error
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 7c81582c0bccb4757186176f0ee12834597066ad ]
Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error. And simplify code by returning an error only if return code is not -ENODEV, which means there is no vdd regulator and it is not an issue.
--- drivers/mfd/stmfx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/stmfx.c +2 -3
@@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client) stmfx->vdd =devm_regulator_get_optional (&client->dev,"vdd" ); ret =PTR_ERR_OR_ZERO (stmfx->vdd);if (ret) { -if (ret == -ENODEV ) - stmfx->vdd =NULL ; -else + stmfx->vdd =NULL ; +if (ret != -ENODEV )return dev_err_probe (&client->dev, ret,"Failed to get VDD regulator\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 304/532 KVM: s390: vsie: fix the length of APCB bitmap
In reply to Greg Kroah-HartmanFrom: Pierre Morel <[email protected]>
[ Upstream commit 246be7d2720ea9a795b576067ecc5e5c7a1e7848 ]
bit_and() uses the count of bits as the woking length. Fix the previous implementation and effectively use the right bitmap size.
--- arch/s390/kvm/vsie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
@@ -169,7 +169,8 @@ static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb0)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb0 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb0 ));return 0 ; }
@@ -191,7 +192,8 @@ static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb1)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb1 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb1 ));return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 305/532 KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
[ Upstream commit 0bc380beb78aa352eadbc21d934dd9606fcee808 ]
We do check for target CPU == -1, but this might change at the time we are going to use it. Hold the physical target CPU in a local variable to avoid out-of-bound accesses to the cpu arrays.
--- arch/s390/kvm/diag.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/s390/kvm/diag.c +5 -3
@@ -166,6 +166,7 @@ static int diag9c_forwarding_overrun(void)static int __diag_time_slice_end_directed (struct kvm_vcpu *vcpu) {struct kvm_vcpu *tcpu; +int tcpu_cpu;int tid; tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa &0xf0 ) >>4 ];
@@ -181,14 +182,15 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu) goto no_yield;/* target guest VCPU already running */ -if (READ_ONCE (tcpu->cpu) >=0 ) { + tcpu_cpu =READ_ONCE (tcpu->cpu); +if (tcpu_cpu >=0 ) {if (!diag9c_forwarding_hz ||diag9c_forwarding_overrun ()) goto no_yield;/* target host CPU already running */ -if (!vcpu_is_preempted (tcpu->cpu)) +if (!vcpu_is_preempted (tcpu_cpu)) goto no_yield; -smp_yield_cpu (tcpu->cpu); +smp_yield_cpu (tcpu_cpu);VCPU_EVENT (vcpu,5 ,"diag time slice end directed to %d: yield forwarded" , tid);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 306/532 mfd: stmpe: Only disable the regulators if they are enabled
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 104d32bd81f620bb9f67fbf7d1159c414e89f05f ]
In stmpe_probe(), if some regulator_enable() calls fail, probing continues and there is only a dev_warn().
So, if stmpe_probe() is called the regulator may not be enabled. It is cleaner to test it before calling regulator_disable() in the remove function.
--- drivers/mfd/stmpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/stmpe.c +2 -2
@@ -1498,9 +1498,9 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)int stmpe_remove (struct stmpe *stmpe) { -if (!IS_ERR (stmpe->vio)) +if (!IS_ERR (stmpe->vio) &®ulator_is_enabled (stmpe->vio))regulator_disable (stmpe->vio); -if (!IS_ERR (stmpe->vcc)) +if (!IS_ERR (stmpe->vcc) &®ulator_is_enabled (stmpe->vcc))regulator_disable (stmpe->vcc);__stmpe_disable (stmpe,STMPE_BLOCK_ADC );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 307/532 phy: tegra: xusb: check return value of devm_kzalloc()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 44faada0f38fc333d392af04c343b0e23f8f5d81 ]
devm_kzalloc() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/phy/tegra/xusb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/tegra/xusb.c +3 -0
@@ -669,6 +669,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) port->dev.driver =devm_kzalloc (&port->dev,sizeof (struct device_driver ),GFP_KERNEL ); +if (!port->dev.driver) +return -ENOMEM ; + port->dev.driver->owner =THIS_MODULE ; port->usb_role_sw = usb_role_switch_register(&port->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 308/532 pwm: imx-tpm: force real_period to be zero in suspend
In reply to Greg Kroah-HartmanFrom: Fancy Fang <[email protected]>
[ Upstream commit 661dfb7f46298e53f6c3deaa772fa527aae86193 ]
During suspend, all the tpm registers will lose values. So the 'real_period' value of struct 'imx_tpm_pwm_chip' should be forced to be zero to force the period update code can be executed after system resume back.
--- drivers/pwm/pwm-imx-tpm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pwm/pwm-imx-tpm.c +7 -0
@@ -397,6 +397,13 @@ static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)if (tpm->enable_count >0 )return -EBUSY ; +/* +* Force 'real_period' to be zero to force period update code +* can be executed after system resume back, since suspend causes +* the period related registers to become their reset values. +*/ + tpm->real_period =0 ; +clk_disable_unprepare (tpm->clk);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 309/532 pwm: sysfs: Do not apply state to already disabled PWMs
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 38ba83598633373f47951384cfc389181c8d1bed ]
If the PWM is exported but not enabled, do not call pwm_class_apply_state(). First of all, in this case, period may still be unconfigured and this would make pwm_class_apply_state() return -EINVAL, and then suspend would fail. Second, it makes little sense to apply state onto PWM that is not enabled before suspend.
Failing case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo mem > /sys/power/state ... pwm pwmchip4: PM: dpm_run_callback(): pwm_class_suspend+0x1/0xa8 returns -22 pwm pwmchip4: PM: failed to suspend: error -22 PM: Some devices failed to suspend, or early wake event detected "
Working case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo 100 > /sys/class/pwm/pwmchip4/pwm1/period $ echo 10 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle $ echo mem > /sys/power/state ... "
Do not call pwm_class_apply_state() in case the PWM is disabled to fix this issue.
--- drivers/pwm/sysfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/pwm/sysfs.c +17 -0
@@ -424,6 +424,13 @@ static int pwm_class_resume_npwm(struct device *parent, unsigned int npwm)if (!export)continue ; +/* If pwmchip was not enabled before suspend, do nothing. */ +if (!export->suspend.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = export->suspend.enabled; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 )
@@ -448,7 +455,17 @@ static int __maybe_unused pwm_class_suspend(struct device *parent)if (!export)continue ; +/* +* If pwmchip was not enabled before suspend, save +* state for resume time and do nothing else. +*/ export->suspend = state; +if (!state.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = false; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 310/532 pwm: ab8500: Fix error code in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit cdcffafc4d845cc0c6392cba168c7a942734cce7 ]
This code accidentally return positive EINVAL instead of negative -EINVAL.
--- drivers/pwm/pwm-ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-ab8500.c +1 -1
@@ -96,7 +96,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)int err;if (pdev->id <1 || pdev->id >31 ) -return dev_err_probe (&pdev->dev,EINVAL ,"Invalid device id %d\n" , pdev->id); +return dev_err_probe (&pdev->dev, -EINVAL ,"Invalid device id %d\n" , pdev->id);/* * Nothing to be done in probe, this is required to get the
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 311/532 pwm: mtk_disp: Fix the disable flow of disp_pwm
In reply to Greg Kroah-HartmanFrom: Shuijing Li <[email protected]>
[ Upstream commit bc13d60e4e1e945b34769a4a4c2b172e8552abe5 ]
There is a flow error in the original mtk_disp_pwm_apply() function. If this function is called when the clock is disabled, there will be a chance to operate the disp_pwm register, resulting in disp_pwm exception. Fix this accordingly.
--- drivers/pwm/pwm-mtk-disp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/pwm/pwm-mtk-disp.c +5 -8
@@ -79,14 +79,11 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,if (state->polarity !=PWM_POLARITY_NORMAL )return -EINVAL ; -if (!state->enabled) { -mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , mdp->data->enable_mask, -0x0 ); - -if (mdp->enabled) { -clk_disable_unprepare (mdp->clk_mm); -clk_disable_unprepare (mdp->clk_main); - } +if (!state->enabled && mdp->enabled) { +mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , + mdp->data->enable_mask,0x0 ); +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main); mdp->enabled = false;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 312/532 md/raid10: fix the condition to call bio_end_io_acct()
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 125bfc7cd750e68c99f1d446e2c22abea08c237f ]
/sys/block/[device]/queue/iostats is used to control whether to count io stat. Write 0 to it will clear queue_flags QUEUE_FLAG_IO_STAT which means iostats is disabled. If we disable iostats and later endable it, the io issued during this period will be counted incorrectly, inflight will be decreased to -1.
//T1 set iostats
echo 0 > /sys/block/md0/queue/iostats
clear QUEUE_FLAG_IO_STAT
//T2 issue io if (QUEUE_FLAG_IO_STAT) -> false bio_start_io_acct inflight++
echo 1 > /sys/block/md0/queue/iostats
set QUEUE_FLAG_IO_STAT
//T3 io end if (QUEUE_FLAG_IO_STAT) -> true bio_end_io_acct inflight-- -> -1
Also, if iostats is enabled while issuing io but disabled while io end, inflight will never be decreased.
Fix it by checking start_time when io end. If start_time is not 0, call bio_end_io_acct().
--- drivers/md/raid10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid10.c +1 -1
@@ -297,7 +297,7 @@ static void raid_end_bio_io(struct r10bio *r10_bio)if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) bio->bi_status =BLK_STS_IOERR ; -if (blk_queue_io_stat (bio->bi_bdev->bd_disk->queue)) +if (r10_bio->start_time)bio_end_io_acct (bio, r10_bio->start_time);bio_endio (bio);/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 313/532 rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 06c6e1b01d9261f03629cefd1f3553503291e6cf ]
If an error occurs after clk_get(), the corresponding resources should be released.
Use devm_clk_get() to fix it.
--- drivers/rtc/rtc-st-lpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-st-lpc.c +1 -1
@@ -228,7 +228,7 @@ static int st_rtc_probe(struct platform_device *pdev)enable_irq_wake (rtc->irq);disable_irq (rtc->irq); - rtc->clk =clk_get (&pdev->dev,NULL ); + rtc->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (rtc->clk)) {dev_err (&pdev->dev,"Unable to request clock\n" );return PTR_ERR (rtc->clk);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 314/532 drm/i915/psr: Use hw.adjusted mode when calculating io/fast wake times
In reply to Greg Kroah-HartmanFrom: Jouni Högander <[email protected]>
[ Upstream commit 5311892a0ad1d301aafd53ca0154091b3eb407ea ]
Encoder compute config is changing hw.adjusted mode. Uapi.adjusted mode doesn't get updated before psr compute config gets called. This causes io and fast wake line calculation using adjusted mode containing values before encoder adjustments. Fix this by using hw.adjusted mode instead of uapi.adjusted mode.
--- drivers/gpu/drm/i915/display/intel_psr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_psr.c +2 -2
@@ -862,9 +862,9 @@ static bool _compute_psr2_wake_times(struct intel_dp *intel_dp, } io_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, io_wake_time); + &crtc_state->hw.adjusted_mode, io_wake_time); fast_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, fast_wake_time); + &crtc_state->hw.adjusted_mode, fast_wake_time);if (io_wake_lines > max_wake_lines || fast_wake_lines > max_wake_lines)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 315/532 media: cec: i2c: ch7322: also select REGMAP
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 29f96ac23648b2259f42d40703c47dd18fd172ca ]
Selecting only REGMAP_I2C can leave REGMAP unset, causing build errors, so also select REGMAP to prevent the build errors.
../drivers/media/cec/i2c/ch7322.c:158:21: error: variable 'ch7322_regmap' has initializer but incomplete type
158 | static const struct regmap_config ch7322_regmap = {../drivers/media/cec/i2c/ch7322.c:159:10: error: 'const struct regmap_config' has no member named 'reg_bits'
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:159:21: warning: excess elements in struct initializer
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:10: error: 'const struct regmap_config' has no member named 'val_bits'
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:21: warning: excess elements in struct initializer
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:161:10: error: 'const struct regmap_config' has no member named 'max_register'
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:161:25: warning: excess elements in struct initializer
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:162:10: error: 'const struct regmap_config' has no member named 'disable_locking'
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c:162:28: warning: excess elements in struct initializer
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c: In function 'ch7322_probe':../drivers/media/cec/i2c/ch7322.c:468:26: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c:468:24: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c: At top level:../drivers/media/cec/i2c/ch7322.c:158:35: error: storage size of 'ch7322_regmap' isn't known
158 | static const struct regmap_config ch7322_regmap = {
--- drivers/media/cec/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/cec/i2c/Kconfig +1 -0
@@ -5,6 +5,7 @@ config CEC_CH7322 tristate "Chrontel CH7322 CEC controller" depends on I2C + select REGMAP select REGMAP_I2C select CEC_CORE help
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 316/532 sctp: fix potential deadlock on &net->sctp.addr_wq_lock
In reply to Greg Kroah-HartmanFrom: Chengfeng Ye <[email protected]>
[ Upstream commit 6feb37b3b06e9049e20dcf7e23998f92c9c5be9a ]
As &net->sctp.addr_wq_lock is also acquired by the timer sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition at sctp_auto_asconf_init() seems should disable irq since it is called from sctp_accept() under process context.
Possible deadlock scenario:sctp_accept()
-> sctp_sock_migrate()
-> sctp_auto_asconf_init()
-> spin_lock(&net->sctp.addr_wq_lock)
<timer interrupt>
-> sctp_addr_wq_timeout_handler()
-> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)This flaw was found using an experimental static analysis tool we are developing for irq-related deadlock.
The tentative patch fix the potential deadlock by spin_lock_bh().
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -362,9 +362,9 @@ static void sctp_auto_asconf_init(struct sctp_sock *sp)struct net *net =sock_net (&sp->inet.sk);if (net->sctp.default_auto_asconf) { -spin_lock (&net->sctp.addr_wq_lock); +spin_lock_bh (&net->sctp.addr_wq_lock);list_add_tail (&sp->auto_asconf_list, &net->sctp.auto_asconf_splist); -spin_unlock (&net->sctp.addr_wq_lock); +spin_unlock_bh (&net->sctp.addr_wq_lock); sp->do_auto_asconf =1 ; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 317/532 net/sched: act_ipt: add sanity checks on table name and hook locations
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit b4ee93380b3c891fea996af8d1d3ca0e36ad31f0 ]
Looks like "tc" hard-codes "mangle" as the only supported table name, but on kernel side there are no checks.
This is wrong. Not all xtables targets are safe to call from tc. E.g. "nat" targets assume skb has a conntrack object assigned to it. Normally those get called from netfilter nat core which consults the nat table to obtain the address mapping.
"tc" userspace either sets PRE or POSTROUTING as hook number, but there is no validation of this on kernel side, so update netlink policy to reject bogus numbers. Some targets may assume skb_dst is set for input/forward hooks, so prevent those from being used.
act_ipt uses the hook number in two places:
1. the state hook number, this is fine as-is
2. to set par.hook_mask
The latter is a bit mask, so update the assignment to make xt_check_target() to the right thing.
Followup patch adds required checks for the skb/packet headers before calling the targets evaluation function.
--- net/sched/act_ipt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
net/sched/act_ipt.c +20 -7
@@ -50,7 +50,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t, par.entryinfo = &e; par.target = target; par.targinfo = t->data; - par.hook_mask = hook; + par.hook_mask =1 << hook; par.family =NFPROTO_IPV4 ; ret =xt_check_target (&par, t->u.target_size -sizeof (*t),0 , false);
@@ -87,7 +87,8 @@ static void tcf_ipt_release(struct tc_action *a)static const struct nla_policy ipt_policy[TCA_IPT_MAX +1 ] = { [TCA_IPT_TABLE ] = { .type =NLA_STRING , .len =IFNAMSIZ }, - [TCA_IPT_HOOK ] = { .type =NLA_U32 }, + [TCA_IPT_HOOK ] =NLA_POLICY_RANGE (NLA_U32 ,NF_INET_PRE_ROUTING , +NF_INET_NUMHOOKS ), [TCA_IPT_INDEX ] = { .type =NLA_U32 }, [TCA_IPT_TARG ] = { .len =sizeof (struct xt_entry_target ) }, };
@@ -160,15 +161,27 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,return -EEXIST ; } } + + err = -EINVAL ; hook =nla_get_u32 (tb[TCA_IPT_HOOK ]); +switch (hook) { +case NF_INET_PRE_ROUTING : +break ; +case NF_INET_POST_ROUTING : +break ; +default : + goto err1; + } + +if (tb[TCA_IPT_TABLE ]) { +/* mangle only for now */ +if (nla_strcmp (tb[TCA_IPT_TABLE ],"mangle" )) + goto err1; + } - err = -ENOMEM ; - tname =kmalloc (IFNAMSIZ ,GFP_KERNEL ); + tname =kstrdup ("mangle" ,GFP_KERNEL );if (unlikely (!tname)) goto err1; -if (tb[TCA_IPT_TABLE ] ==NULL || -nla_strscpy (tname, tb[TCA_IPT_TABLE ],IFNAMSIZ ) >=IFNAMSIZ ) -strcpy (tname,"mangle" ); t =kmemdup (td, td->u.target_size,GFP_KERNEL );if (unlikely (!t))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 318/532 Add MODULE_FIRMWARE() for FIRMWARE_TG357766.
In reply to Greg Kroah-HartmanFrom: Tobias Heider <[email protected]>
[ Upstream commit 046f753da6143ee16452966915087ec8b0de3c70 ]
Fixes a bug where on the M1 mac mini initramfs-tools fails to include the necessary firmware into the initrd.
--- drivers/net/ethernet/broadcom/tg3.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/tg3.c +1 -0
@@ -224,6 +224,7 @@ MODULE_AUTHOR("David S. Miller ([email protected]) and Jeff Garzik (jgarzik@poboxMODULE_DESCRIPTION ("Broadcom Tigon3 ethernet driver" );MODULE_LICENSE ("GPL" );MODULE_FIRMWARE (FIRMWARE_TG3 ); +MODULE_FIRMWARE (FIRMWARE_TG357766 );MODULE_FIRMWARE (FIRMWARE_TG3TSO );MODULE_FIRMWARE (FIRMWARE_TG3TSO5 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 319/532 ibmvnic: Do not reset dql stats on NON_FATAL err
In reply to Greg Kroah-HartmanFrom: Nick Child <[email protected]>
[ Upstream commit 48538ccb825b05544ec308a509e2cc9c013402db ]
All ibmvnic resets, make a call to netdev_tx_reset_queue() when re-opening the device. netdev_tx_reset_queue() resets the num_queued and num_completed byte counters. These stats are used in Byte Queue Limit (BQL) algorithms. The difference between these two stats tracks the number of bytes currently sitting on the physical NIC. ibmvnic increases the number of queued bytes though calls to netdev_tx_sent_queue() in the drivers xmit function. When, VIOS reports that it is done transmitting bytes, the ibmvnic device increases the number of completed bytes through calls to netdev_tx_completed_queue(). It is important to note that the driver batches its transmit calls and num_queued is increased every time that an skb is added to the next batch, not necessarily when the batch is sent to VIOS for transmission.
Unlike other reset types, a NON FATAL reset will not flush the sub crq tx buffers. Therefore, it is possible for the batched skb array to be partially full. So if there is call to netdev_tx_reset_queue() when re-opening the device, the value of num_queued (0) would not account for the skb's that are currently batched. Eventually, when the batch is sent to VIOS, the call to netdev_tx_completed_queue() would increase num_completed to a value greater than the num_queued. This causes a BUG_ON crash:
ibmvnic 30000002: Firmware reports error, cause: adapter problem. Starting recovery...
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
------------[ cut here ]------------ kernel BUG at lib/dynamic_queue_limits.c:27! Oops: Exception in kernel mode, sig: 5 [....] NIP dql_completed+0x28/0x1c0 LR ibmvnic_complete_tx.isra.0+0x23c/0x420 [ibmvnic] Call Trace: ibmvnic_complete_tx.isra.0+0x3f8/0x420 [ibmvnic] (unreliable) ibmvnic_interrupt_tx+0x40/0x70 [ibmvnic] __handle_irq_event_percpu+0x98/0x270 ---[ end trace ]---
Therefore, do not reset the dql stats when performing a NON_FATAL reset.
--- drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +8 -1
@@ -1240,7 +1240,14 @@ static int __ibmvnic_open(struct net_device *netdev)if (prev_state ==VNIC_CLOSED )enable_irq (adapter->tx_scrq[i]->irq);enable_scrq_irq (adapter, adapter->tx_scrq[i]); -netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); +/* netdev_tx_reset_queue will reset dql stats. During NON_FATAL +* resets, don't reset the stats because there could be batched +* skb's waiting to be sent. If we reset dql stats, we risk +* num_completed being greater than num_queued. This will cause +* a BUG_ON in dql_completed(). +*/ +if (adapter->reset_reason !=VNIC_RESET_NON_FATAL ) +netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); } rc =set_link_state (adapter,IBMVNIC_LOGICAL_LNK_UP );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 320/532 net: dsa: vsc73xx: fix MTU configuration
In reply to Greg Kroah-HartmanFrom: Pawel Dembicki <[email protected]>
[ Upstream commit 3cf62c8177adb0db9e15c8b898c44f997acf3ebf ]
Switch in MAXLEN register stores the maximum size of a data frame. The MTU size is 18 bytes smaller than the frame size.
The current settings are causing problems with packet forwarding. This patch fixes the MTU settings to proper values.
--- drivers/net/dsa/vitesse-vsc73xx-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/vitesse-vsc73xx-core.c +3 -3
@@ -1025,17 +1025,17 @@ static int vsc73xx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)struct vsc73xx *vsc = ds->priv;return vsc73xx_write (vsc,VSC73XX_BLOCK_MAC , port, -VSC73XX_MAXLEN , new_mtu); +VSC73XX_MAXLEN , new_mtu +ETH_HLEN +ETH_FCS_LEN ); }/* According to application not "VSC7398 Jumbo Frames" setting -* up the MTU to 9.6 KB does not affect the performance on standard +* up the frame size to 9.6 KB does not affect the performance on standard * frames. It is clear from the application note that * "9.6 kilobytes" == 9600 bytes. */ static int vsc73xx_get_max_mtu (struct dsa_switch *ds,int port) { -return 9600 ; +return 9600 -ETH_HLEN -ETH_FCS_LEN ; }static const struct dsa_switch_ops vsc73xx_ds_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 321/532 spi: bcm-qspi: return error if neither hif_mspi nor mspi is available
In reply to Greg Kroah-HartmanFrom: Jonas Gorski <[email protected]>
[ Upstream commit 7c1f23ad34fcdace50275a6aa1e1969b41c6233f ]
If neither a "hif_mspi" nor "mspi" resource is present, the driver will just early exit in probe but still return success. Apart from not doing anything meaningful, this would then also lead to a null pointer access on removal, as platform_get_drvdata() would return NULL, which it would then try to dereference when trying to unregister the spi master.
Fix this by unconditionally calling devm_ioremap_resource(), as it can handle a NULL res and will then return a viable ERR_PTR() if we get one.
The "return 0;" was previously a "goto qspi_resource_err;" where then ret was returned, but since ret was still initialized to 0 at this place this was a valid conversion in 63c5395bb7a9 ("spi: bcm-qspi: Fix use-after-free on unbind"). The issue was not introduced by this commit, only made more obvious.
--- drivers/spi/spi-bcm-qspi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/spi/spi-bcm-qspi.c +3 -7
@@ -1370,13 +1370,9 @@ int bcm_qspi_probe(struct platform_device *pdev, res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mspi" ); -if (res) { - qspi->base[MSPI ] =devm_ioremap_resource (dev, res); -if (IS_ERR (qspi->base[MSPI ])) -return PTR_ERR (qspi->base[MSPI ]); - }else { -return 0 ; - } + qspi->base[MSPI ] =devm_ioremap_resource (dev, res); +if (IS_ERR (qspi->base[MSPI ])) +return PTR_ERR (qspi->base[MSPI ]); res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"bspi" );if (res) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 322/532 mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
[ Upstream commit 1b712f18c461bd75f018033a15cf381e712806b5 ]
Sec proxy/message manager data buffer is 60 bytes with the last of the registers indicating transmission completion. This however poses a bit of a challenge.
The backing memory for sec_proxy / message manager is regular memory, and all sec proxy does is to trigger a burst of all 60 bytes of data over to the target thread backing ring accelerator. It doesn't do a memory scrub when it moves data out in the burst. When we transmit multiple messages, remnants of previous message is also transmitted which results in some random data being set in TISCI fields of messages that have been expanded forward.
The entire concept of backward compatibility hinges on the fact that the unused message fields remain 0x0 allowing for 0x0 value to be specially considered when backward compatibility of message extension is done.
So, instead of just writing the completion register, we continue to fill the message buffer up with 0x0 (note: for partial message involving completion, we already do this).
This allows us to scale and introduce ABI changes back also work with other boot stages that may have left data in the internal memory.
While at this, be consistent and explicit with the data_reg pointer increment.
--- drivers/mailbox/ti-msgmgr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mailbox/ti-msgmgr.c +9 -3
@@ -385,14 +385,20 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)/* Ensure all unused data is 0 */ data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes));writel (data_trail, data_reg); - data_reg++; + data_reg +=sizeof (u32); } +/* * 'data_reg' indicates next register to write. If we did not already * write on tx complete reg(last reg), we must do so for transmit +* In addition, we also need to make sure all intermediate data +* registers(if any required), are reset to 0 for TISCI backward +* compatibility to be maintained. */ -if (data_reg <= qinst->queue_buff_end) -writel (0 , qinst->queue_buff_end); +while (data_reg <= qinst->queue_buff_end) { +writel (0 , data_reg); + data_reg +=sizeof (u32); + }return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 323/532 f2fs: fix error path handling in truncate_dnode()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 0135c482fa97e2fd8245cb462784112a00ed1211 ]
If truncate_node() fails in truncate_dnode(), it missed to call f2fs_put_page(), fix it.
--- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +3 -1
@@ -942,8 +942,10 @@ static int truncate_dnode(struct dnode_of_data *dn) dn->ofs_in_node =0 ;f2fs_truncate_data_blocks (dn); err =truncate_node (dn); -if (err) +if (err) { +f2fs_put_page (page,1 );return err; + }return 1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 324/532 octeontx2-af: Fix mapping for NIX block from CGX connection
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 2e7bc57b976bb016c6569a54d95c1b8d88f9450a ]
Firmware configures NIX block mapping for all MAC blocks. The current implementation reads the configuration and creates the mapping between RVU PF and NIX blocks. But this configuration is only valid for silicons that support multiple blocks. For all other silicons, all MAC blocks map to NIX0.
This patch corrects the mapping by adding a check for the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 11 +++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +11 -0
@@ -23,6 +23,7 @@#define PCI_DEVID_OCTEONTX2_LBK 0xA061/* Subsystem Device ID */ +#define PCI_SUBSYS_DEVID_98XX 0xB100#define PCI_SUBSYS_DEVID_96XX 0xB200#define PCI_SUBSYS_DEVID_CN10K_A 0xB900
@@ -614,6 +615,16 @@ static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)return rvu->hw->cpt_chan_base + chan; } +static inline bool is_rvu_supports_nix1 (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; + +if (pdev->subsystem_device ==PCI_SUBSYS_DEVID_98XX ) +return true; + +return false; +} +/* Function Prototypes * RVU */
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -111,7 +111,7 @@ static void rvu_map_cgx_nix_block(struct rvu *rvu, int pf, p2x =cgx_lmac_get_p2x (cgx_id, lmac_id);/* Firmware sets P2X_SELECT as either NIX0 or NIX1 */ pfvf->nix_blkaddr =BLKADDR_NIX0 ; -if (p2x ==CMR_P2X_SEL_NIX1 ) +if (is_rvu_supports_nix1 (rvu) && p2x ==CMR_P2X_SEL_NIX1 ) pfvf->nix_blkaddr =BLKADDR_NIX1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 325/532 octeontx2-af: Add validation before accessing cgx and lmac
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 79ebb53772c95d3a6ae51b3c65f9985fdd430df6 ]
with the addition of new MAC blocks like CN10K RPM and CN10KB RPM_USX, LMACs are noncontiguous and CGX blocks are also noncontiguous. But during RVU driver initialization, the driver is assuming they are contiguous and trying to access cgx or lmac with their id which is resulting in kernel panic.
This patch fixes the issue by adding proper checks.
[ 23.219150] pc : cgx_lmac_read+0x38/0x70 [ 23.219154] lr : rvu_program_channels+0x3f0/0x498 [ 23.223852] sp : ffff000100d6fc80 [ 23.227158] x29: ffff000100d6fc80 x28: ffff00010009f880 x27: 000000000000005a [ 23.234288] x26: ffff000102586768 x25: 0000000000002500 x24:
fffffffffff0f000
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +7 -0
@@ -167,6 +167,9 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return ;cgx_write (cgx_dev, lmac_id, offset, val); }
@@ -174,6 +177,10 @@ u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return 0 ; +return cgx_read (cgx_dev, lmac_id, offset); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 326/532 ntfs: Fix panic about slab-out-of-bounds caused by ntfs_listxattr()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit 3c675ddffb17a8b1e32efad5c983254af18b12c2 ]
Here is a BUG report from syzbot:
BUG: KASAN: slab-out-of-bounds in ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] BUG: KASAN: slab-out-of-bounds in ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 Read of size 1 at addr ffff888021acaf3d by task syz-executor128/3632 Call Trace: ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 vfs_listxattr fs/xattr.c:457 [inline] listxattr+0x293/0x2d0 fs/xattr.c:804
Fix the logic of ea_all iteration. When the ea->name_len is 0, return immediately, or Add2Ptr() would visit invalid memory in the next loop.
--- fs/ntfs3/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/xattr.c +3 -0
@@ -178,6 +178,9 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,for (ret =0 , off =0 ; off < size; off +=unpacked_ea_size (ea)) { ea =Add2Ptr (ea_all, off); +if (!ea->name_len) +break ; +if (buffer) {if (ret + ea->name_len +1 > bytes_per_buffer) { err = -ERANGE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 327/532 powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 39f49684036d24af800ff194c33c7b2653c591d7 ]
In a randconfig with CONFIG_SERIAL_CPM=m and CONFIG_PPC_EARLY_DEBUG_CPM=y, there is a build error:
ERROR: modpost: "udbg_putc" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
Prevent the build error by allowing PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y.
--- arch/powerpc/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig.debug +1 -1
@@ -240,7 +240,7 @@ config PPC_EARLY_DEBUG_40x config PPC_EARLY_DEBUG_CPM bool "Early serial debugging for Freescale CPM-based serial ports" - depends on SERIAL_CPM + depends on SERIAL_CPM=y help Select this to enable early debugging for Freescale chips using a CPM-based serial port. This assumes that the bootwrapper
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 328/532 net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 6ca3c005d0604e8d2b439366e3923ea58db99641 ]
According to the synchronization rules for .ndo_get_stats() as seen in Documentation/networking/netdevices.rst, acquiring a plain spin_lock() should not be illegal, but the bridge driver implementation makes it so.
After running these commands, I am being faced with the following lockdep splat:
$ ip link add link swp0 name macsec0 type macsec encrypt on && ip link set swp0 up $ ip link add dev br0 type bridge vlan_filtering 1 && ip link set br0 up $ ip link set macsec0 master br0 && ip link set macsec0 up
========================================================
WARNING: possible irq lock inversion dependency detected 6.4.0-04295-g31b577b4bd4a #603 Not tainted
--------------------------------------------------------
swapper/1/0 just changed the state of lock:
ffff6bd348724cd8 (&br->lock){+.-.}-{3:3}, at: br_forward_delay_timer_expired+0x34/0x198 but this lock took another, SOFTIRQ-unsafe lock in the past:
(&ocelot->stats_lock){+.+.}-{3:3}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of:
&br->lock --> &br->hash_lock --> &ocelot->stats_lockPossible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&ocelot->stats_lock);
local_irq_disable();
lock(&br->lock);
lock(&br->hash_lock);
<Interrupt>
lock(&br->lock);*** DEADLOCK ***
(details about the 3 locks skipped)
swp0 is instantiated by drivers/net/dsa/ocelot/felix.c, and this only matters to the extent that its .ndo_get_stats64() method calls spin_lock(&ocelot->stats_lock).
Documentation/locking/lockdep-design.rst says:
| A lock is irq-safe means it was ever used in an irq context, while a lock | is irq-unsafe means it was ever acquired with irq enabled.
(...)
| Furthermore, the following usage based lock dependencies are not allowed | between any two lock-classes:: | | <hardirq-safe> -> <hardirq-unsafe> | <softirq-safe> -> <softirq-unsafe>
Lockdep marks br->hash_lock as softirq-safe, because it is sometimes taken in softirq context (for example br_fdb_update() which runs in NET_RX softirq), and when it's not in softirq context it blocks softirqs by using spin_lock_bh().
Lockdep marks ocelot->stats_lock as softirq-unsafe, because it never blocks softirqs from running, and it is never taken from softirq context. So it can always be interrupted by softirqs.
There is a call path through which a function that holds br->hash_lock:fdb_add_hw_addr() will call a function that acquires ocelot->stats_lock:ocelot_port_get_stats64(). This can be seen below:
ocelot_port_get_stats64+0x3c/0x1e0 felix_get_stats64+0x20/0x38 dsa_slave_get_stats64+0x3c/0x60 dev_get_stats+0x74/0x2c8 rtnl_fill_stats+0x4c/0x150 rtnl_fill_ifinfo+0x5cc/0x7b8 rtmsg_ifinfo_build_skb+0xe4/0x150 rtmsg_ifinfo+0x5c/0xb0 __dev_notify_flags+0x58/0x200 __dev_set_promiscuity+0xa0/0x1f8 dev_set_promiscuity+0x30/0x70 macsec_dev_change_rx_flags+0x68/0x88 __dev_set_promiscuity+0x1a8/0x1f8 __dev_set_rx_mode+0x74/0xa8 dev_uc_add+0x74/0xa0 fdb_add_hw_addr+0x68/0xd8 fdb_add_local+0xc4/0x110 br_fdb_add_local+0x54/0x88 br_add_if+0x338/0x4a0 br_add_slave+0x20/0x38 do_setlink+0x3a4/0xcb8 rtnl_newlink+0x758/0x9d0 rtnetlink_rcv_msg+0x2f0/0x550 netlink_rcv_skb+0x128/0x148 rtnetlink_rcv+0x24/0x38
the plain English explanation for it is:
The macsec0 bridge port is created without p->flags & BR_PROMISC, because it is what br_manage_promisc() decides for a VLAN filtering bridge with a single auto port.
As part of the br_add_if() procedure, br_fdb_add_local() is called for the MAC address of the device, and this results in a call to dev_uc_add() for macsec0 while the softirq-safe br->hash_lock is taken.
Because macsec0 does not have IFF_UNICAST_FLT, dev_uc_add() ends up calling __dev_set_promiscuity() for macsec0, which is propagated by its implementation, macsec_dev_change_rx_flags(), to the lower device: swp0. This triggers the call path:
dev_set_promiscuity(swp0)
-> rtmsg_ifinfo()
-> dev_get_stats()
-> ocelot_port_get_stats64()
with a calling context that lockdep doesn't like (br->hash_lock held).
Normally we don't see this, because even though many drivers that can be bridge ports don't support IFF_UNICAST_FLT, we need a driver that
(a) doesn't support IFF_UNICAST_FLT, *and*
(b) it forwards the IFF_PROMISC flag to another driver, and
(c) *that* driver implements ndo_get_stats64() using a softirq-unsafe spinlock.
Condition (b) is necessary because the first __dev_set_rx_mode() calls __dev_set_promiscuity() with "bool notify=false", and thus, the rtmsg_ifinfo() code path won't be entered.
The same criteria also hold true for DSA switches which don't report IFF_UNICAST_FLT. When the DSA master uses a spin_lock() in its ndo_get_stats64() method, the same lockdep splat can be seen.
I think the deadlock possibility is real, even though I didn't reproduce it, and I'm thinking of the following situation to support that claim:
fdb_add_hw_addr() runs on a CPU A, in a context with softirqs locally disabled and br->hash_lock held, and may end up attempting to acquire ocelot->stats_lock.
In parallel, ocelot->stats_lock is currently held by a thread B (say, ocelot_check_stats_work()), which is interrupted while holding it by a softirq which attempts to lock br->hash_lock.
Thread B cannot make progress because br->hash_lock is held by A. Whereas thread A cannot make progress because ocelot->stats_lock is held by B.
When taking the issue at face value, the bridge can avoid that problem by simply making the ports promiscuous from a code path with a saner calling context (br->hash_lock not held). A bridge port without IFF_UNICAST_FLT is going to become promiscuous as soon as we call dev_uc_add() on it (which we do unconditionally), so why not be preemptive and make it promiscuous right from the beginning, so as to not be taken by surprise.
With this, we've broken the links between code that holds br->hash_lock or br->lock and code that calls into the ndo_change_rx_flags() or ndo_get_stats64() ops of the bridge port.
--- net/bridge/br_if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/bridge/br_if.c +3 -2
@@ -157,8 +157,9 @@ void br_manage_promisc(struct net_bridge *br)* This lets us disable promiscuous mode and write * this config to hw. */ -if (br->auto_cnt ==0 || - (br->auto_cnt ==1 &&br_auto_port (p))) +if ((p->dev->priv_flags &IFF_UNICAST_FLT ) && + (br->auto_cnt ==0 || + (br->auto_cnt ==1 &&br_auto_port (p))))br_port_clear_promisc (p);else br_port_set_promisc (p);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 329/532 tcp: annotate data races in __tcp_oow_rate_limited()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 998127cdb4699b9d470a9348ffe9f1154346be5f ]
request sockets are lockless, __tcp_oow_rate_limited() could be called on the same object from different cpus. This is harmless.
Add READ_ONCE()/WRITE_ONCE() annotations to avoid a KCSAN report.
--- net/ipv4/tcp_input.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +9 -3
@@ -3584,8 +3584,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32static bool __tcp_oow_rate_limited (struct net *net,int mib_idx,u32 *last_oow_ack_time) { -if (*last_oow_ack_time) { -s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time); +/* Paired with the WRITE_ONCE() in this function. */ +u32 val =READ_ONCE (*last_oow_ack_time); + +if (val) { +s32 elapsed = (s32)(tcp_jiffies32 - val);if (0 <= elapsed && elapsed <READ_ONCE (net->ipv4.sysctl_tcp_invalid_ratelimit)) {
@@ -3594,7 +3597,10 @@ static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, } } - *last_oow_ack_time = tcp_jiffies32; +/* Paired with the prior READ_ONCE() and with itself, +* as we might be lockless. +*/ +WRITE_ONCE (*last_oow_ack_time, tcp_jiffies32);return false;/* not rate-limited: go ahead, send dupack now! */ }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 330/532 xsk: Honor SO_BINDTODEVICE on bind
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit f7306acec9aae9893d15e745c8791124d42ab10a ]
Initial creation of an AF_XDP socket requires CAP_NET_RAW capability. A privileged process might create the socket and pass it to a non-privileged process for later use. However, that process will be able to bind the socket to any network interface. Even though it will not be able to receive any traffic without modification of the BPF map, the situation is not ideal.
Sockets already have a mechanism that can be used to restrict what interface they can be attached to. That is SO_BINDTODEVICE.
To change the SO_BINDTODEVICE binding the process will need CAP_NET_RAW.
Make xsk_bind() honor the SO_BINDTODEVICE in order to allow safer workflow when non-privileged process is using AF_XDP.
The intended workflow is following:
1. First process creates a bare socket with socket(AF_XDP, ...).
2. First process loads the XSK program to the interface.
3. First process adds the socket fd to a BPF map.
4. First process ties socket fd to a particular interface using SO_BINDTODEVICE.
5. First process sends socket fd to a second process.
6. Second process allocates UMEM.
7. Second process binds socket to the interface with bind(...).
8. Second process sends/receives the traffic.
All the steps above are possible today if the first process is privileged and the second one has sufficient RLIMIT_MEMLOCK and no capabilities. However, the second process will be able to bind the socket to any interface it wants on step 7 and send traffic from it. With the proposed change, the second process will be able to bind the socket only to a specific interface chosen by the first process at step 4.
--- Documentation/networking/af_xdp.rst | 9 +++++++++ net/xdp/xsk.c | 5 +++++ 2 files changed, 14 insertions(+)
Documentation/networking/af_xdp.rst +9 -0
@@ -433,6 +433,15 @@ start N bytes into the buffer leaving the first N bytes for the application to use. The final option is the flags field, but it will be dealt with in separate sections for each UMEM flag. +SO_BINDTODEVICE setsockopt +-------------------------- + +This is a generic SOL_SOCKET option that can be used to tie AF_XDP +socket to a particular network interface. It is useful when a socket +is created by a privileged process and passed to a non-privileged one. +Once the option is set, kernel will refuse attempts to bind that socket +to a different interface. Updating the value requires CAP_NET_RAW. + XDP_STATISTICS getsockopt -------------------------
net/xdp/xsk.c +5 -0
@@ -893,6 +893,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)struct sock *sk = sock->sk;struct xdp_sock *xs =xdp_sk (sk);struct net_device *dev; +int bound_dev_if;u32 flags, qid;int err =0 ;
@@ -906,6 +907,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) XDP_USE_NEED_WAKEUP))return -EINVAL ; + bound_dev_if =READ_ONCE (sk->sk_bound_dev_if); +if (bound_dev_if && bound_dev_if != sxdp->sxdp_ifindex) +return -EINVAL ; +rtnl_lock ();mutex_lock (&xs->mutex);if (xs->state !=XSK_READY ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 331/532 net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit 30c45b5361d39b4b793780ffac5538090b9e2eb1 ]
The attribute TCA_PEDIT_PARMS_EX is not be included in pedit_policy and one malicious user could fake a TCA_PEDIT_PARMS_EX whose length is smaller than the intended sizeof(struct tc_pedit). Hence, the dereference in tcf_pedit_init() could access dirty heap data.
static int tcf_pedit_init(...)
{
// ...
pattr = tb[TCA_PEDIT_PARMS]; // TCA_PEDIT_PARMS is included if (!pattr)
pattr = tb[TCA_PEDIT_PARMS_EX]; // but this is not
// ... parm = nla_data(pattr);
index = parm->index; // parm is able to be smaller than 4 bytes
// and this dereference gets dirty skb_buff
// data created in netlink_sendmsg
}This commit adds TCA_PEDIT_PARMS_EX length in pedit_policy which avoid the above case, just like the TCA_PEDIT_PARMS.
--- net/sched/act_pedit.c | 1 + 1 file changed, 1 insertion(+)
net/sched/act_pedit.c +1 -0
@@ -29,6 +29,7 @@ static struct tc_action_ops act_pedit_ops;static const struct nla_policy pedit_policy[TCA_PEDIT_MAX +1 ] = { [TCA_PEDIT_PARMS ] = { .len =sizeof (struct tc_pedit ) }, + [TCA_PEDIT_PARMS_EX ] = { .len =sizeof (struct tc_pedit ) }, [TCA_PEDIT_KEYS_EX ] = { .type =NLA_NESTED }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 332/532 riscv: move memblock_allow_resize() after linear mapping is ready
In reply to Greg Kroah-HartmanFrom: Woody Zhang <[email protected]>
[ Upstream commit 85fadc0d04119c2fe4a20287767ab904c6d21ba1 ]
The initial memblock metadata is accessed from kernel image mapping. The regions arrays need to "reallocated" from memblock and accessed through linear mapping to cover more memblock regions. So the resizing should not be allowed until linear mapping is ready. Note that there are memblock allocations when building linear mapping.
This patch is similar to 24cc61d8cb5a ("arm64: memblock: don't permit memblock resizing until linear mapping is up").
In following log, many memblock regions are reserved before create_linear_mapping_page_table(). And then it triggered reallocation of memblock.reserved.regions and memcpy the old array in kernel image mapping to the new array in linear mapping which caused a page fault.
[ 0.000000] memblock_reserve: [0x00000000bf01f000-0x00000000bf01ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf021000-0x00000000bf021fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf023000-0x00000000bf023fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf025000-0x00000000bf025fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf027000-0x00000000bf027fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf029000-0x00000000bf029fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02b000-0x00000000bf02bfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02d000-0x00000000bf02dfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02f000-0x00000000bf02ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf030000-0x00000000bf030fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] OF: reserved mem: 0x0000000080000000..0x000000008007ffff (512 KiB) map non-reusable mmode_resv0@80000000 [ 0.000000] memblock_reserve: [0x00000000bf000000-0x00000000bf001fed] paging_init+0x19a/0x5ae [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] memblock: reserved is doubled to 256 at [0x000000017fffd000-0x000000017fffe7ff] [ 0.000000] Unable to handle kernel paging request at virtual address ff600000ffffd000 [ 0.000000] Oops [#1] [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.4.0-rc1-00011-g99a670b2069c #66 [ 0.000000] Hardware name: riscv-virtio,qemu (DT) [ 0.000000] epc : __memcpy+0x60/0xf8 [ 0.000000] ra : memblock_double_array+0x192/0x248 [ 0.000000] epc : ffffffff8081d214 ra : ffffffff80a3dfc0 sp : ffffffff81403bd0 [ 0.000000] gp : ffffffff814fbb38 tp : ffffffff8140dac0 t0 : 0000000001600000 [ 0.000000] t1 : 0000000000000000 t2 : 000000008f001000 s0 : ffffffff81403c60 [ 0.000000] s1 : ffffffff80c0bc98 a0 : ff600000ffffd000 a1 : ffffffff80c0bcd8 [ 0.000000] a2 : 0000000000000c00 a3 : ffffffff80c0c8d8 a4 : 0000000080000000 [ 0.000000] a5 : 0000000000080000 a6 : 0000000000000000 a7 : 0000000080200000 [ 0.000000] s2 : ff600000ffffd000 s3 : 0000000000002000 s4 : 0000000000000c00 [ 0.000000] s5 : ffffffff80c0bc60 s6 : ffffffff80c0bcc8 s7 : 0000000000000000 [ 0.000000] s8 : ffffffff814fd0a8 s9 : 000000017fffe7ff s10: 0000000000000000 [ 0.000000] s11: 0000000000001000 t3 : 0000000000001000 t4 : 0000000000000000 [ 0.000000] t5 : 000000008f003000 t6 : ff600000ffffd000 [ 0.000000] status: 0000000200000100 badaddr: ff600000ffffd000 cause: 000000000000000f [ 0.000000] [<ffffffff8081d214>] __memcpy+0x60/0xf8 [ 0.000000] [<ffffffff80a3e1a2>] memblock_add_range.isra.14+0x12c/0x162 [ 0.000000] [<ffffffff80a3e36a>] memblock_reserve+0x6e/0x8c [ 0.000000] [<ffffffff80a123fc>] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] [<ffffffff80a1256a>] memblock_phys_alloc_range+0x5e/0x6a [ 0.000000] [<ffffffff80a04732>] alloc_pmd_fixmap+0x14/0x1c [ 0.000000] [<ffffffff80a0475a>] alloc_p4d_fixmap+0xc/0x14 [ 0.000000] [<ffffffff80a04a36>] create_pgd_mapping+0x98/0x17c [ 0.000000] [<ffffffff80a04e9e>] create_linear_mapping_range.constprop.10+0xe4/0x112 [ 0.000000] [<ffffffff80a05bb8>] paging_init+0x3ec/0x5ae [ 0.000000] [<ffffffff80a03354>] setup_arch+0xb2/0x576 [ 0.000000] [<ffffffff80a00726>] start_kernel+0x72/0x57e [ 0.000000] Code: b303 0285 b383 0305 be03 0385 be83 0405 bf03 0485 (b023) 00ef [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
--- arch/riscv/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/mm/init.c +3 -1
@@ -235,7 +235,6 @@ static void __init setup_bootmem(void)dma_contiguous_reserve (dma32_phys_limit);if (IS_ENABLED (CONFIG_64BIT ))hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); -memblock_allow_resize (); }#ifdef CONFIG_MMU
@@ -868,6 +867,9 @@ void __init paging_init(void) {setup_bootmem ();setup_vm_final (); + +/* Depend on that Linear Mapping is ready */ +memblock_allow_resize (); }void __init misc_mem_init (void )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 333/532 pptp: Fix fib lookup calls.
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 84bef5b6037c15180ef88ac4216dc621d16df1a6 ]
PPTP uses pppox sockets (struct pppox_sock). These sockets don't embed an inet_sock structure, so it's invalid to call inet_sk() on them.
Therefore, the ip_route_output_ports() call in pptp_connect() has two problems:
* The tos variable is set with RT_CONN_FLAGS(sk), which calls inet_sk() on the pppox socket.
* ip_route_output_ports() tries to retrieve routing flags using inet_sk_flowi_flags(), which is also going to call inet_sk() on the pppox socket.
While PPTP doesn't use inet sockets, it's actually really layered on top of IP and therefore needs a proper way to do fib lookups. So let's define pptp_route_output() to get a struct rtable from a pptp socket. Let's also replace the ip_route_output_ports() call of pptp_xmit() for consistency.
In practice, this means that:
* pptp_connect() sets ->flowi4_tos and ->flowi4_flags to zero instead of using bits of unrelated struct pppox_sock fields.
* pptp_xmit() now respects ->sk_mark and ->sk_uid.
* pptp_xmit() now calls the security_sk_classify_flow() security
hook, thus allowing to set ->flowic_secid.
* pptp_xmit() now passes the pppox socket to xfrm_lookup_route().
Found by code inspection.
--- drivers/net/ppp/pptp.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/ppp/pptp.c +20 -11
@@ -24,6 +24,7 @@#include <linux/in.h> #include <linux/ip.h> #include <linux/rcupdate.h> +#include <linux/security.h> #include <linux/spinlock.h> #include <net/sock.h>
@@ -128,6 +129,23 @@ static void del_chan(struct pppox_sock *sock)spin_unlock (&chan_lock); } +static struct rtable *pptp_route_output (struct pppox_sock *po, +struct flowi4 *fl4) +{ +struct sock *sk = &po->sk; +struct net *net; + + net =sock_net (sk); +flowi4_init_output (fl4, sk->sk_bound_dev_if, sk->sk_mark,0 , +RT_SCOPE_UNIVERSE ,IPPROTO_GRE ,0 , + po->proto.pptp.dst_addr.sin_addr.s_addr, + po->proto.pptp.src_addr.sin_addr.s_addr, +0 ,0 ,sock_net_uid (net, sk)); +security_sk_classify_flow (sk,flowi4_to_flowi_common (fl4)); + +return ip_route_output_flow (net, fl4, sk); +} +static int pptp_xmit (struct ppp_channel *chan,struct sk_buff *skb) {struct sock *sk = (struct sock *) chan->private;
@@ -151,11 +169,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)if (sk_pppox (po)->sk_state &PPPOX_DEAD ) goto tx_error; - rt =ip_route_output_ports (net, &fl4,NULL , - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 ,IPPROTO_GRE , -RT_TOS (0 ), sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) goto tx_error;
@@ -438,12 +452,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.private = sk; po->chan.ops = &pptp_chan_ops; - rt =ip_route_output_ports (sock_net (sk), &fl4, sk, - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 , -IPPROTO_GRE ,RT_CONN_FLAGS (sk), - sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) { error = -EHOSTUNREACH ; goto end;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 334/532 net: dsa: tag_sja1105: fix MAC DA patching from meta frames
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 1dcf6efd5f0c1f4496b3ef7ec5a7db104a53b38c ]
The SJA1105 manual says that at offset 4 into the meta frame payload we have "MAC destination byte 2" and at offset 5 we have "MAC destination byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2] aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
The sja1105_meta_unpack() function decodes these the other way around, so a frame with MAC DA 01:80:c2:11:22:33 is received by the network stack as having 01:80:c2:22:11:33.
--- net/dsa/tag_sja1105.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/tag_sja1105.c +2 -2
@@ -100,8 +100,8 @@ static void sja1105_meta_unpack(const struct sk_buff *skb,* a unified unpacking command for both device series. */ packing (buf, &meta->tstamp,31 ,0 ,4 ,UNPACK ,0 ); -packing (buf +4 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 ); -packing (buf +5 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +4 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +5 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 );packing (buf +6 , &meta->source_port,7 ,0 ,1 ,UNPACK ,0 );packing (buf +7 , &meta->switch_id,7 ,0 ,1 ,UNPACK ,0 ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 335/532 octeontx-af: fix hardware timestamp configuration
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 14bb236b29922c4f57d8c05bfdbcb82677f917c9 ]
MAC block on CN10K (RPM) supports hardware timestamp configuration. The previous patch which added timestamp configuration support has a bug. Though the netdev driver requests to disable timestamp configuration, the driver is always enabling it.
This patch fixes the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -724,7 +724,7 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) cgxd =rvu_cgx_pdata (cgx_id, rvu); mac_ops =get_mac_ops (cgxd); - mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, true); + mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, enable);/* If PTP is enabled then inform NPC that packets to be * parsed by this PF will have their data shifted by 8 bytes * and if PTP is disabled then no shift is required
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 336/532 s390/qeth: Fix vipa deletion
In reply to Greg Kroah-HartmanFrom: Thorsten Winkler <[email protected]>
[ Upstream commit 80de809bd35e2a8999edf9f5aaa2d8de18921f11 ]
Change boolean parameter of function "qeth_l3_vipa_store" inside the "qeth_l3_dev_vipa_del4_store" function from "true" to "false" because "true" is used for adding a virtual ip address and "false" for deleting.
--- drivers/s390/net/qeth_l3_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_l3_sys.c +1 -1
@@ -652,7 +652,7 @@ static QETH_DEVICE_ATTR(vipa_add4, add4, 0644,static ssize_t qeth_l3_dev_vipa_del4_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -return qeth_l3_vipa_store (dev, buf, true, count,QETH_PROT_IPV4 ); +return qeth_l3_vipa_store (dev, buf, false, count,QETH_PROT_IPV4 ); } static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 337/532 sh: dma: Fix DMA channel offset calculation
In reply to Greg Kroah-HartmanFrom: Artur Rojek <[email protected]>
[ Upstream commit e82e47584847129a20b8c9f4a1dcde09374fb0e0 ]
Various SoCs of the SH3, SH4 and SH4A family, which use this driver, feature a differing number of DMA channels, which can be distributed between up to two DMAC modules. The existing implementation fails to correctly accommodate for all those variations, resulting in wrong channel offset calculations and leading to kernel panics.
Rewrite dma_base_addr() in order to properly calculate channel offsets in a DMAC module. Fix dmaor_read_reg() and dmaor_write_reg(), so that the correct DMAC module base is selected for the DMAOR register.
--- arch/sh/drivers/dma/dma-sh.c | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)
arch/sh/drivers/dma/dma-sh.c +24 -13
@@ -18,6 +18,18 @@#include <cpu/dma-register.h> #include <cpu/dma.h> +/* +* Some of the SoCs feature two DMAC modules. In such a case, the channels are +* distributed equally among them. +*/ +#ifdef SH_DMAC_BASE1 +#define SH_DMAC_NR_MD_CH (CONFIG_NR_ONCHIP_DMA_CHANNELS / 2) +#else +#define SH_DMAC_NR_MD_CH CONFIG_NR_ONCHIP_DMA_CHANNELS +#endif + +#define SH_DMAC_CH_SZ 0x10 +/* * Define the default configuration for dual address memory-memory transfer. * The 0x400 value represents auto-request, external->external.
@@ -29,7 +41,7 @@ static unsigned long dma_find_base(unsigned int chan)unsigned long base =SH_DMAC_BASE0 ;#ifdef SH_DMAC_BASE1 -if (chan >=6 ) +if (chan >=SH_DMAC_NR_MD_CH ) base =SH_DMAC_BASE1 ;#endif
@@ -40,13 +52,13 @@ static unsigned long dma_base_addr(unsigned int chan) {unsigned long base =dma_find_base (chan); -/* Normalize offset calculation */ -if (chan >=9 ) - chan -=6 ; -if (chan >=4 ) - base +=0x10 ; + chan = (chan %SH_DMAC_NR_MD_CH ) *SH_DMAC_CH_SZ ; + +/* DMAOR is placed inside the channel register space. Step over it. */ +if (chan >=DMAOR ) + base +=SH_DMAC_CH_SZ ; -return base + (chan *0x10 ); +return base + chan; }#ifdef CONFIG_SH_DMA_IRQ_MULTI
@@ -250,12 +262,11 @@ static int sh_dmac_get_dma_residue(struct dma_channel *chan)#define NR_DMAOR 1#endif -/* -* DMAOR bases are broken out amongst channel groups. DMAOR0 manages -* channels 0 - 5, DMAOR1 6 - 11 (optional). -*/ -#define dmaor_read_reg (n) __raw_readw(dma_find_base((n)*6)) -#define dmaor_write_reg (n, data) __raw_writew(data, dma_find_base(n)*6) +#define dmaor_read_reg (n) __raw_readw(dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR) +#define dmaor_write_reg (n, data) __raw_writew(data, \ + dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR)static inline int dmaor_reset (int no) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 338/532 apparmor: fix missing error check for rhashtable_insert_fast
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 000518bc5aef25d3f703592a0296d578c98b1517 ]
rhashtable_insert_fast() could return err value when memory allocation is failed. but unpack_profile() do not check values and this always returns success value. This patch just adds error check code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- security/apparmor/policy_unpack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
security/apparmor/policy_unpack.c +7 -2
@@ -909,8 +909,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) goto fail; } -rhashtable_insert_fast (profile->data, &data->head, - profile->data->p); +if (rhashtable_insert_fast (profile->data, &data->head, + profile->data->p)) { +kfree_sensitive (data->key); +kfree_sensitive (data); + info ="failed to insert data to table" ; + goto fail; + } }if (!unpack_nameX (e,AA_STRUCTEND ,NULL )) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 339/532 i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 743e227a895923c37a333eb2ebf3e391f00c406d ]
The __xiic_start_xfer() manipulates the interrupt flags, xiic_wakeup() may result in return from xiic_xfer() early. Defer both to the end of the xiic_process() interrupt thread, so that they are executed after all the other interrupt bits handling completed and once it completely safe to perform changes to the interrupt bits in the hardware.
Stable-dep-of: cb6e45c9a0ad ("i2c: xiic: Don't try to handle more interrupt events after error")
--- drivers/i2c/busses/i2c-xiic.c | 37 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-xiic.c +26 -11
@@ -375,6 +375,9 @@ static irqreturn_t xiic_process(int irq, void *dev_id)struct xiic_i2c *i2c = dev_id;u32 pend, isr, ier;u32 clr =0 ; +int xfer_more =0 ; +int wakeup_req =0 ; +int wakeup_code =0 ;/* Get the interrupt Status from the IPIF. There is no clearing of * interrupts in the IPIF. Interrupts must be cleared at the source.
@@ -411,10 +414,14 @@ static irqreturn_t xiic_process(int irq, void *dev_id)*/ xiic_reinit (i2c); -if (i2c->rx_msg) -xiic_wakeup (i2c,STATE_ERROR ); -if (i2c->tx_msg) -xiic_wakeup (i2c,STATE_ERROR ); +if (i2c->rx_msg) { + wakeup_req =1 ; + wakeup_code =STATE_ERROR ; + } +if (i2c->tx_msg) { + wakeup_req =1 ; + wakeup_code =STATE_ERROR ; + } }if (pend &XIIC_INTR_RX_FULL_MASK ) {/* Receive register/FIFO is full */
@@ -448,8 +455,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id) i2c->tx_msg++;dev_dbg (i2c->adap.dev.parent,"%s will start next...\n" , __func__); - -__xiic_start_xfer (i2c); + xfer_more =1 ; } } }
@@ -463,11 +469,13 @@ static irqreturn_t xiic_process(int irq, void *dev_id)if (!i2c->tx_msg) goto out; -if ((i2c->nmsgs ==1 ) && !i2c->rx_msg && -xiic_tx_space (i2c) ==0 ) -xiic_wakeup (i2c,STATE_DONE ); + wakeup_req =1 ; + +if (i2c->nmsgs ==1 && !i2c->rx_msg && +xiic_tx_space (i2c) ==0 ) + wakeup_code =STATE_DONE ;else -xiic_wakeup (i2c,STATE_ERROR ); + wakeup_code =STATE_ERROR ; }if (pend & (XIIC_INTR_TX_EMPTY_MASK |XIIC_INTR_TX_HALF_MASK )) {/* Transmit register/FIFO is empty or ½ empty */
@@ -491,7 +499,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)if (i2c->nmsgs >1 ) { i2c->nmsgs--; i2c->tx_msg++; -__xiic_start_xfer (i2c); + xfer_more =1 ; }else {xiic_irq_dis (i2c,XIIC_INTR_TX_HALF_MASK );
@@ -509,6 +517,13 @@ static irqreturn_t xiic_process(int irq, void *dev_id)dev_dbg (i2c->adap.dev.parent,"%s clr: 0x%x\n" , __func__, clr);xiic_setreg32 (i2c,XIIC_IISR_OFFSET , clr); +if (xfer_more) +__xiic_start_xfer (i2c); +if (wakeup_req) +xiic_wakeup (i2c, wakeup_code); + +WARN_ON (xfer_more && wakeup_req); +mutex_unlock (&i2c->lock);return IRQ_HANDLED ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 340/532 i2c: xiic: Dont try to handle more interrupt events after error
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
[ Upstream commit cb6e45c9a0ad9e0f8664fd06db0227d185dc76ab ]
In xiic_process, it is possible that error events such as arbitration lost or TX error can be raised in conjunction with other interrupt flags such as TX FIFO empty or bus not busy. Error events result in the controller being reset and the error returned to the calling request, but the function could potentially try to keep handling the other events, such as by writing more messages into the TX FIFO. Since the transaction has already failed, this is not helpful and will just cause issues.
This problem has been present ever since:
commit 7f9906bd7f72 ("i2c: xiic: Service all interrupts in isr")
which allowed non-error events to be handled after errors, but became more obvious after:
commit 743e227a8959 ("i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()")
which reworked the code to add a WARN_ON which triggers if both the xfer_more and wakeup_req flags were set, since this combination is not supposed to happen, but was occurring in this scenario.
Skip further interrupt handling after error flags are detected to avoid this problem.
--- drivers/i2c/busses/i2c-xiic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-xiic.c +2 -0
@@ -422,6 +422,8 @@ static irqreturn_t xiic_process(int irq, void *dev_id) wakeup_req =1 ; wakeup_code =STATE_ERROR ; } +/* don't try to handle other events */ + goto out; }if (pend &XIIC_INTR_RX_FULL_MASK ) {/* Receive register/FIFO is full */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 341/532 extcon: usbc-tusb320: Convert to i2cs .probe_new()
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 5313121b22fd11db0d14f305c110168b8176efdc ]
The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
Stable-dep-of: 3adbaa30d973 ("extcon: usbc-tusb320: Unregister typec port on driver removal")
--- drivers/extcon/extcon-usbc-tusb320.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +2 -3
@@ -428,8 +428,7 @@ static int tusb320_typec_probe(struct i2c_client *client,return 0 ; } -static int tusb320_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int tusb320_probe (struct i2c_client *client) {struct tusb320_priv *priv;const void *match_data;
@@ -502,7 +501,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { - .probe = tusb320_probe, + .probe_new = tusb320_probe, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 342/532 btrfs: do not BUG_ON() on tree mod log failure at balance_level()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit 39020d8abc7ec62c4de9b260e3d10d4a1c2478ce ]
At balance_level(), instead of doing a BUG_ON() in case we fail to record tree mod log operations, do a transaction abort and return the error to the callers. There's really no need for the BUG_ON() as we can release all resources in this context, and we have to abort because other future tree searches that use the tree mod log (btrfs_search_old_slot()) may get inconsistent results if other operations modify the tree after that failure and before the tree mod log based search.
--- fs/btrfs/ctree.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/btrfs/ctree.c +14 -3
@@ -912,7 +912,12 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, } ret =btrfs_tree_mod_log_insert_root (root->node, child, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (child); +free_extent_buffer (child); +btrfs_abort_transaction (trans, ret); + goto enospc; + }rcu_assign_pointer (root->node, child);add_root_to_dirty_list (root);
@@ -994,7 +999,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,btrfs_node_key (right, &right_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot +1 ,BTRFS_MOD_LOG_KEY_REPLACE ,GFP_NOFS ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &right_key, pslot +1 );btrfs_mark_buffer_dirty (parent); }
@@ -1040,7 +1048,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,btrfs_node_key (mid, &mid_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot,BTRFS_MOD_LOG_KEY_REPLACE ,GFP_NOFS ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &mid_key, pslot);btrfs_mark_buffer_dirty (parent); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 343/532 i2c: qup: Add missing unwind goto in qup_i2c_probe()
In reply to Greg Kroah-HartmanFrom: Shuai Jiang <[email protected]>
commit cd9489623c29aa2f8cc07088168afb6e0d5ef06d upstream.
Smatch Warns:
drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe() warn: missing unwind goto?
The goto label "fail_runtime" and "fail" will disable qup->pclk, but here qup->pclk failed to obtain, in order to be consistent, change the direct return to goto label "fail_dma".
--- drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-qup.c +14 -7
@@ -1752,16 +1752,21 @@ nodma:if (!clk_freq || clk_freq >I2C_MAX_FAST_MODE_PLUS_FREQ ) {dev_err (qup->dev,"clock frequency not supported %d\n" , clk_freq); -return -EINVAL ; + ret = -EINVAL ; + goto fail_dma; } qup->base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (qup->base)) -return PTR_ERR (qup->base); +if (IS_ERR (qup->base)) { + ret =PTR_ERR (qup->base); + goto fail_dma; + } qup->irq =platform_get_irq (pdev,0 ); -if (qup->irq <0 ) -return qup->irq; +if (qup->irq <0 ) { + ret = qup->irq; + goto fail_dma; + }if (has_acpi_companion (qup->dev)) { ret = device_property_read_u32(qup->dev,
@@ -1775,13 +1780,15 @@ nodma: qup->clk =devm_clk_get (qup->dev,"core" );if (IS_ERR (qup->clk)) {dev_err (qup->dev,"Could not get core clock\n" ); -return PTR_ERR (qup->clk); + ret =PTR_ERR (qup->clk); + goto fail_dma; } qup->pclk =devm_clk_get (qup->dev,"iface" );if (IS_ERR (qup->pclk)) {dev_err (qup->dev,"Could not get iface clock\n" ); -return PTR_ERR (qup->pclk); + ret =PTR_ERR (qup->pclk); + goto fail_dma; }qup_i2c_enable_clocks (qup); src_clk_freq =clk_get_rate (qup->clk);
Greg Kroah-Hartman
maintainerPATCH 344/532 NFSD: add encoding of op_recall flag for write delegation
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
commit 58f5d894006d82ed7335e1c37182fbc5f08c2f51 upstream.
Modified nfsd4_encode_open to encode the op_recall flag properly for OPEN result with write delegation granted.
--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -3816,7 +3816,7 @@ nfsd4_encode_open(struct nfsd4_compoundr p =xdr_reserve_space (xdr,32 );if (!p)return nfserr_resource; - *p++ =cpu_to_be32 (0 ); + *p++ =cpu_to_be32 (open->op_recall);/* * TODO: space_limit's in delegations
Greg Kroah-Hartman
maintainerPATCH 345/532 io_uring: wait interruptibly for request completions on exit
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 4826c59453b3b4677d6bf72814e7ababdea86949 upstream.
WHen the ring exits, cleanup is done and the final cancelation and waiting on completions is done by io_ring_exit_work. That function is invoked by kworker, which doesn't take any signals. Because of that, it doesn't really matter if we wait for completions in TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE state. However, it does matter to the hung task detection checker!
Normally we expect cancelations and completions to happen rather quickly. Some test cases, however, will exit the ring and park the owning task stopped (eg via SIGSTOP). If the owning task needs to run task_work to complete requests, then io_ring_exit_work won't make any progress until the task is runnable again. Hence io_ring_exit_work can trigger the hung task detection, which is particularly problematic if panic-on-hung-task is enabled.
As the ring exit doesn't take signals to begin with, have it wait interruptibly rather than uninterruptibly. io_uring has a separate stuck-exit warning that triggers independently anyway, so we're not really missing anything by making this switch.
--- io_uring/io_uring.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
io_uring/io_uring.c +18 -2
@@ -9714,7 +9714,18 @@ static void io_ring_exit_work(struct wor/* there is little hope left, don't run it too often */ interval =HZ *60 ; } - }while (!wait_for_completion_timeout (&ctx->ref_comp, interval)); +/* +* This is really an uninterruptible wait, as it has to be +* complete. But it's also run from a kworker, which doesn't +* take signals, so it's fine to make it interruptible. This +* avoids scenarios where we knowingly can wait much longer +* on completions, for example if someone does a SIGSTOP on +* a task that needs to finish task_work to make this loop +* complete. That's a synthetic situation that should not +* cause a stuck task backtrace, and hence a potential panic +* on stuck tasks if that is enabled. +*/ + }while (!wait_for_completion_interruptible_timeout (&ctx->ref_comp, interval));init_completion (&exit.completion);init_task_work (&exit.task_work, io_tctx_exit_cb);
@@ -9739,7 +9750,12 @@ static void io_ring_exit_work(struct worwake_up_process (node->task);mutex_unlock (&ctx->uring_lock); -wait_for_completion (&exit.completion); +/* +* See comment above for +* wait_for_completion_interruptible_timeout() on why this +* wait is marked as interruptible. +*/ +wait_for_completion_interruptible (&exit.completion);mutex_lock (&ctx->uring_lock); }mutex_unlock (&ctx->uring_lock);
Greg Kroah-Hartman
maintainerPATCH 346/532 mmc: core: disable TRIM on Kingston EMMC04G-M627
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit f1738a1f816233e6dfc2407f24a31d596643fd90 upstream.
It seems that Kingston EMMC04G-M627 despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing I/O errors in OpenWrt under 6.1 on Zyxel NBG7815 that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES.
Trying to use fstrim seems to also throw errors like:
[93010.835112] I/O error, dev loop0, sector 16902 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -100,6 +100,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Kingston EMMC04G-M627 advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("M62704" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 347/532 mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit dbfbddcddcebc9ce8a08757708d4e4a99d238e44 upstream.
It seems that Micron MTFC4GACAJCN-1M despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing the following errors in OpenWrt under 6.1 on Qnap Qhora 301W that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES:
[ 18.085950] I/O error, dev loop0, sector 596 op 0x9:(WRITE_ZEROES) flags 0x800 phys_seg 0 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -107,6 +107,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Micron MTFC4GACAJCN-1M advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("Q2J54A" ,CID_MANFID_MICRON ,0x014e , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 348/532 mmc: mmci: Set PROBE_PREFER_ASYNCHRONOUS
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 3108eb2e8aa7e955a9dd3a4c1bf19a7898961822 upstream.
All mmc host drivers should have the asynchronous probe option enabled, but it seems like we failed to set it for mmci, so let's do that now.
--- drivers/mmc/host/mmci.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/mmci.c +1 -0
@@ -2449,6 +2449,7 @@ static struct amba_driver mmci_driver = .drv = { .name = DRIVER_NAME, .pm = &mmci_dev_pm_ops, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, .probe = mmci_probe, .remove = mmci_remove,
Greg Kroah-Hartman
maintainerPATCH 349/532 mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used.
In reply to Greg Kroah-HartmanFrom: Chevron Li <[email protected]>
commit 20dbd07ef0a8bc29eb03d6a95258ac8934cbe52d upstream.
Bayhub SD host has hardware limitation:
1.The upper 32bit address is inhibited to be written at SD Host Register
[03E][13]=0 (32bits addressing) mode, is admitted to be written only at SD Host Register [03E][13]=1 (64bits addressing) mode.
2.Because of above item#1, need to configure SD Host Register [03E][13] to
1(64bits addressing mode) before set 64bit ADMA system address's higher 32bits SD Host Register [05F~05C] if 64 bits addressing mode is used.
The hardware limitation is reasonable for below reasons:
1.Normal flow should set DMA working mode first, then do
DMA-transfer-related configuration, such as system address.
2.The hardware limitation may avoid the software to configure wrong higher
32bit address at 32bits addressing mode although it is redundant.
The change that set 32bits/64bits addressing mode before set ADMA address,
has no side-effect to other host IPs for below reason:
The setting order is reasonable and standard: DMA Mode setting first and
then DMA address setting. It meets all DMA setting sequence.
--- drivers/mmc/host/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
@@ -1144,6 +1144,8 @@ static void sdhci_prepare_data(struct sd } } +sdhci_config_dma (host); +if (host->flags &SDHCI_REQ_USE_DMA ) {int sg_cnt =sdhci_pre_dma_transfer (host, data,COOKIE_MAPPED );
@@ -1163,8 +1165,6 @@ static void sdhci_prepare_data(struct sd } } -sdhci_config_dma (host); -if (!(host->flags &SDHCI_REQ_USE_DMA )) {int flags;
Greg Kroah-Hartman
maintainerPATCH 350/532 bcache: fixup btree_cache_wait list damage
In reply to Greg Kroah-HartmanFrom: Mingzhe Zou <[email protected]>
commit f0854489fc07d2456f7cc71a63f4faf9c716ffbe upstream.
We get a kernel crash about "list_add corruption. next->prev should be prev (ffff9c801bc01210), but was ffff9c77b688237c. (next=ffffae586d8afe68)."
crash> struct list_head 0xffff9c801bc01210
struct list_head {
next = 0xffffae586d8afe68,
prev = 0xffffae586d8afe68
}
crash> struct list_head 0xffff9c77b688237c
struct list_head {
next = 0x0,
prev = 0x0
}
crash> struct list_head 0xffffae586d8afe68
struct list_head struct: invalid kernel virtual address: ffffae586d8afe68 type: "gdb_readmem_callback" Cannot access memory at address 0xffffae586d8afe68
[230469.019492] Call Trace: [230469.032041] prepare_to_wait+0x8a/0xb0 [230469.044363] ? bch_btree_keys_free+0x6c/0xc0 [escache] [230469.056533] mca_cannibalize_lock+0x72/0x90 [escache] [230469.068788] mca_alloc+0x2ae/0x450 [escache] [230469.080790] bch_btree_node_get+0x136/0x2d0 [escache] [230469.092681] bch_btree_check_thread+0x1e1/0x260 [escache] [230469.104382] ? finish_wait+0x80/0x80 [230469.115884] ? bch_btree_check_recurse+0x1a0/0x1a0 [escache] [230469.127259] kthread+0x112/0x130 [230469.138448] ? kthread_flush_work_fn+0x10/0x10 [230469.149477] ret_from_fork+0x35/0x40
bch_btree_check_thread() and bch_dirty_init_thread() may call mca_cannibalize() to cannibalize other cached btree nodes. Only one thread can do it at a time, so the op of other threads will be added to the btree_cache_wait list.
We must call finish_wait() to remove op from btree_cache_wait before free it's memory address. Otherwise, the list will be damaged. Also should call bch_cannibalize_unlock() to release the btree_cache_alloc_lock and wake_up other waiters.
--- drivers/md/bcache/btree.c | 11 ++++++++++- drivers/md/bcache/btree.h | 1 + drivers/md/bcache/writeback.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +10 -1
@@ -885,7 +885,7 @@ static struct btree *mca_cannibalize(str* cannibalize_bucket() will take. This means every time we unlock the root of * the btree, we need to release this lock if we have it held. */ -static void bch_cannibalize_unlock (struct cache_set *c) +void bch_cannibalize_unlock (struct cache_set *c) {spin_lock (&c->btree_cannibalize_lock);if (c->btree_cache_alloc_lock == current) {
@@ -1968,6 +1968,15 @@ static int bch_btree_check_thread(void * c->gc_stats.nodes++;bch_btree_op_init (&op,0 ); ret =bcache_btree (check_recurse, p, c->root, &op); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op)->wait);if (ret) goto out; }
drivers/md/bcache/btree.h +1 -0
@@ -282,6 +282,7 @@ void bch_initial_gc_finish(struct cache_void bch_moving_gc (struct cache_set *c);int bch_btree_check (struct cache_set *c);void bch_initial_mark_key (struct cache_set *c,int level,struct bkey *k); +void bch_cannibalize_unlock (struct cache_set *c);static inline void wake_up_gc (struct cache_set *c) {
drivers/md/bcache/writeback.c +10 -0
@@ -880,6 +880,16 @@ static int bch_root_node_dirty_init(struif (ret <0 )pr_warn ("sectors dirty init failed, ret=%d!\n" , ret); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op.op)->wait); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 351/532 bcache: Remove unnecessary NULL point check in node allocations
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 028ddcac477b691dd9205c92f991cc15259d033e upstream.
Due to the previous fix of __bch_btree_node_alloc, the return value will never be a NULL pointer. So IS_ERR is enough to handle the failure situation. Fix it by replacing IS_ERR_OR_NULL check by an IS_ERR check.
--- drivers/md/bcache/btree.c | 10 +++++----- drivers/md/bcache/super.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/md/bcache/btree.c +5 -5
@@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_re {struct btree *n =bch_btree_node_alloc (b->c, op, b->level, b->parent); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {mutex_lock (&n->write_lock);bch_btree_sort_into (&b->keys, &n->keys, &b->c->sort);bkey_copy_key (&n->key, &b->key);
@@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(struct btrememset (new_nodes,0 ,sizeof (new_nodes));closure_init_stack (&cl); -while (nodes <GC_MERGE_NODES && !IS_ERR_OR_NULL (r[nodes].b)) +while (nodes <GC_MERGE_NODES && !IS_ERR (r[nodes].b)) keys += r[nodes++].keys; blocks =btree_default_blocks (b->c) *2 /3 ;
@@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btrefor (i =0 ; i < nodes; i++) { new_nodes[i] =btree_node_alloc_replacement (r[i].b,NULL ); -if (IS_ERR_OR_NULL (new_nodes[i])) +if (IS_ERR (new_nodes[i])) goto out_nocoalesce; }
@@ -1487,7 +1487,7 @@ out_nocoalesce:bch_keylist_free (&keylist);for (i =0 ; i < nodes; i++) -if (!IS_ERR_OR_NULL (new_nodes[i])) { +if (!IS_ERR (new_nodes[i])) {btree_node_free (new_nodes[i]);rw_unlock (true, new_nodes[i]); }
@@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btreif (should_rewrite) { n =btree_node_alloc_replacement (b,NULL ); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {bch_btree_node_write_sync (n);bch_btree_set_root (n);
drivers/md/bcache/super.c +2 -2
@@ -1729,7 +1729,7 @@ static void cache_set_flush(struct closuif (!IS_ERR_OR_NULL (c->gc_thread))kthread_stop (c->gc_thread); -if (!IS_ERR_OR_NULL (c->root)) +if (!IS_ERR (c->root))list_add (&c->root->list, &c->btree_cache);/*
@@ -2093,7 +2093,7 @@ static int run_cache_set(struct cache_se err ="cannot allocate new btree root" ; c->root =__bch_btree_node_alloc (c,NULL ,0 , true,NULL ); -if (IS_ERR_OR_NULL (c->root)) +if (IS_ERR (c->root)) goto err;mutex_lock (&c->root->write_lock);
Greg Kroah-Hartman
maintainerPATCH 352/532 bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 upstream.
In some specific situations, the return value of __bch_btree_node_alloc may be NULL. This may lead to a potential NULL pointer dereference in caller function like a calling chain :btree_split->bch_btree_node_alloc->__bch_btree_node_alloc.
Fix it by initializing the return value in __bch_btree_node_alloc.
--- drivers/md/bcache/btree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +3 -1
@@ -1090,10 +1090,12 @@ struct btree *__bch_btree_node_alloc(str struct btree *parent) {BKEY_PADDED (key) k; -struct btree *b =ERR_PTR (-EAGAIN ); +struct btree *b;mutex_lock (&c->bucket_lock); retry: +/* return ERR_PTR(-EAGAIN) when it fails */ + b =ERR_PTR (-EAGAIN );if (__bch_bucket_alloc_set (c,RESERVE_BTREE , &k.key, wait)) goto err;
Greg Kroah-Hartman
maintainerPATCH 353/532 um: Use HOST_DIR for mrproper
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit a5a319ec2c2236bb96d147c16196d2f1f3799301 upstream.
When HEADER_ARCH was introduced, the MRPROPER_FILES (then MRPROPER_DIRS) list wasn't adjusted, leaving SUBARCH as part of the path argument. This resulted in the "mrproper" target not cleaning up arch/x86/... when SUBARCH was specified. Since HOST_DIR is arch/$(HEADER_ARCH), use it instead to get the correct path.
--- arch/um/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/Makefile +1 -1
@@ -148,7 +148,7 @@ export LDFLAGS_vmlinux := $(LDFLAGS_EXEC # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. CLEAN_FILES += linux x.i gmon.out -MRPROPER_FILES += arch/$(SUBARCH)/include/generated +MRPROPER_FILES += $(HOST_DIR)/include/generated archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
Greg Kroah-Hartman
maintainerPATCH 354/532 integrity: Fix possible multiple allocation in integrity_inode_get()
In reply to Greg Kroah-HartmanFrom: Tianjia Zhang <[email protected]>
commit 9df6a4870dc371136e90330cfbbc51464ee66993 upstream.
When integrity_inode_get() is querying and inserting the cache, there is a conditional race in the concurrent environment.
The race condition is the result of not properly implementing "double-checked locking". In this case, it first checks to see if the iint cache record exists before taking the lock, but doesn't check again after taking the integrity_iint_lock.
--- security/integrity/iint.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
security/integrity/iint.c +9 -6
@@ -43,12 +43,10 @@ static struct integrity_iint_cache *__inelse if (inode > iint->inode) n = n->rb_right;else -break ; +return iint; } -if (!n) -return NULL ; -return iint; +return NULL ; }/*
@@ -121,10 +119,15 @@ struct integrity_iint_cache *integrity_i parent = *p; test_iint = rb_entry(parent, struct integrity_iint_cache, rb_node); -if (inode < test_iint->inode) +if (inode < test_iint->inode) { p = &(*p)->rb_left; -else + }else if (inode > test_iint->inode) { p = &(*p)->rb_right; + }else { +write_unlock (&integrity_iint_lock); +kmem_cache_free (iint_cache, iint); +return test_iint; + } } iint->inode = inode;
Greg Kroah-Hartman
maintainerPATCH 355/532 autofs: use flexible array in ioctl structure
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit e910c8e3aa02dc456e2f4c32cb479523c326b534 upstream.
Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") introduced a warning for the autofs_dev_ioctl structure:
In function 'check_name',
inlined from 'validate_dev_ioctl' at fs/autofs/dev-ioctl.c:131:9,
inlined from '_autofs_dev_ioctl' at fs/autofs/dev-ioctl.c:624:8:fs/autofs/dev-ioctl.c:33:14: error: 'strchr' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
33 | if (!strchr(name, '/'))
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/auto_dev-ioctl.h:10,
from fs/autofs/autofs_i.h:10,
from fs/autofs/dev-ioctl.c:14:
include/uapi/linux/auto_dev-ioctl.h: In function '_autofs_dev_ioctl':
include/uapi/linux/auto_dev-ioctl.h:112:14: note: source object 'path' of size 0
112 | char path[0];
| ^~~~This is easily fixed by changing the gnu 0-length array into a c99 flexible array. Since this is a uapi structure, we have to be careful about possible regressions but this one should be fine as they are equivalent here. While it would break building with ancient gcc versions that predate c99, it helps building with --std=c99 and -Wpedantic builds in user space, as well as non-gnu compilers. This means we probably also want it fixed in stable kernels.
--- Documentation/filesystems/autofs-mount-control.rst | 2 +- Documentation/filesystems/autofs.rst | 2 +- include/uapi/linux/auto_dev-ioctl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Documentation/filesystems/autofs-mount-control.rst +1 -1
@@ -196,7 +196,7 @@ information and return operation results struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; The ioctlfd field is a mount point file descriptor of an autofs mount
Documentation/filesystems/autofs.rst +1 -1
@@ -467,7 +467,7 @@ Each ioctl is passed a pointer to an `au struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; For the **OPEN_MOUNT** and **IS_MOUNTPOINT** commands, the target
include/uapi/linux/auto_dev-ioctl.h +1 -1
@@ -109,7 +109,7 @@ struct autofs_dev_ioctl {struct args_ismountpoint ismountpoint; }; -char path[0 ]; +char path[]; };static inline void init_autofs_dev_ioctl (struct autofs_dev_ioctl *in)
Greg Kroah-Hartman
maintainerPATCH 356/532 shmem: use ramfs_kill_sb() for kill_sb method of ramfs-based tmpfs
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit 36ce9d76b0a93bae799e27e4f5ac35478c676592 upstream.
As the ramfs-based tmpfs uses ramfs_init_fs_context() for the init_fs_context method, which allocates fc->s_fs_info, use ramfs_kill_sb() to free it and avoid a memory leak.
--- fs/ramfs/inode.c | 2 +- include/linux/ramfs.h | 1 + mm/shmem.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
fs/ramfs/inode.c +1 -1
@@ -274,7 +274,7 @@ int ramfs_init_fs_context(struct fs_contreturn 0 ; } -static void ramfs_kill_sb (struct super_block *sb) +void ramfs_kill_sb (struct super_block *sb) {kfree (sb->s_fs_info);kill_litter_super (sb);
include/linux/ramfs.h +1 -0
@@ -7,6 +7,7 @@struct inode *ramfs_get_inode (struct super_block *sb,const struct inode *dir,umode_t mode,dev_t dev);extern int ramfs_init_fs_context (struct fs_context *fc); +extern void ramfs_kill_sb (struct super_block *sb);#ifdef CONFIG_MMU static inline int
mm/shmem.c +1 -1
@@ -4043,7 +4043,7 @@ static struct file_system_type shmem_fs_ .name = "tmpfs", .init_fs_context = ramfs_init_fs_context, .parameters = ramfs_fs_parameters, - .kill_sb = kill_litter_super, + .kill_sb = ramfs_kill_sb, .fs_flags = FS_USERNS_MOUNT, };
Greg Kroah-Hartman
maintainerPATCH 357/532 ext4: Remove ext4 locking of moved directory
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 3658840cd363f2be094f5dfd2f0b174a9055dd0f upstream.
Remove locking of moved directory in ext4_rename2(). We will take care of it in VFS instead. This effectively reverts commit 0813299c586b ("ext4: Fix possible corruption when moving a directory") and followup fixes.
Message-Id: <[email protected]>
--- fs/ext4/namei.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
fs/ext4/namei.c +2 -15
@@ -3848,19 +3848,10 @@ static int ext4_rename(struct user_namesreturn retval; } -/* -* We need to protect against old.inode directory getting converted -* from inline directory format into a normal one. -*/ -if (S_ISDIR (old.inode->i_mode)) -inode_lock_nested (old.inode,I_MUTEX_NONDIR2 ); - old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de, &old.inlined); -if (IS_ERR (old.bh)) { - retval =PTR_ERR (old.bh); - goto unlock_moved_dir; - } +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors.
@@ -4050,10 +4041,6 @@ release_bh:brelse (old.bh);brelse (new.bh); -unlock_moved_dir: -if (S_ISDIR (old.inode->i_mode)) -inode_unlock (old.inode); -return retval; }
Greg Kroah-Hartman
maintainerPATCH 358/532 Revert "f2fs: fix potential corruption when moving a directory"
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit cde3c9d7e2a359e337216855dcb333a19daaa436 upstream.
This reverts commit d94772154e524b329a168678836745d2773a6e02. The locking is going to be provided by VFS.
Message-Id: <[email protected]>
--- fs/f2fs/namei.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
fs/f2fs/namei.c +1 -15
@@ -991,20 +991,12 @@ static int f2fs_rename(struct inode *old goto out; } -/* -* Copied from ext4_rename: we need to protect against old.inode -* directory getting converted from inline directory format into -* a normal one. -*/ -if (S_ISDIR (old_inode->i_mode)) -inode_lock_nested (old_inode,I_MUTEX_NONDIR2 ); - err = -ENOENT ; old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);if (!old_entry) {if (IS_ERR (old_page)) err =PTR_ERR (old_page); - goto out_unlock_old; + goto out; }if (S_ISDIR (old_inode->i_mode)) {
@@ -1112,9 +1104,6 @@ static int f2fs_rename(struct inode *oldf2fs_unlock_op (sbi); -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); -if (IS_DIRSYNC (old_dir) ||IS_DIRSYNC (new_dir))f2fs_sync_fs (sbi->sb,1 );
@@ -1129,9 +1118,6 @@ out_dir:f2fs_put_page (old_dir_page,0 ); out_old:f2fs_put_page (old_page,0 ); -out_unlock_old: -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); out:if (whiteout)iput (whiteout);
Greg Kroah-Hartman
maintainerPATCH 359/532 fs: Establish locking order for unrelated directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit f23ce757185319886ca80c4864ce5f81ac6cc9e9 upstream.
Currently the locking order of inode locks for directories that are not in ancestor relationship is not defined because all operations that needed to lock two directories like this were serialized by sb->s_vfs_rename_mutex. However some filesystems need to lock two subdirectories for RENAME_EXCHANGE operations and for this we need the locking order established even for two tree-unrelated directories. Provide a helper function lock_two_inodes() that establishes lock ordering for any two inodes and use it in lock_two_directories().
Message-Id: <[email protected]>
--- fs/inode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/internal.h | 2 ++ fs/namei.c | 4 ++-- 3 files changed, 46 insertions(+), 2 deletions(-)
fs/inode.c +42 -0
@@ -1024,6 +1024,48 @@ void discard_new_inode(struct inode *inoEXPORT_SYMBOL (discard_new_inode);/** +* lock_two_inodes - lock two inodes (may be regular files but also dirs) +* +* Lock any non-NULL argument. The caller must make sure that if he is passing +* in two directories, one is not ancestor of the other. Zero, one or two +* objects may be locked by this function. +* +* @inode1: first inode to lock +* @inode2: second inode to lock +* @subclass1: inode lock subclass for the first lock obtained +* @subclass2: inode lock subclass for the second lock obtained +*/ +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2) +{ +if (!inode1 || !inode2) { +/* +* Make sure @subclass1 will be used for the acquired lock. +* This is not strictly necessary (no current caller cares) but +* let's keep things consistent. +*/ +if (!inode1) +swap (inode1, inode2); + goto lock; + } + +/* +* If one object is directory and the other is not, we must make sure +* to lock directory first as the other object may be its child. +*/ +if (S_ISDIR (inode2->i_mode) ==S_ISDIR (inode1->i_mode)) { +if (inode1 > inode2) +swap (inode1, inode2); + }else if (!S_ISDIR (inode1->i_mode)) +swap (inode1, inode2); +lock: +if (inode1) +inode_lock_nested (inode1, subclass1); +if (inode2 && inode2 != inode1) +inode_lock_nested (inode2, subclass2); +} + +/** * lock_two_nondirectories - take two i_mutexes on non-directory objects * * Lock any non-NULL argument that is not a directory.
fs/internal.h +2 -0
@@ -152,6 +152,8 @@ extern void inode_add_lru(struct inode *int dentry_needs_remove_privs (struct user_namespace *,struct dentry *dentry);bool in_group_or_capable (struct user_namespace *mnt_userns,const struct inode *inode,kgid_t gid); +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2);/* * fs-writeback.c
fs/namei.c +2 -2
@@ -2984,8 +2984,8 @@ struct dentry *lock_rename(struct dentryreturn p; } -inode_lock_nested (p1->d_inode,I_MUTEX_PARENT ); -inode_lock_nested (p2->d_inode,I_MUTEX_PARENT2 ); +lock_two_inodes (p1->d_inode, p2->d_inode, +I_MUTEX_PARENT ,I_MUTEX_PARENT2 );return NULL ; }EXPORT_SYMBOL (lock_rename);
Greg Kroah-Hartman
maintainerPATCH 360/532 fs: Lock moved directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 28eceeda130f5058074dd007d9c59d2e8bc5af2e upstream.
When a directory is moved to a different directory, some filesystems (udf, ext4, ocfs2, f2fs, and likely gfs2, reiserfs, and others) need to update their pointer to the parent and this must not race with other operations on the directory. Lock the directories when they are moved. Although not all filesystems need this locking, we perform it in vfs_rename() because getting the lock ordering right is really difficult and we don't want to expose these locking details to filesystems.
Message-Id: <[email protected]>
--- Documentation/filesystems/directory-locking.rst | 26 ++++++++++++------------ fs/namei.c | 22 ++++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-)
Documentation/filesystems/directory-locking.rst +14 -12
@@ -22,12 +22,11 @@ exclusive. 3) object removal. Locking rules: caller locks parent, finds victim, locks victim and calls the method. Locks are exclusive. -4) rename() that is _not_ cross-directory. Locking rules: caller locks -the parent and finds source and target. In case of exchange (with -RENAME_EXCHANGE in flags argument) lock both. In any case, -if the target already exists, lock it. If the source is a non-directory, -lock it. If we need to lock both, lock them in inode pointer order. -Then call the method. All locks are exclusive. +4) rename() that is _not_ cross-directory. Locking rules: caller locks the +parent and finds source and target. We lock both (provided they exist). If we +need to lock two inodes of different type (dir vs non-dir), we lock directory +first. If we need to lock two inodes of the same type, lock them in inode +pointer order. Then call the method. All locks are exclusive. NB: we might get away with locking the source (and target in exchange case) shared.
@@ -44,15 +43,17 @@ All locks are exclusive. rules: * lock the filesystem - * lock parents in "ancestors first" order. + * lock parents in "ancestors first" order. If one is not ancestor of + the other, lock them in inode pointer order. * find source and target. * if old parent is equal to or is a descendent of target fail with -ENOTEMPTY * if new parent is equal to or is a descendent of source fail with -ELOOP - * If it's an exchange, lock both the source and the target. - * If the target exists, lock it. If the source is a non-directory, - lock it. If we need to lock both, do so in inode pointer order. + * Lock both the source and the target provided they exist. If we + need to lock two inodes of different type (dir vs non-dir), we lock + the directory first. If we need to lock two inodes of the same type, + lock them in inode pointer order. * call the method. All ->i_rwsem are taken exclusive. Again, we might get away with locking
@@ -66,8 +67,9 @@ If no directory is its own ancestor, the Proof: - First of all, at any moment we have a partial ordering of the - objects - A < B iff A is an ancestor of B. + First of all, at any moment we have a linear ordering of the + objects - A < B iff (A is an ancestor of B) or (B is not an ancestor + of A and ptr(A) < ptr(B)). That ordering can change. However, the following is true:
fs/namei.c +14 -8
@@ -4618,7 +4618,7 @@ SYSCALL_DEFINE2(link, const char __user* sb->s_vfs_rename_mutex. We might be more accurate, but that's another * story. * c) we have to lock _four_ objects - parents and victim (if it exists), -* and source (if it is not a directory). +* and source. * And that - after we got ->i_mutex on parents (until then we don't know * whether the target exists). Solution: try to be smart with locking * order for inodes. We rely on the fact that tree topology may change
@@ -4702,10 +4702,16 @@ int vfs_rename(struct renamedata *rd)take_dentry_name_snapshot (&old_name, old_dentry);dget (new_dentry); -if (!is_dir || (flags &RENAME_EXCHANGE )) -lock_two_nondirectories (source, target); -else if (target) -inode_lock (target); +/* +* Lock all moved children. Moved directories may need to change parent +* pointer so they need the lock to prevent against concurrent +* directory changes moving parent pointer. For regular files we've +* historically always done this. The lockdep locking subclasses are +* somewhat arbitrary but RENAME_EXCHANGE in particular can swap +* regular files and directories so it's difficult to tell which +* subclasses to use. +*/ +lock_two_inodes (source, target,I_MUTEX_NORMAL ,I_MUTEX_NONDIR2 ); error = -EPERM ;if (IS_SWAPFILE (source) || (target &&IS_SWAPFILE (target)))
@@ -4753,9 +4759,9 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (!is_dir || (flags &RENAME_EXCHANGE )) -unlock_two_nondirectories (source, target); -else if (target) +if (source) +inode_unlock (source); +if (target)inode_unlock (target);dput (new_dentry);if (!error) {
Greg Kroah-Hartman
maintainerPATCH 361/532 ipvs: increase ip_vs_conn_tab_bits range for 64BIT
In reply to Greg Kroah-HartmanFrom: Abhijeet Rastogi <[email protected]>
commit 04292c695f82b6cf0d25dd5ae494f16ddbb621f6 upstream.
Current range [8, 20] is set purely due to historical reasons because at the time, ~1M (2^20) was considered sufficient. With this change, 27 is the upper limit for 64-bit, 20 otherwise.
Previous change regarding this limit is here.
--- net/netfilter/ipvs/Kconfig | 27 ++++++++++++++------------- net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-)
net/netfilter/ipvs/Kconfig +14 -13
@@ -44,7 +44,8 @@ config IP_VS_DEBUG config IP_VS_TAB_BITS int "IPVS connection table size (the Nth power of 2)" - range 8 20 + range 8 20 if !64BIT + range 8 27 if 64BIT default 12 help The IPVS connection hash table uses the chaining scheme to handle
@@ -54,24 +55,24 @@ config IP_VS_TAB_BITS Note the table size must be power of 2. The table size will be the value of 2 to the your input number power. The number to choose is - from 8 to 20, the default number is 12, which means the table size - is 4096. Don't input the number too small, otherwise you will lose - performance on it. You can adapt the table size yourself, according - to your virtual server application. It is good to set the table size - not far less than the number of connections per second multiplying - average lasting time of connection in the table. For example, your - virtual server gets 200 connections per second, the connection lasts - for 200 seconds in average in the connection table, the table size - should be not far less than 200x200, it is good to set the table - size 32768 (2**15). + from 8 to 27 for 64BIT(20 otherwise), the default number is 12, + which means the table size is 4096. Don't input the number too + small, otherwise you will lose performance on it. You can adapt the + table size yourself, according to your virtual server application. + It is good to set the table size not far less than the number of + connections per second multiplying average lasting time of + connection in the table. For example, your virtual server gets 200 + connections per second, the connection lasts for 200 seconds in + average in the connection table, the table size should be not far + less than 200x200, it is good to set the table size 32768 (2**15). Another note that each connection occupies 128 bytes effectively and each hash entry uses 8 bytes, so you can estimate how much memory is needed for your box. You can overwrite this number setting conn_tab_bits module parameter - or by appending ip_vs.conn_tab_bits=? to the kernel command line - if IP VS was compiled built-in. + or by appending ip_vs.conn_tab_bits=? to the kernel command line if + IP VS was compiled built-in. comment "IPVS transport protocol load balancing support"
net/netfilter/ipvs/ip_vs_conn.c +2 -2
@@ -1484,8 +1484,8 @@ int __init ip_vs_conn_init(void)int idx;/* Compute size and mask */ -if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >20 ) { -pr_info ("conn_tab_bits not in [8, 20]. Using default value\n" ); +if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >27 ) { +pr_info ("conn_tab_bits not in [8, 27]. Using default value\n" ); ip_vs_conn_tab_bits =CONFIG_IP_VS_TAB_BITS ; } ip_vs_conn_tab_size =1 << ip_vs_conn_tab_bits;
Greg Kroah-Hartman
maintainerPATCH 362/532 jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
In reply to Greg Kroah-HartmanFrom: Fabian Frederick <[email protected]>
commit 1168f095417643f663caa341211e117db552989f upstream.
Use kcalloc() for allocation/flush of 128 pointers table to reduce stack usage.
Function now returns -ENOMEM or 0 on success.
stackusage
Before:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208
dynamic,bounded
After:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192
dynamic,bounded
Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled
Tested with an MTD mount point and some user set/getfattr.
Many current target on OpenWRT also suffer from a compilation warning (that become an error with CONFIG_WERROR) with the following output:
fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem':fs/jffs2/xattr.c:887:1: error: the frame size of 1088 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
887 | }
| ^
Using dynamic allocation fix this compilation warning.
Message-Id: <[email protected]>
--- fs/jffs2/build.c | 5 ++++- fs/jffs2/xattr.c | 13 +++++++++---- fs/jffs2/xattr.h | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-)
fs/jffs2/build.c +4 -1
@@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct ic->scan_dents =NULL ;cond_resched (); } -jffs2_build_xattr_subsystem (c); + ret =jffs2_build_xattr_subsystem (c); +if (ret) + goto exit; + c->flags &= ~JFFS2_SB_FLAG_BUILDING ;dbg_fsbuild ("FS build complete\n" );
fs/jffs2/xattr.c +9 -4
@@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct }#define XREF_TMPHASH_SIZE (128) -void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) +int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) {struct jffs2_xattr_ref *ref, *_ref; -struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE ]; +struct jffs2_xattr_ref **xref_tmphash;struct jffs2_xattr_datum *xd, *_xd;struct jffs2_inode_cache *ic;struct jffs2_raw_node_ref *raw;
@@ -784,9 +784,12 @@ void jffs2_build_xattr_subsystem(structBUG_ON (!(c->flags &JFFS2_SB_FLAG_BUILDING )); + xref_tmphash =kcalloc (XREF_TMPHASH_SIZE , +sizeof (struct jffs2_xattr_ref *),GFP_KERNEL ); +if (!xref_tmphash) +return -ENOMEM ; +/* Phase.1 : Merge same xref */ -for (i=0 ; i <XREF_TMPHASH_SIZE ; i++) - xref_tmphash[i] =NULL ;for (ref=c->xref_temp; ref; ref=_ref) {struct jffs2_xattr_ref *tmp;
@@ -884,6 +887,8 @@ void jffs2_build_xattr_subsystem(struct"%u of xref (%u dead, %u orphan) found.\n" , xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, xref_count, xref_dead_count, xref_orphan_count); +kfree (xref_tmphash); +return 0 ; } struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
fs/jffs2/xattr.h +2 -2
@@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(stru#ifdef CONFIG_JFFS2_FS_XATTR extern void jffs2_init_xattr_subsystem (struct jffs2_sb_info *c); -extern void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c); +extern int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c);extern void jffs2_clear_xattr_subsystem (struct jffs2_sb_info *c); extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
@@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct de#else #define jffs2_init_xattr_subsystem (c) -#define jffs2_build_xattr_subsystem (c) +#define jffs2_build_xattr_subsystem (c) (0)#define jffs2_clear_xattr_subsystem (c)#define jffs2_xattr_do_crccheck_inode (c, ic)
Greg Kroah-Hartman
maintainerPATCH 363/532 fs: avoid empty option when generating legacy mount string
In reply to Greg Kroah-HartmanFrom: Thomas Weißschuh <[email protected]>
commit 62176420274db5b5127cd7a0083a9aeb461756ee upstream.
As each option string fragment is always prepended with a comma it would happen that the whole string always starts with a comma. This could be interpreted by filesystem drivers as an empty option and may produce errors.
For example the NTFS driver from ntfs.ko behaves like this and fails when mounted via the new API.
Message-Id: <[email protected]>
--- fs/fs_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fs_context.c +2 -1
@@ -561,7 +561,8 @@ static int legacy_parse_param(struct fs_return -ENOMEM ; } - ctx->legacy_data[size++] =',' ; +if (size) + ctx->legacy_data[size++] =',' ; len =strlen (param->key);memcpy (ctx->legacy_data + size, param->key, len); size += len;
Greg Kroah-Hartman
maintainerPATCH 364/532 btrfs: add handling for RAID1C23/DUP to btrfs_reduce_alloc_profile
In reply to Greg Kroah-HartmanFrom: Matt Corallo <[email protected]>
commit 160fe8f6fdb13da6111677be6263e5d65e875987 upstream.
Callers of btrfs_reduce_alloc_profile expect it to return exactly one allocation profile flag, and failing to do so may ultimately result in a WARN_ON and remount-ro when allocating new blocks, like the below transaction abort on 6.1.
btrfs_reduce_alloc_profile has two ways of determining the profile, first it checks if a conversion balance is currently running and uses the profile we're converting to. If no balance is currently running, it returns the max-redundancy profile which at least one block in the selected block group has.
This works by simply checking each known allocation profile bit in redundancy order. However, btrfs_reduce_alloc_profile has not been updated as new flags have been added - first with the DUP profile and later with the RAID1C34 profiles.
Because of the way it checks, if we have blocks with different profiles and at least one is known, that profile will be selected. However, if none are known we may return a flag set with multiple allocation profiles set.
This is currently only possible when a balance from one of the three unhandled profiles to another of the unhandled profiles is canceled after allocating at least one block using the new profile.
In that case, a transaction abort like the below will occur and the filesystem will need to be mounted with -o skip_balance to get it mounted rw again (but the balance cannot be resumed without a similar abort).
[770.648] ------------[ cut here ]------------ [770.648] BTRFS: Transaction aborted (error -22) [770.648] WARNING: CPU: 43 PID: 1159593 at fs/btrfs/extent-tree.c:4122 find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] CPU: 43 PID: 1159593 Comm: btrfs Tainted: G W 6.1.0-0.deb11.7-powerpc64le #1 Debian 6.1.20-2~bpo11+1a~test [770.648] Hardware name: T2P9D01 REV 1.00 POWER9 0x4e1202 opal:skiboot-bc106a0 PowerNV [770.648] NIP: c00800000f6784fc LR: c00800000f6784f8 CTR: c000000000d746c0 [770.648] REGS: c000200089afe9a0 TRAP: 0700 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 9000000002029033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 28848282 XER: 20040000 [770.648] CFAR: c000000000135110 IRQMASK: 0 GPR00: c00800000f6784f8 c000200089afec40 c00800000f7ea800 0000000000000026 GPR04: 00000001004820c2 c000200089afea00 c000200089afe9f8 0000000000000027 GPR08: c000200ffbfe7f98 c000000002127f90 ffffffffffffffd8 0000000026d6a6e8 GPR12: 0000000028848282 c000200fff7f3800 5deadbeef0000122 c00000002269d000 GPR16: c0002008c7797c40 c000200089afef17 0000000000000000 0000000000000000 GPR20: 0000000000000000 0000000000000001 c000200008bc5a98 0000000000000001 GPR24: 0000000000000000 c0000003c73088d0 c000200089afef17 c000000016d3a800 GPR28: c0000003c7308800 c00000002269d000 ffffffffffffffea 0000000000000001 [770.648] NIP [c00800000f6784fc] find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] LR [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] [770.648] Call Trace: [770.648] [c000200089afec40] [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] (unreliable) [770.648] [c000200089afed30] [c00800000f681398] btrfs_reserve_extent+0x1a0/0x2f0 [btrfs] [770.648] [c000200089afeea0] [c00800000f681bf0] btrfs_alloc_tree_block+0x108/0x670 [btrfs] [770.648] [c000200089afeff0] [c00800000f66bd68] __btrfs_cow_block+0x170/0x850 [btrfs] [770.648] [c000200089aff100] [c00800000f66c58c] btrfs_cow_block+0x144/0x288 [btrfs] [770.648] [c000200089aff1b0] [c00800000f67113c] btrfs_search_slot+0x6b4/0xcb0 [btrfs] [770.648] [c000200089aff2a0] [c00800000f679f60] lookup_inline_extent_backref+0x128/0x7c0 [btrfs] [770.648] [c000200089aff3b0] [c00800000f67b338] lookup_extent_backref+0x70/0x190 [btrfs] [770.648] [c000200089aff470] [c00800000f67b54c] __btrfs_free_extent+0xf4/0x1490 [btrfs] [770.648] [c000200089aff5a0] [c00800000f67d770] __btrfs_run_delayed_refs+0x328/0x1530 [btrfs] [770.648] [c000200089aff740] [c00800000f67ea2c] btrfs_run_delayed_refs+0xb4/0x3e0 [btrfs] [770.648] [c000200089aff800] [c00800000f699aa4] btrfs_commit_transaction+0x8c/0x12b0 [btrfs] [770.648] [c000200089aff8f0] [c00800000f6dc628] reset_balance_state+0x1c0/0x290 [btrfs] [770.648] [c000200089aff9a0] [c00800000f6e2f7c] btrfs_balance+0x1164/0x1500 [btrfs] [770.648] [c000200089affb40] [c00800000f6f8e4c] btrfs_ioctl+0x2b54/0x3100 [btrfs] [770.648] [c000200089affc80] [c00000000053be14] sys_ioctl+0x794/0x1310 [770.648] [c000200089affd70] [c00000000002af98] system_call_exception+0x138/0x250 [770.648] [c000200089affe10] [c00000000000c654] system_call_common+0xf4/0x258 [770.648] --- interrupt: c00 at 0x7fff94126800 [770.648] NIP: 00007fff94126800 LR: 0000000107e0b594 CTR: 0000000000000000 [770.648] REGS: c000200089affe80 TRAP: 0c00 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 900000000000d033 <SF,HV,EE,PR,ME,IR,DR,RI,LE> CR: 24002848 XER: 00000000 [770.648] IRQMASK: 0 GPR00: 0000000000000036 00007fffc9439da0 00007fff94217100 0000000000000003 GPR04: 00000000c4009420 00007fffc9439ee8 0000000000000000 0000000000000000 GPR08: 00000000803c7416 0000000000000000 0000000000000000 0000000000000000 GPR12: 0000000000000000 00007fff9467d120 0000000107e64c9c 0000000107e64d0a GPR16: 0000000107e64d06 0000000107e64cf1 0000000107e64cc4 0000000107e64c73 GPR20: 0000000107e64c31 0000000107e64bf1 0000000107e64be7 0000000000000000 GPR24: 0000000000000000 00007fffc9439ee0 0000000000000003 0000000000000001 GPR28: 00007fffc943f713 0000000000000000 00007fffc9439ee8 0000000000000000 [770.648] NIP [00007fff94126800] 0x7fff94126800 [770.648] LR [0000000107e0b594] 0x107e0b594 [770.648] --- interrupt: c00 [770.648] Instruction dump: [770.648] 3b00ffe4 e8898828 481175f5 60000000 4bfff4fc 3be00000 4bfff570 3d220000 [770.648] 7fc4f378 e8698830 4811cd95 e8410018 <0fe00000> f9c10060 f9e10068 fa010070 [770.648] ---[ end trace 0000000000000000 ]--- [770.648] BTRFS: error (device dm-2: state A) in find_free_extent_update_loop:4122: errno=-22 unknown [770.648] BTRFS info (device dm-2: state EA): forced readonly [770.648] BTRFS: error (device dm-2: state EA) in __btrfs_free_extent:3070: errno=-22 unknown [770.648] BTRFS error (device dm-2: state EA): failed to run delayed ref for logical 17838685708288 num_bytes 24576 type 184 action 2 ref_mod 1: -22 [770.648] BTRFS: error (device dm-2: state EA) in btrfs_run_delayed_refs:2144: errno=-22 unknown [770.648] BTRFS: error (device dm-2: state EA) in reset_balance_state:3599: errno=-22 unknown
--- fs/btrfs/block-group.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +8 -1
@@ -78,14 +78,21 @@ static u64 btrfs_reduce_alloc_profile(st } allowed &= flags; -if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) +/* Select the highest-redundancy RAID level. */ +if (allowed &BTRFS_BLOCK_GROUP_RAID1C4 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C4 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) allowed =BTRFS_BLOCK_GROUP_RAID6 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID1C3 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C3 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID5 ) allowed =BTRFS_BLOCK_GROUP_RAID5 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID10 ) allowed =BTRFS_BLOCK_GROUP_RAID10 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID1 ) allowed =BTRFS_BLOCK_GROUP_RAID1 ; +else if (allowed &BTRFS_BLOCK_GROUP_DUP ) + allowed =BTRFS_BLOCK_GROUP_DUP ;else if (allowed &BTRFS_BLOCK_GROUP_RAID0 ) allowed =BTRFS_BLOCK_GROUP_RAID0 ;
Greg Kroah-Hartman
maintainerPATCH 365/532 btrfs: delete unused BGs while reclaiming BGs
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 3ed01616bad6c7e3de196676b542ae3df8058592 upstream.
The reclaiming process only starts after the filesystem volumes are allocated to a certain level (75% by default). Thus, the list of reclaiming target block groups can build up so huge at the time the reclaim process kicks in. On a test run, there were over 1000 BGs in the reclaim list.
As the reclaim involves rewriting the data, it takes really long time to reclaim the BGs. While the reclaim is running, btrfs_delete_unused_bgs() won't proceed because the reclaim side is holding fs_info->reclaim_bgs_lock. As a result, we will have a large number of unused BGs kept in the unused list. On my test run, I got 1057 unused BGs.
Since deleting a block group is relatively easy and fast work, we can call btrfs_delete_unused_bgs() while it reclaims BGs, to avoid building up unused BGs.
--- fs/btrfs/block-group.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/block-group.c +14 -0
@@ -1574,10 +1574,24 @@ void btrfs_reclaim_bgs_work(struct work_ next:btrfs_put_block_group (bg); + +mutex_unlock (&fs_info->reclaim_bgs_lock); +/* +* Reclaiming all the block groups in the list can take really +* long. Prioritize cleaning up unused block groups. +*/ +btrfs_delete_unused_bgs (fs_info); +/* +* If we are interrupted by a balance, we can just bail out. The +* cleaner thread restart again if necessary. +*/ +if (!mutex_trylock (&fs_info->reclaim_bgs_lock)) + goto end;spin_lock (&fs_info->unused_bgs_lock); }spin_unlock (&fs_info->unused_bgs_lock);mutex_unlock (&fs_info->reclaim_bgs_lock); +end:btrfs_exclop_finish (fs_info);sb_end_write (fs_info->sb); }
Greg Kroah-Hartman
maintainerPATCH 366/532 btrfs: bail out reclaim process if filesystem is read-only
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 93463ff7b54626f8276c0bd3d3f968fbf8d5d380 upstream.
When a filesystem is read-only, we cannot reclaim a block group as it cannot rewrite the data. Just bail out in that case.
Note that it can drop block groups in this case. As we did sb_start_write(), read-only filesystem means we got a fatal error and forced read-only. There is no chance to reclaim them again.
--- fs/btrfs/block-group.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/block-group.c +9 -2
@@ -1541,8 +1541,15 @@ void btrfs_reclaim_bgs_work(struct work_ }spin_unlock (&bg->lock); -/* Get out fast, in case we're unmounting the filesystem */ -if (btrfs_fs_closing (fs_info)) { +/* +* Get out fast, in case we're read-only or unmounting the +* filesystem. It is OK to drop block groups from the list even +* for the read-only case. As we did sb_start_write(), +* "mount -o remount,ro" won't happen and read-only filesystem +* means it is forced read-only due to a fatal error. So, it +* never gets back to read-write to let us reclaim again. +*/ +if (btrfs_need_cleaner_sleep (fs_info)) {up_write (&space_info->groups_sem); goto next; }
Greg Kroah-Hartman
maintainerPATCH 367/532 btrfs: reinsert BGs failed to reclaim
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 7e27180994383b7c741ad87749db01e4989a02ba upstream.
The reclaim process can temporarily fail. For example, if the space is getting tight, it fails to make the block group read-only. If there are no further writes on that block group, the block group will never get back to the reclaim list, and the BG never gets reclaimed. In a certain workload, we can leave many such block groups never reclaimed.
So, let's get it back to the list and give it a chance to be reclaimed.
--- fs/btrfs/block-group.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/block-group.c +2 -0
@@ -1580,6 +1580,8 @@ void btrfs_reclaim_bgs_work(struct work_ } next: +if (ret) +btrfs_mark_bg_to_reclaim (bg);btrfs_put_block_group (bg);mutex_unlock (&fs_info->reclaim_bgs_lock);
Greg Kroah-Hartman
maintainerPATCH 368/532 btrfs: fix race when deleting quota root from the dirty cow roots list
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit b31cb5a6eb7a48b0a7bfdf06832b1fd5088d8c79 upstream.
When disabling quotas we are deleting the quota root from the list fs_info->dirty_cowonly_roots without taking the lock that protects it, which is struct btrfs_fs_info::trans_lock. This unsynchronized list manipulation may cause chaos if there's another concurrent manipulation of this list, such as when adding a root to it with ctree.c:add_root_to_dirty_list().
This can result in all sorts of weird failures caused by a race, such as the following crash:
[337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G W 6.4.0-rc6-btrfs-next-134+ #1 [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.279928] Code: 85 38 06 00 (...) [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206 [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000 [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070 [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600 [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48 [337571.281723] FS: 00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000 [337571.281950] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0 [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [337571.282874] Call Trace: [337571.283101] <TASK> [337571.283327] ? __die_body+0x1b/0x60 [337571.283570] ? die_addr+0x39/0x60 [337571.283796] ? exc_general_protection+0x22e/0x430 [337571.284022] ? asm_exc_general_protection+0x22/0x30 [337571.284251] ? commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.284531] btrfs_commit_transaction+0x42e/0xf90 [btrfs] [337571.284803] ? _raw_spin_unlock+0x15/0x30 [337571.285031] ? release_extent_buffer+0x103/0x130 [btrfs] [337571.285305] reset_balance_state+0x152/0x1b0 [btrfs] [337571.285578] btrfs_balance+0xa50/0x11e0 [btrfs] [337571.285864] ? __kmem_cache_alloc_node+0x14a/0x410 [337571.286086] btrfs_ioctl+0x249a/0x3320 [btrfs] [337571.286358] ? mod_objcg_state+0xd2/0x360 [337571.286577] ? refill_obj_stock+0xb0/0x160 [337571.286798] ? seq_release+0x25/0x30 [337571.287016] ? __rseq_handle_notify_resume+0x3ba/0x4b0 [337571.287235] ? percpu_counter_add_batch+0x2e/0xa0 [337571.287455] ? __x64_sys_ioctl+0x88/0xc0 [337571.287675] __x64_sys_ioctl+0x88/0xc0 [337571.287901] do_syscall_64+0x38/0x90 [337571.288126] entry_SYSCALL_64_after_hwframe+0x72/0xdc [337571.288352] RIP: 0033:0x7f478aaffe9b
So fix this by locking struct btrfs_fs_info::trans_lock before deleting the quota root from that list.
--- fs/btrfs/qgroup.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/qgroup.c +2 -0
@@ -1269,7 +1269,9 @@ int btrfs_quota_disable(struct btrfs_fs_ goto out; } +spin_lock (&fs_info->trans_lock);list_del ("a_root->dirty_list); +spin_unlock (&fs_info->trans_lock);btrfs_tree_lock (quota_root->node);btrfs_clean_tree_block (quota_root->node);
Greg Kroah-Hartman
maintainerPATCH 369/532 btrfs: fix extent buffer leak after tree mod log failure at split_node()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit ede600e497b1461d06d22a7d17703d9096868bc3 upstream.
At split_node(), if we fail to log the tree mod log copy operation, we return without unlocking the split extent buffer we just allocated and without decrementing the reference we own on it. Fix this by unlocking it and decrementing the ref count before returning.
--- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
@@ -2637,6 +2637,8 @@ static noinline int split_node(struct bt ret =btrfs_tree_mod_log_eb_copy (split, c,0 , mid, c_nritems - mid);if (ret) { +btrfs_tree_unlock (split); +free_extent_buffer (split);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 370/532 btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 40b0a749388517de244643c09bdbb98f7dcb6ef1 upstream.
At __btrfs_cow_block(), instead of doing a BUG_ON() in case we fail to record a tree mod log root insertion operation, do a transaction abort instead. There's really no need for the BUG_ON(), we can properly release all resources in this context and turn the filesystem to RO mode and in an error state instead.
--- fs/btrfs/ctree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +7 -2
@@ -457,9 +457,14 @@ static noinline int __btrfs_cow_block(st btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) parent_start = buf->start; -atomic_inc (&cow->refs); ret =btrfs_tree_mod_log_insert_root (root->node, cow, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow); +btrfs_abort_transaction (trans, ret); +return ret; + } +atomic_inc (&cow->refs);rcu_assign_pointer (root->node, cow); btrfs_free_tree_block(trans, btrfs_root_id(root), buf,
Greg Kroah-Hartman
maintainerPATCH 371/532 ASoC: mediatek: mt8173: Fix irq error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit f9c058d14f4fe23ef523a7ff73734d51c151683c upstream.
After reordering the irq probe, the error path was not properly done. Lets fix it.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +5 -4
@@ -1072,6 +1072,10 @@ static int mt8173_afe_pcm_dev_probe(stru afe->dev = &pdev->dev; + irq_id =platform_get_irq (pdev,0 ); +if (irq_id <=0 ) +return irq_id <0 ? irq_id : -ENXIO ; + afe->base_addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (afe->base_addr))return PTR_ERR (afe->base_addr);
@@ -1177,14 +1181,11 @@ static int mt8173_afe_pcm_dev_probe(struif (ret) goto err_cleanup_components; - irq_id =platform_get_irq (pdev,0 ); -if (irq_id <=0 ) -return irq_id <0 ? irq_id : -ENXIO ; ret =devm_request_irq (afe->dev, irq_id, mt8173_afe_irq_handler,0 ,"Afe_ISR_Handle" , (void *)afe);if (ret) {dev_err (afe->dev,"could not request_irq\n" ); - goto err_pm_disable; + goto err_cleanup_components; }dev_info (&pdev->dev,"MT8173 AFE driver initialized.\n" );
Greg Kroah-Hartman
maintainerPATCH 372/532 ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit a46d37012a5be1737393b8f82fd35665e4556eee upstream.
If the second component fails to initialize, cleanup the first on.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +2 -2
@@ -1162,14 +1162,14 @@ static int mt8173_afe_pcm_dev_probe(stru comp_hdmi =devm_kzalloc (&pdev->dev,sizeof (*comp_hdmi),GFP_KERNEL );if (!comp_hdmi) { ret = -ENOMEM ; - goto err_pm_disable; + goto err_cleanup_components; } ret =snd_soc_component_initialize (comp_hdmi, &mt8173_afe_hdmi_dai_component, &pdev->dev);if (ret) - goto err_pm_disable; + goto err_cleanup_components;#ifdef CONFIG_DEBUG_FS comp_hdmi->debugfs_prefix ="hdmi" ;
Greg Kroah-Hartman
maintainerPATCH 373/532 ARM: dts: qcom: ipq4019: fix broken NAND controller properties override
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit edcbdd57de499305e2a3737d4a73fe387f71d84c upstream.
After renaming NAND controller node name from "qpic-nand" to "nand-controller", the board DTS/DTSI also have to be updated:
Warning (unit_address_vs_reg): /soc/qpic-nand@79b0000: node has a unit name, but no reg or ranges property
--- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts | 8 ++++---- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi | 10 +++++----- arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-)
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts +4 -4
@@ -11,9 +11,9 @@ dma@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - status = "okay"; - }; }; }; + +&nand { + status = "okay"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi +5 -5
@@ -102,10 +102,10 @@ status = "okay"; perst-gpio = <&tlmm 38 0x1>; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi +6 -6
@@ -65,11 +65,11 @@ dma@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - status = "okay"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; +};
Greg Kroah-Hartman
maintainerPATCH 374/532 ARM: orion5x: fix d2net gpio initialization
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit f8ef1233939495c405a9faa4bd1ae7d3f581bae4 upstream.
The DT version of this board has a custom file with the gpio device. However, it does nothing because the d2net_init() has no caller or prototype:
arch/arm/mach-orion5x/board-d2net.c:101:13: error: no previous prototype for 'd2net_init'
Call it from the board-dt file as intended.
--- arch/arm/mach-orion5x/board-dt.c | 3 +++ arch/arm/mach-orion5x/common.h | 6 ++++++ 2 files changed, 9 insertions(+)
arch/arm/mach-orion5x/board-dt.c +3 -0
@@ -63,6 +63,9 @@ static void __init orion5x_dt_init(void)if (of_machine_is_compatible ("maxtor,shared-storage-2" ))mss2_init (); +if (of_machine_is_compatible ("lacie,d2-network" )) +d2net_init (); +of_platform_default_populate (NULL , orion5x_auxdata_lookup,NULL ); }
arch/arm/mach-orion5x/common.h +6 -0
@@ -75,6 +75,12 @@ extern void mss2_init(void);static inline void mss2_init (void ) {}#endif +#ifdef CONFIG_MACH_D2NET_DT +void d2net_init (void ); +#else +static inline void d2net_init (void ) {} +#endif +/***************************************************************************** * Helpers to access Orion registers ****************************************************************************/
Greg Kroah-Hartman
maintainerPATCH 375/532 leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
commit cee4bd16c3195a701be683f7da9e88c6e11acb73 upstream.
Dev can be renamed also while up for supported device. We currently wrongly clear the NETDEV_LED_MODE_LINKUP flag on NETDEV_CHANGENAME event.
Fix this by rechecking if the carrier is ok on NETDEV_CHANGENAME and correctly set the NETDEV_LED_MODE_LINKUP bit.
--- drivers/leds/trigger/ledtrig-netdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/leds/trigger/ledtrig-netdev.c +3 -0
@@ -318,6 +318,9 @@ static int netdev_trig_notify(struct notclear_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode);switch (evt) {case NETDEV_CHANGENAME : +if (netif_carrier_ok (dev)) +set_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode); + fallthrough;case NETDEV_REGISTER :if (trigger_data->net_dev)dev_put (trigger_data->net_dev);
Greg Kroah-Hartman
maintainerPATCH 376/532 fs: no need to check source
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 66d8fc0539b0d49941f313c9509a8384e4245ac1 upstream.
The @source inode must be valid. It is even checked via IS_SWAPFILE() above making it pretty clear. So no need to check it when we unlock.
What doesn't need to exist is the @target inode. The lock_two_inodes() helper currently swaps the @inode1 and @inode2 arguments if @inode1 is NULL to have consistent lock class usage. However, we know that at least for vfs_rename() that @inode1 is @source and thus is never NULL as per above. We also know that @source is a different inode than @target as that is checked right at the beginning of vfs_rename(). So we know that @source is valid and locked and that @target is locked. So drop the check whether @source is non-NULL.
Message-Id: <[email protected]>
--- fs/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/namei.c +1 -2
@@ -4759,8 +4759,7 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (source) -inode_unlock (source); +inode_unlock (source);if (target)inode_unlock (target);dput (new_dentry);
Greg Kroah-Hartman
maintainerPATCH 377/532 ovl: fix null pointer dereference in ovl_get_acl_rcu()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit f4e19e595cc2e76a8a58413eb19d3d9c51328b53 upstream.
Following process:
P1 P2
path_openat
link_path_walk
may_lookup
inode_permission(rcu)
ovl_permission
acl_permission_check
check_acl
get_cached_acl_rcu
ovl_get_inode_acl
realinode = ovl_inode_real(ovl_inode)
drop_cache
__dentry_kill(ovl_dentry)
iput(ovl_inode)
ovl_destroy_inode(ovl_inode)
dput(oi->__upperdentry)
dentry_kill(upperdentry)
dentry_unlink_inode
upperdentry->d_inode = NULL
ovl_inode_upper
upperdentry = ovl_i_dentry_upper(ovl_inode) d_inode(upperdentry) // returns NULL
IS_POSIXACL(realinode) // NULL pointer dereference
, will trigger an null pointer dereference at realinode:
[ 205.472797] BUG: kernel NULL pointer dereference, address:
0000000000000028
[ 205.476701] CPU: 2 PID: 2713 Comm: ls Not tainted
6.3.0-12064-g2edfa098e750-dirty #1216
[ 205.478754] RIP: 0010:do_ovl_get_acl+0x5d/0x300
[ 205.489584] Call Trace:
[ 205.489812] <TASK>
[ 205.490014] ovl_get_inode_acl+0x26/0x30
[ 205.490466] get_cached_acl_rcu+0x61/0xa0
[ 205.490908] generic_permission+0x1bf/0x4e0
[ 205.491447] ovl_permission+0x79/0x1b0
[ 205.491917] inode_permission+0x15e/0x2c0
[ 205.492425] link_path_walk+0x115/0x550
[ 205.493311] path_lookupat.isra.0+0xb2/0x200
[ 205.493803] filename_lookup+0xda/0x240
[ 205.495747] vfs_fstatat+0x7b/0xb0Fetch a reproducer in [Link].
Use the helper ovl_i_path_realinode() to get realinode and then do non-nullptr checking.
--- fs/overlayfs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/overlayfs/inode.c +9 -1
@@ -453,7 +453,15 @@ struct posix_acl *ovl_get_acl(struct inoconst struct cred *old_cred;struct posix_acl *acl; -if (!IS_ENABLED (CONFIG_FS_POSIX_ACL ) || !IS_POSIXACL (realinode)) +if (!IS_ENABLED (CONFIG_FS_POSIX_ACL )) +return NULL ; + +if (!realinode) { +WARN_ON (!rcu); +return ERR_PTR (-ECHILD ); + } + +if (!IS_POSIXACL (realinode))return NULL ;if (rcu)
Greg Kroah-Hartman
maintainerPATCH 378/532 fanotify: disallow mount/sb marks on kernel internal pseudo fs
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
commit 69562eb0bd3e6bb8e522a7b254334e0fb30dff0c upstream.
Hopefully, nobody is trying to abuse mount/sb marks for watching all anonymous pipes/inodes.
I cannot think of a good reason to allow this - it looks like an oversight that dated back to the original fanotify API.
Message-Id: <[email protected]>
--- fs/notify/fanotify/fanotify_user.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
fs/notify/fanotify/fanotify_user.c +20 -2
@@ -1337,8 +1337,11 @@ static int fanotify_test_fid(struct pathreturn 0 ; } -static int fanotify_events_supported (struct path *path,__u64 mask) +static int fanotify_events_supported (struct path *path,__u64 mask, +unsigned int flags) { +unsigned int mark_type = flags &FANOTIFY_MARK_TYPE_BITS ; +/* * Some filesystems such as 'proc' acquire unusual locks when opening * files. For them fanotify permission events have high chances of
@@ -1350,6 +1353,21 @@ static int fanotify_events_supported(strif (mask &FANOTIFY_PERM_EVENTS && path->mnt->mnt_sb->s_type->fs_flags &FS_DISALLOW_NOTIFY_PERM )return -EINVAL ; + +/* +* mount and sb marks are not allowed on kernel internal pseudo fs, +* like pipe_mnt, because that would subscribe to events on all the +* anonynous pipes in the system. +* +* SB_NOUSER covers all of the internal pseudo fs whose objects are not +* exposed to user's mount namespace, but there are other SB_KERNMOUNT +* fs, like nsfs, debugfs, for which the value of allowing sb and mount +* mark is questionable. For now we leave them alone. +*/ +if (mark_type !=FAN_MARK_INODE && + path->mnt->mnt_sb->s_flags &SB_NOUSER ) +return -EINVAL ; +return 0 ; }
@@ -1476,7 +1494,7 @@ static int do_fanotify_mark(int fanotify goto fput_and_out;if (flags &FAN_MARK_ADD ) { - ret =fanotify_events_supported (&path, mask); + ret =fanotify_events_supported (&path, mask, flags);if (ret) goto path_put_and_out; }
Greg Kroah-Hartman
maintainerPATCH 379/532 netfilter: nf_tables: unbind non-anonymous set if rule construction fails
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
commit 3e70489721b6c870252c9082c496703677240f53 upstream.
Otherwise a dangling reference to a rule object that is gone remains in the set binding list.
--- net/netfilter/nf_tables_api.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_tables_api.c +2 -0
@@ -5042,6 +5042,8 @@ void nf_tables_deactivate_set(const strunft_set_trans_unbind (ctx, set);if (nft_set_is_anonymous (set))nft_deactivate_next (ctx->net, set); +else +list_del_rcu (&binding->list); set->use--;break ;
Greg Kroah-Hartman
maintainerPATCH 380/532 netfilter: conntrack: Avoid nf_ct_helper_hash uses after free
In reply to Greg Kroah-HartmanFrom: Florent Revest <[email protected]>
commit 6eef7a2b933885a17679eb8ed0796ddf0ee5309b upstream.
If nf_conntrack_init_start() fails (for example due to a register_nf_conntrack_bpf() failure), the nf_conntrack_helper_fini() clean-up path frees the nf_ct_helper_hash map.
When built with NF_CONNTRACK=y, further netfilter modules (e.g:netfilter_conntrack_ftp) can still be loaded and call nf_conntrack_helpers_register(), independently of whether nf_conntrack initialized correctly. This accesses the nf_ct_helper_hash dangling pointer and causes a uaf, possibly leading to random memory corruption.
This patch guards nf_conntrack_helper_register() from accessing a freed or uninitialized nf_ct_helper_hash pointer and fixes possible uses-after-free when loading a conntrack module.
--- net/netfilter/nf_conntrack_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nf_conntrack_helper.c +4 -0
@@ -405,6 +405,9 @@ int nf_conntrack_helper_register(structBUG_ON (me->expect_class_max >=NF_CT_MAX_EXPECT_CLASSES );BUG_ON (strlen (me->name) >NF_CT_HELPER_NAME_LEN -1 ); +if (!nf_ct_helper_hash) +return -ENOENT ; +if (me->expect_policy->max_expected >NF_CT_EXPECT_MAX_CNT )return -EINVAL ;
@@ -595,4 +598,5 @@ void nf_conntrack_helper_fini(void) {nf_ct_extend_unregister (&helper_extend);kvfree (nf_ct_helper_hash); + nf_ct_helper_hash =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 381/532 netfilter: nf_tables: do not ignore genmask when looking up chain by id
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit 515ad530795c118f012539ed76d02bacfd426d89 upstream.
When adding a rule to a chain referring to its ID, if that chain had been deleted on the same batch, the rule might end up referring to a deleted chain.
This will lead to a WARNING like following:
[ 33.098431] ------------[ cut here ]------------ [ 33.098678] WARNING: CPU: 5 PID: 69 at net/netfilter/nf_tables_api.c:2037 nf_tables_chain_destroy+0x23d/0x260 [ 33.099217] Modules linked in: [ 33.099388] CPU: 5 PID: 69 Comm: kworker/5:1 Not tainted 6.4.0+ #409 [ 33.099726] Workqueue: events nf_tables_trans_destroy_work [ 33.100018] RIP: 0010:nf_tables_chain_destroy+0x23d/0x260 [ 33.100306] Code: 8b 7c 24 68 e8 64 9c ed fe 4c 89 e7 e8 5c 9c ed fe 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 89 c6 89 c7 c3 cc cc cc cc <0f> 0b 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 89 c6 89 c7 [ 33.101271] RSP: 0018:ffffc900004ffc48 EFLAGS: 00010202 [ 33.101546] RAX: 0000000000000001 RBX: ffff888006fc0a28 RCX: 0000000000000000 [ 33.101920] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 [ 33.102649] RBP: ffffc900004ffc78 R08: 0000000000000000 R09: 0000000000000000 [ 33.103018] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880135ef500 [ 33.103385] R13: 0000000000000000 R14: dead000000000122 R15: ffff888006fc0a10 [ 33.103762] FS: 0000000000000000(0000) GS:ffff888024c80000(0000) knlGS:0000000000000000 [ 33.104184] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 33.104493] CR2: 00007fe863b56a50 CR3: 00000000124b0001 CR4: 0000000000770ee0 [ 33.104872] PKRU: 55555554 [ 33.104999] Call Trace: [ 33.105113] <TASK> [ 33.105214] ? show_regs+0x72/0x90 [ 33.105371] ? __warn+0xa5/0x210 [ 33.105520] ? nf_tables_chain_destroy+0x23d/0x260 [ 33.105732] ? report_bug+0x1f2/0x200 [ 33.105902] ? handle_bug+0x46/0x90 [ 33.106546] ? exc_invalid_op+0x19/0x50 [ 33.106762] ? asm_exc_invalid_op+0x1b/0x20 [ 33.106995] ? nf_tables_chain_destroy+0x23d/0x260 [ 33.107249] ? nf_tables_chain_destroy+0x30/0x260 [ 33.107506] nf_tables_trans_destroy_work+0x669/0x680 [ 33.107782] ? mark_held_locks+0x28/0xa0 [ 33.107996] ? __pfx_nf_tables_trans_destroy_work+0x10/0x10 [ 33.108294] ? _raw_spin_unlock_irq+0x28/0x70 [ 33.108538] process_one_work+0x68c/0xb70 [ 33.108755] ? lock_acquire+0x17f/0x420 [ 33.108977] ? __pfx_process_one_work+0x10/0x10 [ 33.109218] ? do_raw_spin_lock+0x128/0x1d0 [ 33.109435] ? _raw_spin_lock_irq+0x71/0x80 [ 33.109634] worker_thread+0x2bd/0x700 [ 33.109817] ? __pfx_worker_thread+0x10/0x10 [ 33.110254] kthread+0x18b/0x1d0 [ 33.110410] ? __pfx_kthread+0x10/0x10 [ 33.110581] ret_from_fork+0x29/0x50 [ 33.110757] </TASK> [ 33.110866] irq event stamp: 1651 [ 33.111017] hardirqs last enabled at (1659): [<ffffffffa206a209>] __up_console_sem+0x79/0xa0 [ 33.111379] hardirqs last disabled at (1666): [<ffffffffa206a1ee>] __up_console_sem+0x5e/0xa0 [ 33.111740] softirqs last enabled at (1616): [<ffffffffa1f5d40e>] __irq_exit_rcu+0x9e/0xe0 [ 33.112094] softirqs last disabled at (1367): [<ffffffffa1f5d40e>] __irq_exit_rcu+0x9e/0xe0 [ 33.112453] ---[ end trace 0000000000000000 ]---
This is due to the nft_chain_lookup_byid ignoring the genmask. After this change, adding the new rule will fail as it will not find the chain.
--- net/netfilter/nf_tables_api.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/netfilter/nf_tables_api.c +7 -4
@@ -2533,7 +2533,7 @@ err:static struct nft_chain *nft_chain_lookup_byid (const struct net *net,const struct nft_table *table, -const struct nlattr *nla) +const struct nlattr *nla,u8 genmask) {struct nftables_pernet *nft_net =nft_pernet (net);u32 id =ntohl (nla_get_be32 (nla));
@@ -2544,7 +2544,8 @@ static struct nft_chain *nft_chain_lookuif (trans->msg_type ==NFT_MSG_NEWCHAIN && chain->table == table && - id ==nft_trans_chain_id (trans)) + id ==nft_trans_chain_id (trans) && +nft_active_genmask (chain, genmask))return chain; }return ERR_PTR (-ENOENT );
@@ -3532,7 +3533,8 @@ static int nf_tables_newrule(struct sk_breturn -EOPNOTSUPP ; }else if (nla[NFTA_RULE_CHAIN_ID ]) { - chain =nft_chain_lookup_byid (net, table, nla[NFTA_RULE_CHAIN_ID ]); + chain =nft_chain_lookup_byid (net, table, nla[NFTA_RULE_CHAIN_ID ], + genmask);if (IS_ERR (chain)) {NL_SET_BAD_ATTR (extack, nla[NFTA_RULE_CHAIN_ID ]);return PTR_ERR (chain);
@@ -9931,7 +9933,8 @@ static int nft_verdict_init(const struct genmask); }else if (tb[NFTA_VERDICT_CHAIN_ID ]) { chain =nft_chain_lookup_byid (ctx->net, ctx->table, - tb[NFTA_VERDICT_CHAIN_ID ]); + tb[NFTA_VERDICT_CHAIN_ID ], + genmask);if (IS_ERR (chain))return PTR_ERR (chain); }else {
Greg Kroah-Hartman
maintainerPATCH 382/532 netfilter: nf_tables: prevent OOB access in nft_byteorder_eval
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit caf3ef7468f7534771b5c44cd8dbd6f7f87c2cbd upstream.
When evaluating byteorder expressions with size 2, a union with 32-bit and 16-bit members is used. Since the 16-bit members are aligned to 32-bit, the array accesses will be out-of-bounds.
It may lead to a stack-out-of-bounds access like the one below:
[ 23.095215] ================================================================== [ 23.095625] BUG: KASAN: stack-out-of-bounds in nft_byteorder_eval+0x13c/0x320 [ 23.096020] Read of size 2 at addr ffffc90000007948 by task ping/115 [ 23.096358] [ 23.096456] CPU: 0 PID: 115 Comm: ping Not tainted 6.4.0+ #413 [ 23.096770] Call Trace: [ 23.096910] <IRQ> [ 23.097030] dump_stack_lvl+0x60/0xc0 [ 23.097218] print_report+0xcf/0x630 [ 23.097388] ? nft_byteorder_eval+0x13c/0x320 [ 23.097577] ? kasan_addr_to_slab+0xd/0xc0 [ 23.097760] ? nft_byteorder_eval+0x13c/0x320 [ 23.097949] kasan_report+0xc9/0x110 [ 23.098106] ? nft_byteorder_eval+0x13c/0x320 [ 23.098298] __asan_load2+0x83/0xd0 [ 23.098453] nft_byteorder_eval+0x13c/0x320 [ 23.098659] nft_do_chain+0x1c8/0xc50 [ 23.098852] ? __pfx_nft_do_chain+0x10/0x10 [ 23.099078] ? __kasan_check_read+0x11/0x20 [ 23.099295] ? __pfx___lock_acquire+0x10/0x10 [ 23.099535] ? __pfx___lock_acquire+0x10/0x10 [ 23.099745] ? __kasan_check_read+0x11/0x20 [ 23.099929] nft_do_chain_ipv4+0xfe/0x140 [ 23.100105] ? __pfx_nft_do_chain_ipv4+0x10/0x10 [ 23.100327] ? lock_release+0x204/0x400 [ 23.100515] ? nf_hook.constprop.0+0x340/0x550 [ 23.100779] nf_hook_slow+0x6c/0x100 [ 23.100977] ? __pfx_nft_do_chain_ipv4+0x10/0x10 [ 23.101223] nf_hook.constprop.0+0x334/0x550 [ 23.101443] ? __pfx_ip_local_deliver_finish+0x10/0x10 [ 23.101677] ? __pfx_nf_hook.constprop.0+0x10/0x10 [ 23.101882] ? __pfx_ip_rcv_finish+0x10/0x10 [ 23.102071] ? __pfx_ip_local_deliver_finish+0x10/0x10 [ 23.102291] ? rcu_read_lock_held+0x4b/0x70 [ 23.102481] ip_local_deliver+0xbb/0x110 [ 23.102665] ? __pfx_ip_rcv+0x10/0x10 [ 23.102839] ip_rcv+0x199/0x2a0 [ 23.102980] ? __pfx_ip_rcv+0x10/0x10 [ 23.103140] __netif_receive_skb_one_core+0x13e/0x150 [ 23.103362] ? __pfx___netif_receive_skb_one_core+0x10/0x10 [ 23.103647] ? mark_held_locks+0x48/0xa0 [ 23.103819] ? process_backlog+0x36c/0x380 [ 23.103999] __netif_receive_skb+0x23/0xc0 [ 23.104179] process_backlog+0x91/0x380 [ 23.104350] __napi_poll.constprop.0+0x66/0x360 [ 23.104589] ? net_rx_action+0x1cb/0x610 [ 23.104811] net_rx_action+0x33e/0x610 [ 23.105024] ? _raw_spin_unlock+0x23/0x50 [ 23.105257] ? __pfx_net_rx_action+0x10/0x10 [ 23.105485] ? mark_held_locks+0x48/0xa0 [ 23.105741] __do_softirq+0xfa/0x5ab [ 23.105956] ? __dev_queue_xmit+0x765/0x1c00 [ 23.106193] do_softirq.part.0+0x49/0xc0 [ 23.106423] </IRQ> [ 23.106547] <TASK> [ 23.106670] __local_bh_enable_ip+0xf5/0x120 [ 23.106903] __dev_queue_xmit+0x789/0x1c00 [ 23.107131] ? __pfx___dev_queue_xmit+0x10/0x10 [ 23.107381] ? find_held_lock+0x8e/0xb0 [ 23.107585] ? lock_release+0x204/0x400 [ 23.107798] ? neigh_resolve_output+0x185/0x350 [ 23.108049] ? mark_held_locks+0x48/0xa0 [ 23.108265] ? neigh_resolve_output+0x185/0x350 [ 23.108514] neigh_resolve_output+0x246/0x350 [ 23.108753] ? neigh_resolve_output+0x246/0x350 [ 23.109003] ip_finish_output2+0x3c3/0x10b0 [ 23.109250] ? __pfx_ip_finish_output2+0x10/0x10 [ 23.109510] ? __pfx_nf_hook+0x10/0x10 [ 23.109732] __ip_finish_output+0x217/0x390 [ 23.109978] ip_finish_output+0x2f/0x130 [ 23.110207] ip_output+0xc9/0x170 [ 23.110404] ip_push_pending_frames+0x1a0/0x240 [ 23.110652] raw_sendmsg+0x102e/0x19e0 [ 23.110871] ? __pfx_raw_sendmsg+0x10/0x10 [ 23.111093] ? lock_release+0x204/0x400 [ 23.111304] ? __mod_lruvec_page_state+0x148/0x330 [ 23.111567] ? find_held_lock+0x8e/0xb0 [ 23.111777] ? find_held_lock+0x8e/0xb0 [ 23.111993] ? __rcu_read_unlock+0x7c/0x2f0 [ 23.112225] ? aa_sk_perm+0x18a/0x550 [ 23.112431] ? filemap_map_pages+0x4f1/0x900 [ 23.112665] ? __pfx_aa_sk_perm+0x10/0x10 [ 23.112880] ? find_held_lock+0x8e/0xb0 [ 23.113098] inet_sendmsg+0xa0/0xb0 [ 23.113297] ? inet_sendmsg+0xa0/0xb0 [ 23.113500] ? __pfx_inet_sendmsg+0x10/0x10 [ 23.113727] sock_sendmsg+0xf4/0x100 [ 23.113924] ? move_addr_to_kernel.part.0+0x4f/0xa0 [ 23.114190] __sys_sendto+0x1d4/0x290 [ 23.114391] ? __pfx___sys_sendto+0x10/0x10 [ 23.114621] ? __pfx_mark_lock.part.0+0x10/0x10 [ 23.114869] ? lock_release+0x204/0x400 [ 23.115076] ? find_held_lock+0x8e/0xb0 [ 23.115287] ? rcu_is_watching+0x23/0x60 [ 23.115503] ? __rseq_handle_notify_resume+0x6e2/0x860 [ 23.115778] ? __kasan_check_write+0x14/0x30 [ 23.116008] ? blkcg_maybe_throttle_current+0x8d/0x770 [ 23.116285] ? mark_held_locks+0x28/0xa0 [ 23.116503] ? do_syscall_64+0x37/0x90 [ 23.116713] __x64_sys_sendto+0x7f/0xb0 [ 23.116924] do_syscall_64+0x59/0x90 [ 23.117123] ? irqentry_exit_to_user_mode+0x25/0x30 [ 23.117387] ? irqentry_exit+0x77/0xb0 [ 23.117593] ? exc_page_fault+0x92/0x140 [ 23.117806] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 23.118081] RIP: 0033:0x7f744aee2bba [ 23.118282] Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 15 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 7e c3 0f 1f 44 00 00 41 54 48 83 ec 30 44 89 [ 23.119237] RSP: 002b:00007ffd04a7c9f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c [ 23.119644] RAX: ffffffffffffffda RBX: 00007ffd04a7e0a0 RCX: 00007f744aee2bba [ 23.120023] RDX: 0000000000000040 RSI: 000056488e9e6300 RDI: 0000000000000003 [ 23.120413] RBP: 000056488e9e6300 R08: 00007ffd04a80320 R09: 0000000000000010 [ 23.120809] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000040 [ 23.121219] R13: 00007ffd04a7dc38 R14: 00007ffd04a7ca00 R15: 00007ffd04a7e0a0 [ 23.121617] </TASK> [ 23.121749] [ 23.121845] The buggy address belongs to the virtual mapping at [ 23.121845] [ffffc90000000000, ffffc90000009000) created by: [ 23.121845] irq_init_percpu_irqstack+0x1cf/0x270 [ 23.122707] [ 23.122803] The buggy address belongs to the physical page: [ 23.123104] page:0000000072ac19f0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24a09 [ 23.123609] flags: 0xfffffc0001000(reserved|node=0|zone=1|lastcpupid=0x1fffff) [ 23.123998] page_type: 0xffffffff() [ 23.124194] raw: 000fffffc0001000 ffffea0000928248 ffffea0000928248 0000000000000000 [ 23.124610] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 [ 23.125023] page dumped because: kasan: bad access detected [ 23.125326] [ 23.125421] Memory state around the buggy address: [ 23.125682] ffffc90000007800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 23.126072] ffffc90000007880: 00 00 00 00 00 f1 f1 f1 f1 f1 f1 00 00 f2 f2 00 [ 23.126455] >ffffc90000007900: 00 00 00 00 00 00 00 00 00 f2 f2 f2 f2 00 00 00 [ 23.126840] ^ [ 23.127138] ffffc90000007980: 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3 [ 23.127522] ffffc90000007a00: f3 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 [ 23.127906] ================================================================== [ 23.128324] Disabling lock debugging due to kernel taint
Using simple s16 pointers for the 16-bit accesses fixes the problem. For the 32-bit accesses, src and dst can be used directly.
--- net/netfilter/nft_byteorder.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/netfilter/nft_byteorder.c +7 -7
@@ -30,11 +30,11 @@ void nft_byteorder_eval(const struct nftconst struct nft_byteorder *priv =nft_expr_priv (expr);u32 *src = ®s->data[priv->sreg];u32 *dst = ®s->data[priv->dreg]; -union {u32 u32;u16 u16; } *s, *d; +u16 *s16, *d16;unsigned int i; - s = (void *)src; - d = (void *)dst; + s16 = (void *)src; + d16 = (void *)dst;switch (priv->size) {case 8 : {
@@ -61,11 +61,11 @@ void nft_byteorder_eval(const struct nftswitch (priv->op) {case NFT_BYTEORDER_NTOH :for (i =0 ; i < priv->len /4 ; i++) - d[i].u32 =ntohl ((__force __be32 )s[i].u32); + dst[i] =ntohl ((__force __be32 )src[i]);break ;case NFT_BYTEORDER_HTON :for (i =0 ; i < priv->len /4 ; i++) - d[i].u32 = (__force __u32 )htonl (s[i].u32); + dst[i] = (__force __u32 )htonl (src[i]);break ; }break ;
@@ -73,11 +73,11 @@ void nft_byteorder_eval(const struct nftswitch (priv->op) {case NFT_BYTEORDER_NTOH :for (i =0 ; i < priv->len /2 ; i++) - d[i].u16 =ntohs ((__force __be16 )s[i].u16); + d16[i] =ntohs ((__force __be16 )s16[i]);break ;case NFT_BYTEORDER_HTON :for (i =0 ; i < priv->len /2 ; i++) - d[i].u16 = (__force __u16 )htons (s[i].u16); + d16[i] = (__force __u16 )htons (s16[i]);break ; }break ;
Greg Kroah-Hartman
maintainerPATCH 383/532 wireguard: queueing: use saner cpu selection wrapping
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit 7387943fa35516f6f8017a3b0e9ce48a3bef9faa upstream.
Using % nr_cpumask_bits is slow and complicated, and not totally robust toward dynamic changes to CPU topologies. Rather than storing the next CPU in the round-robin, just store the last one, and also return that value. This simplifies the loop drastically into a much more common pattern.
--- drivers/net/wireguard/queueing.c | 1 + drivers/net/wireguard/queueing.h | 25 +++++++++++-------------- drivers/net/wireguard/receive.c | 2 +- drivers/net/wireguard/send.c | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-)
drivers/net/wireguard/queueing.c +1 -0
@@ -28,6 +28,7 @@ int wg_packet_queue_init(struct crypt_quint ret;memset (queue,0 ,sizeof (*queue)); + queue->last_cpu =-1 ; ret =ptr_ring_init (&queue->ring, len,GFP_KERNEL );if (ret)return ret;
drivers/net/wireguard/queueing.h +11 -14
@@ -119,20 +119,17 @@ static inline int wg_cpumask_choose_onlireturn cpu; } -/* This function is racy, in the sense that next is unlocked, so it could return -* the same CPU twice. A race-free version of this would be to instead store an -* atomic sequence number, do an increment-and-return, and then iterate through -* every possible CPU until we get to that index -- choose_cpu. However that's -* a bit slower, and it doesn't seem like this potential race actually -* introduces any performance loss, so we live with it. +/* This function is racy, in the sense that it's called while last_cpu is +* unlocked, so it could return the same CPU twice. Adding locking or using +* atomic sequence numbers is slower though, and the consequences of racing are +* harmless, so live with it. */ -static inline int wg_cpumask_next_online (int *next) +static inline int wg_cpumask_next_online (int *last_cpu) { -int cpu = *next; - -while (unlikely (!cpumask_test_cpu (cpu, cpu_online_mask))) - cpu =cpumask_next (cpu, cpu_online_mask) % nr_cpumask_bits; - *next =cpumask_next (cpu, cpu_online_mask) % nr_cpumask_bits; +int cpu =cpumask_next (*last_cpu, cpu_online_mask); +if (cpu >= nr_cpu_ids) + cpu =cpumask_first (cpu_online_mask); + *last_cpu = cpu;return cpu; }
@@ -161,7 +158,7 @@ static inline void wg_prev_queue_drop_pestatic inline int wg_queue_enqueue_per_device_and_peer (struct crypt_queue *device_queue,struct prev_queue *peer_queue, -struct sk_buff *skb,struct workqueue_struct *wq,int *next_cpu) +struct sk_buff *skb,struct workqueue_struct *wq) {int cpu;
@@ -175,7 +172,7 @@ static inline int wg_queue_enqueue_per_d/* Then we queue it up in the device queue, which consumes the * packet as soon as it can. */ - cpu =wg_cpumask_next_online (next_cpu); + cpu =wg_cpumask_next_online (&device_queue->last_cpu);if (unlikely (ptr_ring_produce_bh (&device_queue->ring, skb)))return -EPIPE ;queue_work_on (cpu, wq, &per_cpu_ptr (device_queue->worker, cpu)->work);
drivers/net/wireguard/receive.c +1 -1
@@ -531,7 +531,7 @@ static void wg_packet_consume_data(struc goto err; ret =wg_queue_enqueue_per_device_and_peer (&wg->decrypt_queue, &peer->rx_queue, skb, - wg->packet_crypt_wq, &wg->decrypt_queue.last_cpu); + wg->packet_crypt_wq);if (unlikely (ret == -EPIPE ))wg_queue_enqueue_per_peer_rx (skb,PACKET_STATE_DEAD );if (likely (!ret || ret == -EPIPE )) {
drivers/net/wireguard/send.c +1 -1
@@ -318,7 +318,7 @@ static void wg_packet_create_data(struct goto err; ret =wg_queue_enqueue_per_device_and_peer (&wg->encrypt_queue, &peer->tx_queue, first, - wg->packet_crypt_wq, &wg->encrypt_queue.last_cpu); + wg->packet_crypt_wq);if (unlikely (ret == -EPIPE ))wg_queue_enqueue_per_peer_tx (first,PACKET_STATE_DEAD ); err:
Greg Kroah-Hartman
maintainerPATCH 384/532 wireguard: netlink: send staged packets when setting initial private key
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit f58d0a9b4c6a7a5199c3af967e43cc8b654604d4 upstream.
Packets bound for peers can queue up prior to the device private key being set. For example, if persistent keepalive is set, a packet is queued up to be sent as soon as the device comes up. However, if the private key hasn't been set yet, the handshake message never sends, and no timer is armed to retry, since that would be pointless.
But, if a user later sets a private key, the expectation is that those queued packets, such as a persistent keepalive, are actually sent. So adjust the configuration logic to account for this edge case, and add a test case to make sure this works.
Maxim noticed this with a wg-quick(8) config to the tune of:
[Interface]
PostUp = wg set %i private-key somefile
[Peer]
PublicKey = ...
Endpoint = ...
PersistentKeepalive = 25Here, the private key gets set after the device comes up using a PostUp script, triggering the bug.
--- drivers/net/wireguard/netlink.c | 14 ++++++++----- tools/testing/selftests/wireguard/netns.sh | 30 +++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-)
drivers/net/wireguard/netlink.c +9 -5
@@ -546,6 +546,7 @@ static int wg_set_device(struct sk_buffu8 *private_key =nla_data (info->attrs[WGDEVICE_A_PRIVATE_KEY ]);u8 public_key[NOISE_PUBLIC_KEY_LEN ];struct wg_peer *peer, *temp; +bool send_staged_packets;if (!crypto_memneq (wg->static_identity.static_private, private_key,NOISE_PUBLIC_KEY_LEN ))
@@ -564,14 +565,17 @@ static int wg_set_device(struct sk_buff }down_write (&wg->static_identity.lock); -wg_noise_set_static_identity_private_key (&wg->static_identity, - private_key); -list_for_each_entry_safe (peer, temp, &wg->peer_list, - peer_list) { + send_staged_packets = !wg->static_identity.has_identity &&netif_running (wg->dev); +wg_noise_set_static_identity_private_key (&wg->static_identity, private_key); + send_staged_packets = send_staged_packets && wg->static_identity.has_identity; + +wg_cookie_checker_precompute_device_keys (&wg->cookie_checker); +list_for_each_entry_safe (peer, temp, &wg->peer_list, peer_list) {wg_noise_precompute_static_static (peer);wg_noise_expire_current_peer_keypairs (peer); +if (send_staged_packets) +wg_packet_send_staged_packets (peer); } -wg_cookie_checker_precompute_device_keys (&wg->cookie_checker);up_write (&wg->static_identity.lock); } skip_set_private_key:
tools/testing/selftests/wireguard/netns.sh +26 -4
@@ -502,10 +502,32 @@ n2 bash -c 'printf 0 > /proc/sys/net/ipv n1 ping -W 1 -c 1 192.168.241.2 [[ $(n2 wg show wg0 endpoints) == "$pub1 10.0.0.3:1" ]] -ip1 link del veth1 -ip1 link del veth3 -ip1 link del wg0 -ip2 link del wg0 +ip1 link del dev veth3 +ip1 link del dev wg0 +ip2 link del dev wg0 + +# Make sure persistent keep alives are sent when an adapter comes up +ip1 link add dev wg0 type wireguard +n1 wg set wg0 private-key <(echo "$key1") peer "$pub2" endpoint 10.0.0.1:1 persistent-keepalive 1 +read _ _ tx_bytes < <(n1 wg show wg0 transfer) +[[ $tx_bytes -eq 0 ]] +ip1 link set dev wg0 up +read _ _ tx_bytes < <(n1 wg show wg0 transfer) +[[ $tx_bytes -gt 0 ]] +ip1 link del dev wg0 +# This should also happen even if the private key is set later +ip1 link add dev wg0 type wireguard +n1 wg set wg0 peer "$pub2" endpoint 10.0.0.1:1 persistent-keepalive 1 +read _ _ tx_bytes < <(n1 wg show wg0 transfer) +[[ $tx_bytes -eq 0 ]] +ip1 link set dev wg0 up +read _ _ tx_bytes < <(n1 wg show wg0 transfer) +[[ $tx_bytes -eq 0 ]] +n1 wg set wg0 private-key <(echo "$key1") +read _ _ tx_bytes < <(n1 wg show wg0 transfer) +[[ $tx_bytes -gt 0 ]] +ip1 link del dev veth1 +ip1 link del dev wg0 # We test that Netlink/IPC is working properly by doing things that usually cause split responses ip0 link add dev wg0 type wireguard
Greg Kroah-Hartman
maintainerPATCH 385/532 tty: serial: fsl_lpuart: add earlycon for imx8ulp platform
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
commit e0edfdc15863ec80a1d9ac6e174dbccc00206dd0 upstream.
Add earlycon support for imx8ulp platform.
--- drivers/tty/serial/fsl_lpuart.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/fsl_lpuart.c +1 -0
@@ -2632,6 +2632,7 @@ OF_EARLYCON_DECLARE(lpuart, "fsl,vf610-lOF_EARLYCON_DECLARE (lpuart32,"fsl,ls1021a-lpuart" , lpuart32_early_console_setup);OF_EARLYCON_DECLARE (lpuart32,"fsl,ls1028a-lpuart" , ls1028a_early_console_setup);OF_EARLYCON_DECLARE (lpuart32,"fsl,imx7ulp-lpuart" , lpuart32_imx_early_console_setup); +OF_EARLYCON_DECLARE (lpuart32,"fsl,imx8ulp-lpuart" , lpuart32_imx_early_console_setup);OF_EARLYCON_DECLARE (lpuart32,"fsl,imx8qxp-lpuart" , lpuart32_imx_early_console_setup);EARLYCON_DECLARE (lpuart, lpuart_early_console_setup);EARLYCON_DECLARE (lpuart32, lpuart32_early_console_setup);
Greg Kroah-Hartman
maintainerPATCH 386/532 block/partition: fix signedness issue for Amiga partitions
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
commit 7eb1e47696aa231b1a567846bbe3a1e1befe1854 upstream.
Making 'blk' sector_t (i.e. 64 bit if LBD support is active) fails the 'blk>0' test in the partition block loop if a value of (signed int) -1 is used to mark the end of the partition block list.
Explicitly cast 'blk' to signed int to allow use of -1 to terminate the partition block linked list.
--- block/partitions/amiga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/amiga.c +1 -1
@@ -90,7 +90,7 @@ int amiga_partition(struct parsed_partit } blk =be32_to_cpu (rdb->rdb_PartitionList);put_dev_sector (sect); -for (part =1 ; blk>0 && part<=16 ; part++,put_dev_sector (sect)) { +for (part =1 ; (s32 ) blk>0 && part<=16 ; part++,put_dev_sector (sect)) {/* Read in terms partition table understands */ if (check_mul_overflow (blk, (sector_t ) blksize, &blk)) { pr_err("Dev %s: overflow calculating partition block %llu! Skipping partitions %u and beyond\n",
Greg Kroah-Hartman
maintainerPATCH 387/532 io_uring: Use io_schedule* in cqring wait
In reply to Greg Kroah-HartmanFrom: Andres Freund <[email protected]>
Commit 8a796565cec3601071cbbd27d6304e202019d014 upstream.
I observed poor performance of io_uring compared to synchronous IO. That turns out to be caused by deeper CPU idle states entered with io_uring, due to io_uring using plain schedule(), whereas synchronous IO uses io_schedule().
The losses due to this are substantial. On my cascade lake workstation, t/io_uring from the fio repository e.g. yields regressions between 20% and 40% with the following command:
./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0
This is repeatable with different filesystems, using raw block devices and using different block devices.
Use io_schedule_prepare() / io_schedule_finish() in io_cqring_wait_schedule() to address the difference.
After that using io_uring is on par or surpassing synchronous IO (using registered files etc makes it reliably win, but arguably is a less fair comparison).
There are other calls to schedule() in io_uring/, but none immediately jump out to be similarly situated, so I did not touch them. Similarly, it's possible that mutex_lock_io() should be used, but it's not clear if there are cases where that matters.
--- io_uring/io_uring.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
io_uring/io_uring.c +11 -3
@@ -7796,7 +7796,7 @@ static inline int io_cqring_wait_schedulstruct io_wait_queue *iowq, ktime_t *timeout) { - int ret; + int token, ret;/* make sure we run task_work before checking for signals */ ret =io_run_task_work_sig ();
@@ -7806,9 +7806,17 @@ static inline int io_cqring_wait_schedulif (test_bit (0 , &ctx->check_cq_overflow))return 1 ; +/* +* Use io_schedule_prepare/finish, so cpufreq can take into account +* that the task is waiting for IO - turns out to be important for low +* QD IO. +*/ + token =io_schedule_prepare (); + ret =1 ;if (!schedule_hrtimeout (timeout,HRTIMER_MODE_ABS )) -return -ETIME ; -return 1 ; + ret = -ETIME ; +io_schedule_finish (token); +return ret; }/*
Greg Kroah-Hartman
maintainerPATCH 388/532 io_uring: add reschedule point to handle_tw_list()
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
Commit f58680085478dd292435727210122960d38e8014 upstream.
If CONFIG_PREEMPT_NONE is set and the task_work chains are long, we could be running into issues blocking others for too long. Add a reschedule check in handle_tw_list(), and flush the ctx if we need to reschedule.
--- io_uring/io_uring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
io_uring/io_uring.c +5 -2
@@ -2217,9 +2217,12 @@ static void tctx_task_work(struct callba } req->io_task_work.func (req, &locked); node = next; +if (unlikely (need_resched ())) { +ctx_flush_and_put (ctx, &locked); + ctx =NULL ; +cond_resched (); + } }while (node); - -cond_resched (); }ctx_flush_and_put (ctx, &locked);
Greg Kroah-Hartman
maintainerPATCH 389/532 net: lan743x: Dont sleep in atomic context
In reply to Greg Kroah-HartmanFrom: Moritz Fischer <[email protected]>
commit 7a8227b2e76be506b2ac64d2beac950ca04892a5 upstream.
dev_set_rx_mode() grabs a spin_lock, and the lan743x implementation proceeds subsequently to go to sleep using readx_poll_timeout().
Introduce a helper wrapping the readx_poll_timeout_atomic() function and use it to replace the calls to readx_polL_timeout().
--- drivers/net/ethernet/microchip/lan743x_main.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +17 -4
@@ -83,6 +83,18 @@ static int lan743x_csr_light_reset(struc !(data & HW_CFG_LRST_), 100000, 10000000); } +static int lan743x_csr_wait_for_bit_atomic (struct lan743x_adapter *adapter, +int offset,u32 bit_mask, +int target_value,int udelay_min, +int udelay_max,int count) +{ +u32 data; + +return readx_poll_timeout_atomic (LAN743X_CSR_READ_OP , offset, data, + target_value == !!(data & bit_mask), + udelay_max, udelay_min * count); +} + static int lan743x_csr_wait_for_bit(struct lan743x_adapter *adapter, int offset, u32 bit_mask, int target_value, int usleep_min,
@@ -671,8 +683,8 @@ static int lan743x_dp_write(struct lan74u32 dp_sel;int i; -if (lan743x_csr_wait_for_bit (adapter,DP_SEL ,DP_SEL_DPRDY_ , -1 ,40 ,100 ,100 )) +if (lan743x_csr_wait_for_bit_atomic (adapter,DP_SEL ,DP_SEL_DPRDY_ , +1 ,40 ,100 ,100 ))return -EIO ; dp_sel =lan743x_csr_read (adapter,DP_SEL ); dp_sel &= ~DP_SEL_MASK_ ;
@@ -683,8 +695,9 @@ static int lan743x_dp_write(struct lan74lan743x_csr_write (adapter,DP_ADDR , addr + i);lan743x_csr_write (adapter,DP_DATA_0 , buf[i]);lan743x_csr_write (adapter,DP_CMD ,DP_CMD_WRITE_ ); -if (lan743x_csr_wait_for_bit (adapter,DP_SEL ,DP_SEL_DPRDY_ , -1 ,40 ,100 ,100 )) +if (lan743x_csr_wait_for_bit_atomic (adapter,DP_SEL , +DP_SEL_DPRDY_ , +1 ,40 ,100 ,100 ))return -EIO ; }
Greg Kroah-Hartman
maintainerPATCH 390/532 workqueue: clean up WORK_* constant types, clarify masking
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit afa4bb778e48d79e4a642ed41e3b4e0de7489a6c upstream.
Dave Airlie reports that gcc-13.1.1 has started complaining about some of the workqueue code in 32-bit arm builds:
kernel/workqueue.c: In function ‘get_work_pwq’:
kernel/workqueue.c:713:24: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
713 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK);
| ^[ ... a couple of other cases ... ]
and while it's not immediately clear exactly why gcc started complaining about it now, I suspect it's some C23-induced enum type handlign fixup in gcc-13 is the cause.
Whatever the reason for starting to complain, the code and data types are indeed disgusting enough that the complaint is warranted.
The wq code ends up creating various "helper constants" (like that WORK_STRUCT_WQ_DATA_MASK) using an enum type, which is all kinds of confused. The mask needs to be 'unsigned long', not some unspecified enum type.
To make matters worse, the actual "mask and cast to a pointer" is repeated a couple of times, and the cast isn't even always done to the right pointer, but - as the error case above - to a 'void *' with then the compiler finishing the job.
That's now how we roll in the kernel.
So create the masks using the proper types rather than some ambiguous enumeration, and use a nice helper that actually does the type conversion in one well-defined place.
Incidentally, this magically makes clang generate better code. That, admittedly, is really just a sign of clang having been seriously confused before, and cleaning up the typing unconfuses the compiler too.
--- include/linux/workqueue.h | 15 ++++++++------- kernel/workqueue.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-)
include/linux/workqueue.h +8 -7
@@ -68,7 +68,6 @@ enum {WORK_OFFQ_FLAG_BASE =WORK_STRUCT_COLOR_SHIFT , __WORK_OFFQ_CANCELING = WORK_OFFQ_FLAG_BASE, - WORK_OFFQ_CANCELING = (1 << __WORK_OFFQ_CANCELING),/* * When a work item is off queue, its high bits point to the last
@@ -79,12 +78,6 @@ enum {WORK_OFFQ_POOL_SHIFT =WORK_OFFQ_FLAG_BASE +WORK_OFFQ_FLAG_BITS ,WORK_OFFQ_LEFT =BITS_PER_LONG -WORK_OFFQ_POOL_SHIFT ,WORK_OFFQ_POOL_BITS =WORK_OFFQ_LEFT <=31 ?WORK_OFFQ_LEFT :31 , -WORK_OFFQ_POOL_NONE = (1LU <<WORK_OFFQ_POOL_BITS ) -1 , - -/* convenience constants */ -WORK_STRUCT_FLAG_MASK = (1UL <<WORK_STRUCT_FLAG_BITS ) -1 , -WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK , -WORK_STRUCT_NO_POOL = (unsigned long )WORK_OFFQ_POOL_NONE <<WORK_OFFQ_POOL_SHIFT ,/* bit mask for work_busy() return values */ WORK_BUSY_PENDING = 1 << 0,
@@ -94,6 +87,14 @@ enum { WORKER_DESC_LEN = 24, }; +/* Convenience constants - of type 'unsigned long', not 'enum'! */ +#define WORK_OFFQ_CANCELING (1ul << __WORK_OFFQ_CANCELING) +#define WORK_OFFQ_POOL_NONE ((1ul << WORK_OFFQ_POOL_BITS) - 1) +#define WORK_STRUCT_NO_POOL (WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT) + +#define WORK_STRUCT_FLAG_MASK ((1ul << WORK_STRUCT_FLAG_BITS) - 1) +#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK) +struct work_struct {atomic_long_t data;struct list_head entry;
kernel/workqueue.c +8 -5
@@ -697,12 +697,17 @@ static void clear_work_data(struct work_set_work_data (work,WORK_STRUCT_NO_POOL ,0 ); } +static inline struct pool_workqueue *work_struct_pwq (unsigned long data) +{ +return (struct pool_workqueue *)(data &WORK_STRUCT_WQ_DATA_MASK ); +} +static struct pool_workqueue *get_work_pwq (struct work_struct *work) {unsigned long data =atomic_long_read (&work->data);if (data &WORK_STRUCT_PWQ ) -return (void *)(data &WORK_STRUCT_WQ_DATA_MASK ); +return work_struct_pwq (data);else return NULL ; }
@@ -730,8 +735,7 @@ static struct worker_pool *get_work_poolassert_rcu_or_pool_mutex ();if (data &WORK_STRUCT_PWQ ) -return ((struct pool_workqueue *) - (data &WORK_STRUCT_WQ_DATA_MASK ))->pool; +return work_struct_pwq (data)->pool; pool_id = data >>WORK_OFFQ_POOL_SHIFT ;if (pool_id ==WORK_OFFQ_POOL_NONE )
@@ -752,8 +756,7 @@ static int get_work_pool_id(struct work_unsigned long data =atomic_long_read (&work->data);if (data &WORK_STRUCT_PWQ ) -return ((struct pool_workqueue *) - (data &WORK_STRUCT_WQ_DATA_MASK ))->pool->id; +return work_struct_pwq (data)->pool->id;return data >>WORK_OFFQ_POOL_SHIFT ; }
Greg Kroah-Hartman
maintainerPATCH 391/532 ksmbd: use ksmbd_req_buf_next() in ksmbd_smb2_check_message()
In reply to Greg Kroah-HartmanFrom: Ralph Boehme <[email protected]>
commit b83b27909e74d27796de19c802fbc3b65ab4ba9a upstream.
Use ksmbd_req_buf_next() in ksmbd_smb2_check_message().
--- fs/ksmbd/smb2misc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/ksmbd/smb2misc.c +2 -7
@@ -347,16 +347,11 @@ static int smb2_validate_credit_charge(sint ksmbd_smb2_check_message (struct ksmbd_work *work) { -struct smb2_pdu *pdu = work->request_buf; +struct smb2_pdu *pdu =ksmbd_req_buf_next (work);struct smb2_hdr *hdr = &pdu->hdr;int command;__u32 clc_len;/* calculated length */ -__u32 len =get_rfc1002_len (pdu); - -if (work->next_smb2_rcv_hdr_off) { - pdu =ksmbd_req_buf_next (work); - hdr = &pdu->hdr; - } +__u32 len =get_rfc1002_len (work->request_buf);if (le32_to_cpu (hdr->NextCommand) >0 ) len =le32_to_cpu (hdr->NextCommand);
Greg Kroah-Hartman
maintainerPATCH 392/532 ksmbd: validate command payload size
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit 2b9b8f3b68edb3d67d79962f02e26dbb5ae3808d upstream.
->StructureSize2 indicates command payload size. ksmbd should validate this size with rfc1002 length before accessing it.
This patch remove unneeded check and add the validation for this.
[ 8.912583] BUG: KASAN: slab-out-of-bounds in ksmbd_smb2_check_message+0x12a/0xc50 [ 8.913051] Read of size 2 at addr ffff88800ac7d92c by task kworker/0:0/7 ... [ 8.914967] Call Trace: [ 8.915126] <TASK> [ 8.915267] dump_stack_lvl+0x33/0x50 [ 8.915506] print_report+0xcc/0x620 [ 8.916558] kasan_report+0xae/0xe0 [ 8.917080] kasan_check_range+0x35/0x1b0 [ 8.917334] ksmbd_smb2_check_message+0x12a/0xc50 [ 8.917935] ksmbd_verify_smb_message+0xae/0xd0 [ 8.918223] handle_ksmbd_work+0x192/0x820 [ 8.918478] process_one_work+0x419/0x760 [ 8.918727] worker_thread+0x2a2/0x6f0 [ 8.919222] kthread+0x187/0x1d0 [ 8.919723] ret_from_fork+0x1f/0x30 [ 8.919954] </TASK>
--- fs/ksmbd/smb2misc.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
fs/ksmbd/smb2misc.c +12 -11
@@ -352,6 +352,7 @@ int ksmbd_smb2_check_message(struct ksmbint command;__u32 clc_len;/* calculated length */ __u32 len =get_rfc1002_len (work->request_buf); +__u32 req_struct_size;if (le32_to_cpu (hdr->NextCommand) >0 ) len =le32_to_cpu (hdr->NextCommand);
@@ -374,17 +375,9 @@ int ksmbd_smb2_check_message(struct ksmb }if (smb2_req_struct_sizes[command] != pdu->StructureSize2) { -if (command !=SMB2_OPLOCK_BREAK_HE && - (hdr->Status ==0 || pdu->StructureSize2 !=SMB2_ERROR_STRUCTURE_SIZE2_LE )) { -/* error packets have 9 byte structure size */ -ksmbd_debug (SMB , -"Illegal request size %u for command %d\n" , -le16_to_cpu (pdu->StructureSize2), command); -return 1 ; - }else if (command ==SMB2_OPLOCK_BREAK_HE && - hdr->Status ==0 && -le16_to_cpu (pdu->StructureSize2) !=OP_BREAK_STRUCT_SIZE_20 && -le16_to_cpu (pdu->StructureSize2) !=OP_BREAK_STRUCT_SIZE_21 ) { +if (command ==SMB2_OPLOCK_BREAK_HE && +le16_to_cpu (pdu->StructureSize2) !=OP_BREAK_STRUCT_SIZE_20 && +le16_to_cpu (pdu->StructureSize2) !=OP_BREAK_STRUCT_SIZE_21 ) {/* special case for SMB2.1 lease break message */ ksmbd_debug(SMB, "Illegal request size %d for oplock break\n",
@@ -393,6 +386,14 @@ int ksmbd_smb2_check_message(struct ksmb } } + req_struct_size =le16_to_cpu (pdu->StructureSize2) + + __SMB2_HEADER_STRUCTURE_SIZE; +if (command ==SMB2_LOCK_HE ) + req_struct_size -=sizeof (struct smb2_lock_element ); + +if (req_struct_size > len +1 ) +return 1 ; +if (smb2_calc_size (hdr, &clc_len))return 1 ;
Greg Kroah-Hartman
maintainerPATCH 393/532 ksmbd: fix out-of-bound read in smb2_write
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit 5fe7f7b78290638806211046a99f031ff26164e1 upstream.
ksmbd_smb2_check_message doesn't validate hdr->NextCommand. If ->NextCommand is bigger than Offset + Length of smb2 write, It will allow oversized smb2 write length. It will cause OOB read in smb2_write.
--- fs/ksmbd/smb2misc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ksmbd/smb2misc.c +9 -3
@@ -352,10 +352,16 @@ int ksmbd_smb2_check_message(struct ksmbint command;__u32 clc_len;/* calculated length */ __u32 len =get_rfc1002_len (work->request_buf); -__u32 req_struct_size; +__u32 req_struct_size, next_cmd =le32_to_cpu (hdr->NextCommand); -if (le32_to_cpu (hdr->NextCommand) >0 ) - len =le32_to_cpu (hdr->NextCommand); +if ((u64 )work->next_smb2_rcv_hdr_off + next_cmd > len) { +pr_err ("next command(%u) offset exceeds smb msg size\n" , + next_cmd); +return 1 ; + } + +if (next_cmd >0 ) + len = next_cmd;else if (work->next_smb2_rcv_hdr_off) len -= work->next_smb2_rcv_hdr_off;
Greg Kroah-Hartman
maintainerPATCH 394/532 ksmbd: validate session id and tree id in the compound request
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit 5005bcb4219156f1bf7587b185080ec1da08518e upstream.
This patch validate session id and tree id in compound request. If first operation in the compound is SMB2 ECHO request, ksmbd bypass session and tree validation. So work->sess and work->tcon could be NULL. If secound request in the compound access work->sess or tcon, It cause NULL pointer dereferecing error.
--- fs/ksmbd/server.c | 33 ++++++++++++++++++++------------- fs/ksmbd/smb2pdu.c | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 18 deletions(-)
fs/ksmbd/server.c +20 -13
@@ -184,24 +184,31 @@ static void __handle_ksmbd_work(struct k goto send; } -if (conn->ops->check_user_session) { - rc = conn->ops->check_user_session (work); -if (rc <0 ) { - command = conn->ops->get_cmd_val (work); - conn->ops->set_rsp_status (work, -STATUS_USER_SESSION_DELETED ); - goto send; - }else if (rc >0 ) { - rc = conn->ops->get_ksmbd_tcon (work); + do { + if (conn->ops->check_user_session) { + rc = conn->ops->check_user_session(work); if (rc < 0) { - conn->ops->set_rsp_status (work, -STATUS_NETWORK_NAME_DELETED ); + if (rc == -EINVAL) + conn->ops->set_rsp_status(work, + STATUS_INVALID_PARAMETER); + else + conn->ops->set_rsp_status(work, + STATUS_USER_SESSION_DELETED); goto send; + } else if (rc > 0) { + rc = conn->ops->get_ksmbd_tcon(work); + if (rc < 0) { + if (rc == -EINVAL) + conn->ops->set_rsp_status(work, + STATUS_INVALID_PARAMETER); + else + conn->ops->set_rsp_status(work, + STATUS_NETWORK_NAME_DELETED); + goto send; + } } } - } - do { rc = __process_request(work, conn, &command); if (rc == SERVER_HANDLER_ABORT) break;
fs/ksmbd/smb2pdu.c +39 -5
78 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 395/532 drm/panel: simple: Add connector_type for innolux_at043tn24
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
[ Upstream commit 2c56a751845ddfd3078ebe79981aaaa182629163 ]
The innolux at043tn24 display is a parallel LCD. Pass the 'connector_type' information to avoid the following warning:
panel-simple panel: Specify missing connector_type
--- drivers/gpu/drm/panel/panel-simple.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-simple.c +1 -0
@@ -2469,6 +2469,7 @@ static const struct panel_desc innolux_at043tn24 = { .height = 54, }, .bus_format = MEDIA_BUS_FMT_RGB888_1X24, + .connector_type = DRM_MODE_CONNECTOR_DPI, .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 396/532 drm/bridge: ti-sn65dsi86: Fix auxiliary bus lifetime
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 7aa83fbd712a6f08ffa67890061f26d140c2a84f ]
Memory for the "struct device" for any given device isn't supposed to be released until the device's release() is called. This is important because someone might be holding a kobject reference to the "struct device" and might try to access one of its members even after any other cleanup/uninitialization has happened.
Code analysis of ti-sn65dsi86 shows that this isn't quite right. When the code was written, it was believed that we could rely on the fact that the child devices would all be freed before the parent devices and thus we didn't need to worry about a release() function. While I still believe that the parent's "struct device" is guaranteed to outlive the child's "struct device" (because the child holds a kobject reference to the parent), the parent's "devm" allocated memory is a different story. That appears to be freed much earlier.
Let's make this better for ti-sn65dsi86 by allocating each auxiliary with kzalloc and then free that memory in the release().
--- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 33 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +21 -12
@@ -147,9 +147,9 @@* each other's read-modify-write. */ struct ti_sn65dsi86 { -struct auxiliary_device bridge_aux; -struct auxiliary_device gpio_aux; -struct auxiliary_device aux_aux; +struct auxiliary_device *bridge_aux; +struct auxiliary_device *gpio_aux; +struct auxiliary_device *aux_aux;struct device *dev;struct regmap *regmap;
@@ -412,27 +412,34 @@ static void ti_sn65dsi86_delete_aux(void *data)auxiliary_device_delete (data); } -/* -* AUX bus docs say that a non-NULL release is mandatory, but it makes no -* sense for the model used here where all of the aux devices are allocated -* in the single shared structure. We'll use this noop as a workaround. -*/ -static void ti_sn65dsi86_noop (struct device *dev) {} +static void ti_sn65dsi86_aux_device_release (struct device *dev) +{ + struct auxiliary_device *aux = container_of(dev, struct auxiliary_device, dev); + +kfree (aux); +}static int ti_sn65dsi86_add_aux_device (struct ti_sn65dsi86 *pdata, -struct auxiliary_device *aux, +struct auxiliary_device **aux_out,const char *name) {struct device *dev = pdata->dev; +struct auxiliary_device *aux;int ret; + aux =kzalloc (sizeof (*aux),GFP_KERNEL ); +if (!aux) +return -ENOMEM ; + aux->name = name; aux->dev.parent = dev; - aux->dev.release = ti_sn65dsi86_noop; + aux->dev.release = ti_sn65dsi86_aux_device_release;device_set_of_node_from_dev (&aux->dev, dev); ret =auxiliary_device_init (aux); -if (ret) +if (ret) { +kfree (aux);return ret; + } ret =devm_add_action_or_reset (dev, ti_sn65dsi86_uninit_aux, aux);if (ret)return ret;
@@ -441,6 +448,8 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,if (ret)return ret; ret =devm_add_action_or_reset (dev, ti_sn65dsi86_delete_aux, aux); +if (!ret) + *aux_out = aux;return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 397/532 drm/panel: simple: Add Powertip PH800480T013 drm_display_mode flags
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 1c519980aced3da1fae37c1339cf43b24eccdee7 ]
Add missing drm_display_mode DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC flags. Those are used by various bridges in the pipeline to correctly configure its sync signals polarity.
--- drivers/gpu/drm/panel/panel-simple.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panel/panel-simple.c +1 -0
@@ -3651,6 +3651,7 @@ static const struct drm_display_mode powertip_ph800480t013_idf02_mode = { .vsync_start = 480 + 49, .vsync_end = 480 + 49 + 2, .vtotal = 480 + 49 + 2 + 22, + .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, };static const struct panel_desc powertip_ph800480t013_idf02 = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 398/532 igc: Remove delay during TX ring configuration
In reply to Greg Kroah-HartmanFrom: Muhammad Husaini Zulkifli <[email protected]>
[ Upstream commit cca28ceac7c7857bc2d313777017585aef00bcc4 ]
Remove unnecessary delay during the TX ring configuration. This will cause delay, especially during link down and link up activity.
Furthermore, old SKUs like as I225 will call the reset_adapter to reset the controller during TSN mode Gate Control List (GCL) setting. This will add more time to the configuration of the real-time use case.
It doesn't mentioned about this delay in the Software User Manual. It might have been ported from legacy code I210 in the past.
--- drivers/net/ethernet/intel/igc/igc_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +0 -1
@@ -708,7 +708,6 @@ static void igc_configure_tx_ring(struct igc_adapter *adapter,/* disable the queue */ wr32 (IGC_TXDCTL (reg_idx),0 );wrfl (); -mdelay (10 );wr32 (IGC_TDLEN (reg_idx), ring->count *sizeof (union igc_adv_tx_desc ));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 399/532 net/mlx5e: fix double free in mlx5e_destroy_flow_table
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 884abe45a9014d0de2e6edb0630dfd64f23f1d1b ]
In function accel_fs_tcp_create_groups(), when the ft->g memory is successfully allocated but the 'in' memory fails to be allocated, the memory pointed to by ft->g is released once. And in function accel_fs_tcp_create_table, mlx5e_destroy_flow_table is called to release the memory pointed to by ft->g again. This will cause double free problem.
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c +1 -0
@@ -194,6 +194,7 @@ static int accel_fs_tcp_create_groups(struct mlx5e_flow_table *ft, in =kvzalloc (inlen,GFP_KERNEL );if (!in || !ft->g) {kfree (ft->g); + ft->g =NULL ;kvfree (in);return -ENOMEM ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 400/532 net/mlx5e: fix memory leak in mlx5e_ptp_open
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit d543b649ffe58a0cb4b6948b3305069c5980a1fa ]
When kvzalloc_node or kvzalloc failed in mlx5e_ptp_open, the memory pointed by "c" or "cparams" is not freed, which can lead to a memory leak. Fix by freeing the array in the error path.
--- drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +4 -2
@@ -676,8 +676,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params, c =kvzalloc_node (sizeof (*c),GFP_KERNEL ,dev_to_node (mlx5_core_dma_dev (mdev))); cparams =kvzalloc (sizeof (*cparams),GFP_KERNEL ); -if (!c || !cparams) -return -ENOMEM ; +if (!c || !cparams) { + err = -ENOMEM ; + goto err_free; + } c->priv = priv; c->mdev = priv->mdev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 401/532 net/mlx5e: Check for NOT_READY flag state after locking
In reply to Greg Kroah-HartmanFrom: Vlad Buslov <[email protected]>
[ Upstream commit 65e64640e97c0f223e77f9ea69b5a46186b93470 ]
Currently the check for NOT_READY flag is performed before obtaining the necessary lock. This opens a possibility for race condition when the flow is concurrently removed from unready_flows list by the workqueue task, which causes a double-removal from the list and a crash[0]. Fix the issue by moving the flag check inside the section protected by uplink_priv->unready_flows_lock mutex.
[0]:
[44376.389654] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] SMP [44376.391665] CPU: 7 PID: 59123 Comm: tc Not tainted 6.4.0-rc4+ #1 [44376.392984] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [44376.395342] RIP: 0010:mlx5e_tc_del_fdb_flow+0xb3/0x340 [mlx5_core] [44376.396857] Code: 00 48 8b b8 68 ce 02 00 e8 8a 4d 02 00 4c 8d a8 a8 01 00 00 4c 89 ef e8 8b 79 88 e1 48 8b 83 98 06 00 00 48 8b 93 90 06 00 00 <48> 89 42 08 48 89 10 48 b8 00 01 00 00 00 00 ad de 48 89 83 90 06 [44376.399167] RSP: 0018:ffff88812cc97570 EFLAGS: 00010246 [44376.399680] RAX: dead000000000122 RBX: ffff8881088e3800 RCX: ffff8881881bac00 [44376.400337] RDX: dead000000000100 RSI: ffff88812cc97500 RDI: ffff8881242f71b0 [44376.401001] RBP: ffff88811cbb0940 R08: 0000000000000400 R09: 0000000000000001 [44376.401663] R10: 0000000000000001 R11: 0000000000000000 R12: ffff88812c944000 [44376.402342] R13: ffff8881242f71a8 R14: ffff8881222b4000 R15: 0000000000000000 [44376.402999] FS: 00007f0451104800(0000) GS:ffff88852cb80000(0000) knlGS:0000000000000000 [44376.403787] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [44376.404343] CR2: 0000000000489108 CR3: 0000000123a79003 CR4: 0000000000370ea0 [44376.405004] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [44376.405665] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [44376.406339] Call Trace: [44376.406651] <TASK> [44376.406939] ? die_addr+0x33/0x90 [44376.407311] ? exc_general_protection+0x192/0x390 [44376.407795] ? asm_exc_general_protection+0x22/0x30 [44376.408292] ? mlx5e_tc_del_fdb_flow+0xb3/0x340 [mlx5_core] [44376.408876] __mlx5e_tc_del_fdb_peer_flow+0xbc/0xe0 [mlx5_core] [44376.409482] mlx5e_tc_del_flow+0x42/0x210 [mlx5_core] [44376.410055] mlx5e_flow_put+0x25/0x50 [mlx5_core] [44376.410529] mlx5e_delete_flower+0x24b/0x350 [mlx5_core] [44376.411043] tc_setup_cb_reoffload+0x22/0x80 [44376.411462] fl_reoffload+0x261/0x2f0 [cls_flower] [44376.411907] ? mlx5e_rep_indr_setup_ft_cb+0x160/0x160 [mlx5_core] [44376.412481] ? mlx5e_rep_indr_setup_ft_cb+0x160/0x160 [mlx5_core] [44376.413044] tcf_block_playback_offloads+0x76/0x170 [44376.413497] tcf_block_unbind+0x7b/0xd0 [44376.413881] tcf_block_setup+0x17d/0x1c0 [44376.414269] tcf_block_offload_cmd.isra.0+0xf1/0x130 [44376.414725] tcf_block_offload_unbind+0x43/0x70 [44376.415153] __tcf_block_put+0x82/0x150 [44376.415532] ingress_destroy+0x22/0x30 [sch_ingress] [44376.415986] qdisc_destroy+0x3b/0xd0 [44376.416343] qdisc_graft+0x4d0/0x620 [44376.416706] tc_get_qdisc+0x1c9/0x3b0 [44376.417074] rtnetlink_rcv_msg+0x29c/0x390 [44376.419978] ? rep_movs_alternative+0x3a/0xa0 [44376.420399] ? rtnl_calcit.isra.0+0x120/0x120 [44376.420813] netlink_rcv_skb+0x54/0x100 [44376.421192] netlink_unicast+0x1f6/0x2c0 [44376.421573] netlink_sendmsg+0x232/0x4a0 [44376.421980] sock_sendmsg+0x38/0x60 [44376.422328] ____sys_sendmsg+0x1d0/0x1e0 [44376.422709] ? copy_msghdr_from_user+0x6d/0xa0 [44376.423127] ___sys_sendmsg+0x80/0xc0 [44376.423495] ? ___sys_recvmsg+0x8b/0xc0 [44376.423869] __sys_sendmsg+0x51/0x90 [44376.424226] do_syscall_64+0x3d/0x90 [44376.424587] entry_SYSCALL_64_after_hwframe+0x46/0xb0 [44376.425046] RIP: 0033:0x7f045134f887 [44376.425403] Code: 0a 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 [44376.426914] RSP: 002b:00007ffd63a82b98 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [44376.427592] RAX: ffffffffffffffda RBX: 000000006481955f RCX: 00007f045134f887 [44376.428195] RDX: 0000000000000000 RSI: 00007ffd63a82c00 RDI: 0000000000000003 [44376.428796] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 [44376.429404] R10: 00007f0451208708 R11: 0000000000000246 R12: 0000000000000001 [44376.430039] R13: 0000000000409980 R14: 000000000047e538 R15: 0000000000485400 [44376.430644] </TASK> [44376.430907] Modules linked in: mlx5_ib mlx5_core act_mirred act_tunnel_key cls_flower vxlan dummy sch_ingress openvswitch nsh rpcrdma rdma_ucm ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm ib_uverbs ib_core xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink xt_addrtype iptable_nat nf_nat br_netfilter rpcsec_g ss_krb5 auth_rpcgss oid_registry overlay zram zsmalloc fuse [last unloaded: mlx5_core] [44376.433936] ---[ end trace 0000000000000000 ]--- [44376.434373] RIP: 0010:mlx5e_tc_del_fdb_flow+0xb3/0x340 [mlx5_core] [44376.434951] Code: 00 48 8b b8 68 ce 02 00 e8 8a 4d 02 00 4c 8d a8 a8 01 00 00 4c 89 ef e8 8b 79 88 e1 48 8b 83 98 06 00 00 48 8b 93 90 06 00 00 <48> 89 42 08 48 89 10 48 b8 00 01 00 00 00 00 ad de 48 89 83 90 06 [44376.436452] RSP: 0018:ffff88812cc97570 EFLAGS: 00010246 [44376.436924] RAX: dead000000000122 RBX: ffff8881088e3800 RCX: ffff8881881bac00 [44376.437530] RDX: dead000000000100 RSI: ffff88812cc97500 RDI: ffff8881242f71b0 [44376.438179] RBP: ffff88811cbb0940 R08: 0000000000000400 R09: 0000000000000001 [44376.438786] R10: 0000000000000001 R11: 0000000000000000 R12: ffff88812c944000 [44376.439393] R13: ffff8881242f71a8 R14: ffff8881222b4000 R15: 0000000000000000 [44376.439998] FS: 00007f0451104800(0000) GS:ffff88852cb80000(0000) knlGS:0000000000000000 [44376.440714] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [44376.441225] CR2: 0000000000489108 CR3: 0000000123a79003 CR4: 0000000000370ea0 [44376.441843] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [44376.442471] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +3 -3
@@ -1282,7 +1282,8 @@ static void remove_unready_flow(struct mlx5e_tc_flow *flow) uplink_priv = &rpriv->uplink_priv;mutex_lock (&uplink_priv->unready_flows_lock); -unready_flow_del (flow); +if (flow_flag_test (flow,NOT_READY )) +unready_flow_del (flow);mutex_unlock (&uplink_priv->unready_flows_lock); }
@@ -1525,8 +1526,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, esw_attr = attr->esw_attr;mlx5e_put_flow_tunnel_id (flow); -if (flow_flag_test (flow,NOT_READY )) -remove_unready_flow (flow); +remove_unready_flow (flow);if (mlx5e_is_offloaded_flow (flow)) {if (flow_flag_test (flow,SLOW ))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 402/532 igc: set TP bit in supported and advertising fields of ethtool_link_ksettings
In reply to Greg Kroah-HartmanFrom: Prasad Koya <[email protected]>
[ Upstream commit 9ac3fc2f42e5ffa1e927dcbffb71b15fa81459e2 ]
set TP bit in the 'supported' and 'advertising' fields. i225/226 parts only support twisted pair copper.
--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/igc/igc_ethtool.c +2 -0
@@ -1701,6 +1701,8 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,/* twisted pair */ cmd->base.port =PORT_TP ; cmd->base.phy_address = hw->phy.addr; +ethtool_link_ksettings_add_link_mode (cmd, supported,TP ); +ethtool_link_ksettings_add_link_mode (cmd, advertising,TP );/* advertising link modes */ if (hw->phy.autoneg_advertised &ADVERTISE_10_HALF )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 403/532 igc: Handle PPS start time programming for past time values
In reply to Greg Kroah-HartmanFrom: Aravindhan Gunasekaran <[email protected]>
[ Upstream commit 84a192e46106355de1a314d709e657231d4b1026 ]
I225/6 hardware can be programmed to start PPS output once the time in Target Time registers is reached. The time programmed in these registers should always be into future. Only then PPS output is triggered when SYSTIM register reaches the programmed value. There are two modes in i225/6 hardware to program PPS, pulse and clock mode.
There were issues reported where PPS is not generated when start time is in past.
Example 1, "echo 0 0 0 2 0 > /sys/class/ptp/ptp0/period"
In the current implementation, a value of '0' is programmed into Target time registers and PPS output is in pulse mode. Eventually an interrupt which is triggered upon SYSTIM register reaching Target time is not fired. Thus no PPS output is generated.
Example 2, "echo 0 0 0 1 0 > /sys/class/ptp/ptp0/period"
Above case, a value of '0' is programmed into Target time registers and PPS output is in clock mode. Here, HW tries to catch-up the current time by incrementing Target Time register. This catch-up time seem to vary according to programmed PPS period time as per the HW design. In my experiments, the delay ranged between few tens of seconds to few minutes. The PPS output is only generated after the Target time register reaches current time.
In my experiments, I also observed PPS stopped working with below test and could not recover until module is removed and loaded again.
1) echo 0 <future time> 0 1 0 > /sys/class/ptp/ptp1/period
2) echo 0 0 0 1 0 > /sys/class/ptp/ptp1/period
3) echo 0 0 0 1 0 > /sys/class/ptp/ptp1/period
After this PPS did not work even if i re-program with proper values. I could only get this back working by reloading the driver.
This patch takes care of calculating and programming appropriate future time value into Target Time registers.
--- drivers/net/ethernet/intel/igc/igc_ptp.c | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igc/igc_ptp.c +22 -3
@@ -357,16 +357,35 @@ static int igc_ptp_feature_enable_i225(struct ptp_clock_info *ptp, tsim &= ~IGC_TSICR_TT0 ; }if (on) { +struct timespec64 safe_start;int i = rq->perout.index;igc_pin_perout (igc, i, pin, use_freq); - igc->perout[i].start.tv_sec = rq->perout.start.sec; +igc_ptp_read (igc, &safe_start); + +/* PPS output start time is triggered by Target time(TT) +* register. Programming any past time value into TT +* register will cause PPS to never start. Need to make +* sure we program the TT register a time ahead in +* future. There isn't a stringent need to fire PPS out +* right away. Adding +2 seconds should take care of +* corner cases. Let's say if the SYSTIML is close to +* wrap up and the timer keeps ticking as we program the +* register, adding +2seconds is safe bet. +*/ + safe_start.tv_sec +=2 ; + +if (rq->perout.start.sec < safe_start.tv_sec) + igc->perout[i].start.tv_sec = safe_start.tv_sec; +else + igc->perout[i].start.tv_sec = rq->perout.start.sec; igc->perout[i].start.tv_nsec = rq->perout.start.nsec; igc->perout[i].period.tv_sec = ts.tv_sec; igc->perout[i].period.tv_nsec = ts.tv_nsec; -wr32 (trgttimh, rq->perout.start.sec); +wr32 (trgttimh, (u32 )igc->perout[i].start.tv_sec);/* For now, always select timer 0 as source. */ -wr32 (trgttiml, rq->perout.start.nsec |IGC_TT_IO_TIMER_SEL_SYSTIM0 ); +wr32 (trgttiml, (u32)(igc->perout[i].start.tv_nsec | +IGC_TT_IO_TIMER_SEL_SYSTIM0 ));if (use_freq)wr32 (freqout, ns); tsauxc |= tsauxc_mask;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 404/532 scsi: qla2xxx: Fix error code in qla2x00_start_sp()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e579b007eff3ff8d29d59d16214cd85fb9e573f7 ]
This should be negative -EAGAIN instead of positive. The callers treat non-zero error codes the same so it doesn't really impact runtime beyond some trivial differences to debug output.
--- drivers/scsi/qla2xxx/qla_iocb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +1 -1
@@ -3898,7 +3898,7 @@ qla2x00_start_sp(srb_t *sp) pkt =__qla2x00_alloc_iocbs (sp->qpair, sp);if (!pkt) { - rval =EAGAIN ; + rval = -EAGAIN ;ql_log (ql_log_warn, vha,0x700c ,"qla2x00_alloc_iocbs failed.\n" ); goto done;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 405/532 bpf: Fix max stack depth check for async callbacks
In reply to Greg Kroah-HartmanFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 5415ccd50a8620c8cbaa32d6f18c946c453566f5 ]
The check_max_stack_depth pass happens after the verifier's symbolic execution, and attempts to walk the call graph of the BPF program, ensuring that the stack usage stays within bounds for all possible call chains. There are two cases to consider: bpf_pseudo_func and bpf_pseudo_call. In the former case, the callback pointer is loaded into a register, and is assumed that it is passed to some helper later which calls it (however there is no way to be sure), but the check remains conservative and accounts the stack usage anyway. For this particular case, asynchronous callbacks are skipped as they execute asynchronously when their corresponding event fires.
The case of bpf_pseudo_call is simpler and we know that the call is definitely made, hence the stack depth of the subprog is accounted for.
However, the current check still skips an asynchronous callback even if a bpf_pseudo_call was made for it. This is erroneous, as it will miss accounting for the stack usage of the asynchronous callback, which can be used to breach the maximum stack depth limit.
Fix this by only skipping asynchronous callbacks when the instruction is not a pseudo call to the subprog.
--- kernel/bpf/verifier.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +3 -2
@@ -3765,8 +3765,9 @@ static int check_max_stack_depth(struct bpf_verifier_env *env)verbose (env,"verifier bug. subprog has tail_call and async cb\n" );return -EFAULT ; } -/* async callbacks don't increase bpf prog stack size */ -continue ; +/* async callbacks don't increase bpf prog stack size unless called directly */ +if (!bpf_pseudo_call (insn + i)) +continue ; } i = next_insn;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 406/532 net: mvneta: fix txq_map in case of txq_number==1
In reply to Greg Kroah-HartmanFrom: Klaus Kudielka <[email protected]>
[ Upstream commit 21327f81db6337c8843ce755b01523c7d3df715b ]
If we boot with mvneta.txq_number=1, the txq_map is set incorrectly:MVNETA_CPU_TXQ_ACCESS(1) refers to TX queue 1, but only TX queue 0 is initialized. Fix this.
--- drivers/net/ethernet/marvell/mvneta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvneta.c +2 -2
@@ -1474,7 +1474,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)*/ if (txq_number ==1 ) txq_map = (cpu == pp->rxq_def) ? -MVNETA_CPU_TXQ_ACCESS (1 ) :0 ; +MVNETA_CPU_TXQ_ACCESS (0 ) :0 ; }else { txq_map =MVNETA_CPU_TXQ_ACCESS_ALL_MASK ;
@@ -4185,7 +4185,7 @@ static void mvneta_percpu_elect(struct mvneta_port *pp)*/ if (txq_number ==1 ) txq_map = (cpu == elected_cpu) ? -MVNETA_CPU_TXQ_ACCESS (1 ) :0 ; +MVNETA_CPU_TXQ_ACCESS (0 ) :0 ;else txq_map =mvreg_read (pp,MVNETA_CPU_MAP (cpu)) &MVNETA_CPU_TXQ_ACCESS_ALL_MASK ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 407/532 net/sched: cls_fw: Fix improper refcount update leads to use-after-free
In reply to Greg Kroah-HartmanFrom: M A Ramdhan <[email protected]>
[ Upstream commit 0323bce598eea038714f941ce2b22541c46d488f ]
In the event of a failure in tcf_change_indev(), fw_set_parms() will immediately return an error after incrementing or decrementing reference counter in tcf_bind_filter(). If attacker can control reference counter to zero and make reference freed, leading to use after free.
In order to prevent this, move the point of possible failure above the point where the TC_FW_CLASSID is handled.
Message-ID: <[email protected]>
--- net/sched/cls_fw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/sched/cls_fw.c +5 -5
@@ -210,11 +210,6 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,if (err <0 )return err; -if (tb[TCA_FW_CLASSID ]) { - f->res.classid =nla_get_u32 (tb[TCA_FW_CLASSID ]); -tcf_bind_filter (tp, &f->res, base); - } -if (tb[TCA_FW_INDEV ]) {int ret; ret =tcf_change_indev (net, tb[TCA_FW_INDEV ], extack);
@@ -231,6 +226,11 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, }else if (head->mask !=0xFFFFFFFF )return err; +if (tb[TCA_FW_CLASSID ]) { + f->res.classid =nla_get_u32 (tb[TCA_FW_CLASSID ]); +tcf_bind_filter (tp, &f->res, base); + } +return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 408/532 gve: Set default duplex configuration to full
In reply to Greg Kroah-HartmanFrom: Junfeng Guo <[email protected]>
[ Upstream commit 0503efeadbf6bb8bf24397613a73b67e665eac5f ]
Current duplex mode was unset in the driver, resulting in the default parameter being set to 0, which corresponds to half duplex. It might mislead users to have incorrect expectation about the driver's transmission capabilities.
Set the default duplex configuration to full, as the driver runs in full duplex mode at this point.
Message-ID: <[email protected]>
--- drivers/net/ethernet/google/gve/gve_ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/google/gve/gve_ethtool.c +3 -0
@@ -532,6 +532,9 @@ static int gve_get_link_ksettings(struct net_device *netdev, err =gve_adminq_report_link_speed (priv); cmd->base.speed = priv->link_speed; + + cmd->base.duplex =DUPLEX_FULL ; +return err; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 409/532 ionic: remove WARN_ON to prevent panic_on_warn
In reply to Greg Kroah-HartmanFrom: Nitya Sunkad <[email protected]>
[ Upstream commit abfb2a58a5377ebab717d4362d6180f901b6e5c1 ]
Remove unnecessary early code development check and the WARN_ON that it uses. The irq alloc and free paths have long been cleaned up and this check shouldn't have stuck around so long.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +0 -5
@@ -451,11 +451,6 @@ static void ionic_qcqs_free(struct ionic_lif *lif)static void ionic_link_qcq_interrupts (struct ionic_qcq *src_qcq,struct ionic_qcq *n_qcq) { -if (WARN_ON (n_qcq->flags &IONIC_QCQ_F_INTR )) { -ionic_intr_free (n_qcq->cq.lif->ionic, n_qcq->intr.index); - n_qcq->flags &= ~IONIC_QCQ_F_INTR ; - } - n_qcq->intr.vector = src_qcq->intr.vector; n_qcq->intr.index = src_qcq->intr.index; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 410/532 net: bgmac: postpone turning IRQs off to avoid SoC hangs
In reply to Greg Kroah-HartmanFrom: Rafał Miłecki <[email protected]>
[ Upstream commit e7731194fdf085f46d58b1adccfddbd0dfee4873 ]
Turning IRQs off is done by accessing Ethernet controller registers. That can't be done until device's clock is enabled. It results in a SoC hang otherwise.
This bug remained unnoticed for years as most bootloaders keep all Ethernet interfaces turned on. It seems to only affect a niche SoC family BCM47189. It has two Ethernet controllers but CFE bootloader uses only the first one.
--- drivers/net/ethernet/broadcom/bgmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +2 -2
@@ -1492,8 +1492,6 @@ int bgmac_enet_probe(struct bgmac *bgmac) bgmac->in_init = true; -bgmac_chip_intrs_off (bgmac); - net_dev->irq = bgmac->irq;SET_NETDEV_DEV (net_dev, bgmac->dev);dev_set_drvdata (bgmac->dev, bgmac);
@@ -1511,6 +1509,8 @@ int bgmac_enet_probe(struct bgmac *bgmac)*/ bgmac_clk_enable (bgmac,0 ); +bgmac_chip_intrs_off (bgmac); +/* This seems to be fixing IRQ by assigning OOB #6 to the core */ if (!(bgmac->feature_flags &BGMAC_FEAT_IDM_MASK )) {if (bgmac->feature_flags &BGMAC_FEAT_IRQ_ID_OOB_6 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 411/532 net: prevent skb corruption on frag list segmentation
In reply to Greg Kroah-HartmanFrom: Paolo Abeni <[email protected]>
[ Upstream commit c329b261afe71197d9da83c1f18eb45a7e97e089 ]
Ian reported several skb corruptions triggered by rx-gro-list, collecting different oops alike:
[ 62.624003] BUG: kernel NULL pointer dereference, address: 00000000000000c0 [ 62.631083] #PF: supervisor read access in kernel mode [ 62.636312] #PF: error_code(0x0000) - not-present page [ 62.641541] PGD 0 P4D 0 [ 62.644174] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 62.648629] CPU: 1 PID: 913 Comm: napi/eno2-79 Not tainted 6.4.0 #364 [ 62.655162] Hardware name: Supermicro Super Server/A2SDi-12C-HLN4F, BIOS 1.7a 10/13/2022 [ 62.663344] RIP: 0010:__udp_gso_segment (./include/linux/skbuff.h:2858 ./include/linux/udp.h:23 net/ipv4/udp_offload.c:228 net/ipv4/udp_offload.c:261 net/ipv4/udp_offload.c:277) [ 62.687193] RSP: 0018:ffffbd3a83b4f868 EFLAGS: 00010246 [ 62.692515] RAX: 00000000000000ce RBX: 0000000000000000 RCX: 0000000000000000 [ 62.699743] RDX: ffffa124def8a000 RSI: 0000000000000079 RDI: ffffa125952a14d4 [ 62.706970] RBP: ffffa124def8a000 R08: 0000000000000022 R09: 00002000001558c9 [ 62.714199] R10: 0000000000000000 R11: 00000000be554639 R12: 00000000000000e2 [ 62.721426] R13: ffffa125952a1400 R14: ffffa125952a1400 R15: 00002000001558c9 [ 62.728654] FS: 0000000000000000(0000) GS:ffffa127efa40000(0000) knlGS:0000000000000000 [ 62.736852] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 62.742702] CR2: 00000000000000c0 CR3: 00000001034b0000 CR4: 00000000003526e0 [ 62.749948] Call Trace: [ 62.752498] <TASK> [ 62.779267] inet_gso_segment (net/ipv4/af_inet.c:1398) [ 62.787605] skb_mac_gso_segment (net/core/gro.c:141) [ 62.791906] __skb_gso_segment (net/core/dev.c:3403 (discriminator 2)) [ 62.800492] validate_xmit_skb (./include/linux/netdevice.h:4862 net/core/dev.c:3659) [ 62.804695] validate_xmit_skb_list (net/core/dev.c:3710) [ 62.809158] sch_direct_xmit (net/sched/sch_generic.c:330) [ 62.813198] __dev_queue_xmit (net/core/dev.c:3805 net/core/dev.c:4210) net/netfilter/core.c:626) [ 62.821093] br_dev_queue_push_xmit (net/bridge/br_forward.c:55) [ 62.825652] maybe_deliver (net/bridge/br_forward.c:193) [ 62.829420] br_flood (net/bridge/br_forward.c:233) [ 62.832758] br_handle_frame_finish (net/bridge/br_input.c:215) [ 62.837403] br_handle_frame (net/bridge/br_input.c:298 net/bridge/br_input.c:416) [ 62.851417] __netif_receive_skb_core.constprop.0 (net/core/dev.c:5387) [ 62.866114] __netif_receive_skb_list_core (net/core/dev.c:5570) [ 62.871367] netif_receive_skb_list_internal (net/core/dev.c:5638 net/core/dev.c:5727) [ 62.876795] napi_complete_done (./include/linux/list.h:37 ./include/net/gro.h:434 ./include/net/gro.h:429 net/core/dev.c:6067) [ 62.881004] ixgbe_poll (drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:3191) [ 62.893534] __napi_poll (net/core/dev.c:6498) [ 62.897133] napi_threaded_poll (./include/linux/netpoll.h:89 net/core/dev.c:6640) [ 62.905276] kthread (kernel/kthread.c:379) [ 62.913435] ret_from_fork (arch/x86/entry/entry_64.S:314) [ 62.917119] </TASK>
In the critical scenario, rx-gro-list GRO-ed packets are fed, via a bridge, both to the local input path and to an egress device (tun).
The segmentation of such packets unsafely writes to the cloned skbs with shared heads.
This change addresses the issue by uncloning as needed the to-be-segmented skbs.
--- net/core/skbuff.c | 5 +++++ 1 file changed, 5 insertions(+)
net/core/skbuff.c +5 -0
@@ -3882,6 +3882,11 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,skb_push (skb, -skb_network_offset (skb) + offset); +/* Ensure the head is writeable before touching the shared info */ + err =skb_unclone (skb,GFP_ATOMIC ); +if (err) + goto err_linearize; +skb_shinfo (skb)->frag_list =NULL ;while (list_skb) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 412/532 icmp6: Fix null-ptr-deref of ip6_null_entry->rt6i_idev in icmp6_dev().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 2aaa8a15de73874847d62eb595c6683bface80fd ]
With some IPv6 Ext Hdr (RPL, SRv6, etc.), we can send a packet that has the link-local address as src and dst IP and will be forwarded to an external IP in the IPv6 Ext Hdr.
For example, the script below generates a packet whose src IP is the link-local address and dst is updated to 11::.
# for f in $(find /proc/sys/net/ -name *seg6_enabled*); do echo 1 > $f; done # python3
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
from socket import *
from scapy.all import *
SRC_ADDR=DST_ADDR= "fe80::5054:ff:fe12:3456"pkt =
IPv6(src=SRC_ADDR, dst=DST_ADDR)
pkt /=IPv6ExtHdrSegmentRouting(type=4, addresses=["11::", "22::"], segleft=1)sk =
socket(AF_INET6, SOCK_RAW, IPPROTO_RAW)sk.sendto(bytes(pkt), (DST_ADDR, 0))
For such a packet, we call ip6_route_input() to look up a route for the next destination in these three functions depending on the header type.
* ipv6_rthdr_rcv()
* ipv6_rpl_srh_rcv()
* ipv6_srh_rcv()
If no route is found, ip6_null_entry is set to skb, and the following dst_input(skb) calls ip6_pkt_drop().
Finally, in icmp6_dev(), we dereference skb_rt6_info(skb)->rt6i_idev->dev as the input device is the loopback interface. Then, we have to check if skb_rt6_info(skb)->rt6i_idev is NULL or not to avoid NULL pointer deref for ip6_null_entry.
BUG: kernel NULL pointer dereference, address: 0000000000000000 PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 157 Comm: python3 Not tainted 6.4.0-11996-gb121d614371c #35 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:icmp6_send (net/ipv6/icmp.c:436 net/ipv6/icmp.c:503) Code: fe ff ff 48 c7 40 30 c0 86 5d 83 e8 c6 44 1c 00 e9 c8 fc ff ff 49 8b 46 58 48 83 e0 fe 0f 84 4a fb ff ff 48 8b 80 d0 00 00 00 <48> 8b 00 44 8b 88 e0 00 00 00 e9 34 fb ff ff 4d 85 ed 0f 85 69 01 RSP: 0018:ffffc90000003c70 EFLAGS: 00000286 RAX: 0000000000000000 RBX: 0000000000000001 RCX: 00000000000000e0 RDX: 0000000000000021 RSI: 0000000000000000 RDI: ffff888006d72a18 RBP: ffffc90000003d80 R08: 0000000000000000 R09: 0000000000000001 R10: ffffc90000003d98 R11: 0000000000000040 R12: ffff888006d72a10 R13: 0000000000000000 R14: ffff8880057fb800 R15: ffffffff835d86c0 FS: 00007f9dc72ee740(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000000057b2000 CR4: 00000000007506f0 PKRU: 55555554 Call Trace: <IRQ> ip6_pkt_drop (net/ipv6/route.c:4513) ipv6_rthdr_rcv (net/ipv6/exthdrs.c:640 net/ipv6/exthdrs.c:686) ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:437 (discriminator 5)) ip6_input_finish (./include/linux/rcupdate.h:781 net/ipv6/ip6_input.c:483) __netif_receive_skb_one_core (net/core/dev.c:5455) process_backlog (./include/linux/rcupdate.h:781 net/core/dev.c:5895) __napi_poll (net/core/dev.c:6460) net_rx_action (net/core/dev.c:6529 net/core/dev.c:6660) __do_softirq (./arch/x86/include/asm/jump_label.h:27 ./include/linux/jump_label.h:207 ./include/trace/events/irq.h:142 kernel/softirq.c:554) do_softirq (kernel/softirq.c:454 kernel/softirq.c:441) </IRQ> <TASK> __local_bh_enable_ip (kernel/softirq.c:381) __dev_queue_xmit (net/core/dev.c:4231) ip6_finish_output2 (./include/net/neighbour.h:544 net/ipv6/ip6_output.c:135) rawv6_sendmsg (./include/net/dst.h:458 ./include/linux/netfilter.h:303 net/ipv6/raw.c:656 net/ipv6/raw.c:914) sock_sendmsg (net/socket.c:725 net/socket.c:748) __sys_sendto (net/socket.c:2134) __x64_sys_sendto (net/socket.c:2146 net/socket.c:2142 net/socket.c:2142) do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) RIP: 0033:0x7f9dc751baea Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 15 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 7e c3 0f 1f 44 00 00 41 54 48 83 ec 30 44 89 RSP: 002b:00007ffe98712c38 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00007ffe98712cf8 RCX: 00007f9dc751baea RDX: 0000000000000060 RSI: 00007f9dc6460b90 RDI: 0000000000000003 RBP: 00007f9dc56e8be0 R08: 00007ffe98712d70 R09: 000000000000001c R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: ffffffffc4653600 R14: 0000000000000001 R15: 00007f9dc6af5d1b </TASK> Modules linked in: CR2: 0000000000000000 ---[ end trace 0000000000000000 ]--- RIP: 0010:icmp6_send (net/ipv6/icmp.c:436 net/ipv6/icmp.c:503) Code: fe ff ff 48 c7 40 30 c0 86 5d 83 e8 c6 44 1c 00 e9 c8 fc ff ff 49 8b 46 58 48 83 e0 fe 0f 84 4a fb ff ff 48 8b 80 d0 00 00 00 <48> 8b 00 44 8b 88 e0 00 00 00 e9 34 fb ff ff 4d 85 ed 0f 85 69 01 RSP: 0018:ffffc90000003c70 EFLAGS: 00000286 RAX: 0000000000000000 RBX: 0000000000000001 RCX: 00000000000000e0 RDX: 0000000000000021 RSI: 0000000000000000 RDI: ffff888006d72a18 RBP: ffffc90000003d80 R08: 0000000000000000 R09: 0000000000000001 R10: ffffc90000003d98 R11: 0000000000000040 R12: ffff888006d72a10 R13: 0000000000000000 R14: ffff8880057fb800 R15: ffffffff835d86c0 FS: 00007f9dc72ee740(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000000057b2000 CR4: 00000000007506f0 PKRU: 55555554 Kernel panic - not syncing: Fatal exception in interrupt
Kernel Offset: disabled
--- net/ipv6/icmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/icmp.c +4 -1
@@ -430,7 +430,10 @@ static struct net_device *icmp6_dev(const struct sk_buff *skb)if (unlikely (dev->ifindex ==LOOPBACK_IFINDEX ||netif_is_l3_master (skb->dev))) {const struct rt6_info *rt6 =skb_rt6_info (skb); -if (rt6) +/* The destination could be an external IP in Ext Hdr (SRv6, RPL, etc.), +* and ip6_null_entry could be set to skb if no route is found. +*/ +if (rt6 && rt6->rt6i_idev) dev = rt6->rt6i_idev->dev; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 413/532 udp6: fix udp6_ehashfn() typo
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 51d03e2f2203e76ed02d33fb5ffbb5fc85ffaf54 ]
Amit Klein reported that udp6_ehash_secret was initialized but never used.
--- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/udp.c +1 -1
@@ -88,7 +88,7 @@ static u32 udp6_ehashfn(const struct net *net, fhash =__ipv6_addr_jhash (faddr, udp_ipv6_hash_secret);return __inet6_ehashfn (lhash, lport, fhash, fport, - udp_ipv6_hash_secret +net_hash_mix (net)); + udp6_ehash_secret +net_hash_mix (net)); }int udp_v6_get_port (struct sock *sk,unsigned short snum)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 414/532 ntb: idt: Fix error handling in idt_pci_driver_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit c012968259b451dc4db407f2310fe131eaefd800 ]
A problem about ntb_hw_idt create debugfs failed is triggered with the following log given:
[ 1236.637636] IDT PCI-E Non-Transparent Bridge Driver 2.0 [ 1236.639292] debugfs: Directory 'ntb_hw_idt' with parent '/' already present!
The reason is that idt_pci_driver_init() returns pci_register_driver() directly without checking its return value, if pci_register_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of ntb_hw_idt can never be created later.
idt_pci_driver_init()
debugfs_create_dir() # create debugfs directory pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when pci_register_driver() returns error.
--- drivers/ntb/hw/idt/ntb_hw_idt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ntb/hw/idt/ntb_hw_idt.c +6 -1
@@ -2891,6 +2891,7 @@ static struct pci_driver idt_pci_driver = {static int __init idt_pci_driver_init (void ) { +int ret;pr_info ("%s %s\n" ,NTB_DESC ,NTB_VER );/* Create the top DebugFS directory if the FS is initialized */
@@ -2898,7 +2899,11 @@ static int __init idt_pci_driver_init(void) dbgfs_topdir =debugfs_create_dir (KBUILD_MODNAME ,NULL );/* Register the NTB hardware driver to handle the PCI device */ -return pci_register_driver (&idt_pci_driver); + ret =pci_register_driver (&idt_pci_driver); +if (ret) +debugfs_remove_recursive (dbgfs_topdir); + +return ret; }module_init (idt_pci_driver_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 415/532 NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 98af0a33c1101c29b3ce4f0cf4715fd927c717f9 ]
A problem about ntb_hw_amd create debugfs failed is triggered with the following log given:
[ 618.431232] AMD(R) PCI-E Non-Transparent Bridge Driver 1.0 [ 618.433284] debugfs: Directory 'ntb_hw_amd' with parent '/' already present!
The reason is that amd_ntb_pci_driver_init() returns pci_register_driver() directly without checking its return value, if pci_register_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of ntb_hw_amd can never be created later.
amd_ntb_pci_driver_init()
debugfs_create_dir() # create debugfs directory pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when pci_register_driver() returns error.
--- drivers/ntb/hw/amd/ntb_hw_amd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +6 -1
@@ -1336,12 +1336,17 @@ static struct pci_driver amd_ntb_pci_driver = {static int __init amd_ntb_pci_driver_init (void ) { +int ret;pr_info ("%s %s\n" ,NTB_DESC ,NTB_VER );if (debugfs_initialized ()) debugfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL ); -return pci_register_driver (&amd_ntb_pci_driver); + ret =pci_register_driver (&amd_ntb_pci_driver); +if (ret) +debugfs_remove_recursive (debugfs_dir); + +return ret; }module_init (amd_ntb_pci_driver_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 416/532 ntb: intel: Fix error handling in intel_ntb_pci_driver_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 4c3c796aca02883ad35bb117468938cc4022ca41 ]
A problem about ntb_hw_intel create debugfs failed is triggered with the following log given:
[ 273.112733] Intel(R) PCI-E Non-Transparent Bridge Driver 2.0 [ 273.115342] debugfs: Directory 'ntb_hw_intel' with parent '/' already present!
The reason is that intel_ntb_pci_driver_init() returns pci_register_driver() directly without checking its return value, if pci_register_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of ntb_hw_intel can never be created later.
intel_ntb_pci_driver_init()
debugfs_create_dir() # create debugfs directory pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when pci_register_driver() returns error.
--- drivers/ntb/hw/intel/ntb_hw_gen1.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/ntb/hw/intel/ntb_hw_gen1.c +6 -1
@@ -2060,12 +2060,17 @@ static struct pci_driver intel_ntb_pci_driver = {static int __init intel_ntb_pci_driver_init (void ) { +int ret;pr_info ("%s %s\n" ,NTB_DESC ,NTB_VER );if (debugfs_initialized ()) debugfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL ); -return pci_register_driver (&intel_ntb_pci_driver); + ret =pci_register_driver (&intel_ntb_pci_driver); +if (ret) +debugfs_remove_recursive (debugfs_dir); + +return ret; }module_init (intel_ntb_pci_driver_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 417/532 NTB: ntb_transport: fix possible memory leak while device_register() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8623ccbfc55d962e19a3537652803676ad7acb90 ]
If device_register() returns error, the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(), and client_dev is freed in ntb_transport_client_release().
--- drivers/ntb/ntb_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/ntb_transport.c +1 -1
@@ -410,7 +410,7 @@ int ntb_transport_register_client_dev(char *device_name) rc =device_register (dev);if (rc) { -kfree (client_dev); +put_device (dev); goto err; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 418/532 NTB: ntb_tool: Add check for devm_kcalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 2790143f09938776a3b4f69685b380bae8fd06c7 ]
As the devm_kcalloc may return NULL pointer,
it should be better to add check for the return
value, as same as the others.
--- drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ntb/test/ntb_tool.c +2 -0
@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 419/532 ipv6/addrconf: fix a potential refcount underflow for idev
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 06a0716949c22e2aefb648526580671197151acc ]
Now in addrconf_mod_rs_timer(), reference idev depends on whether rs_timer is not pending. Then modify rs_timer timeout.
There is a time gap in [1], during which if the pending rs_timer becomes not pending. It will miss to hold idev, but the rs_timer is activated. Thus rs_timer callback function addrconf_rs_timer() will be executed and put idev later without holding idev. A refcount underflow issue for idev can be caused by this.
if (!timer_pending(&idev->rs_timer)) in6_dev_hold(idev); <--------------[1] mod_timer(&idev->rs_timer, jiffies + when);
To fix the issue, hold idev if mod_timer() return 0.
--- net/ipv6/addrconf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv6/addrconf.c +1 -2
@@ -323,9 +323,8 @@ static void addrconf_del_dad_work(struct inet6_ifaddr *ifp)static void addrconf_mod_rs_timer (struct inet6_dev *idev,unsigned long when) { -if (!timer_pending (&idev->rs_timer)) +if (!mod_timer (&idev->rs_timer, jiffies + when))in6_dev_hold (idev); -mod_timer (&idev->rs_timer, jiffies + when); } static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 420/532 platform/x86: wmi: remove unnecessary argument
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 84eacf7e6413d5e2d2f4f9dddf9216c18a3631cf ]
The GUID block is available for wmi_create_device() through wblock->gblock. Use that consistently in the function instead of using a mix of gblock and wblock->gblock.
Stable-dep-of: 028e6e204ace ("platform/x86: wmi: Break possible infinite loop when parsing GUID")
--- drivers/platform/x86/wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/platform/x86/wmi.c +4 -5
@@ -1046,7 +1046,6 @@ static const struct device_type wmi_type_data = { };static int wmi_create_device (struct device *wmi_bus_dev, -const struct guid_block *gblock,struct wmi_block *wblock,struct acpi_device *device) {
@@ -1054,12 +1053,12 @@ static int wmi_create_device(struct device *wmi_bus_dev,char method[5 ];int result; -if (gblock->flags &ACPI_WMI_EVENT ) { +if (wblock->gblock.flags &ACPI_WMI_EVENT ) { wblock->dev.dev.type = &wmi_type_event; goto out_init; } -if (gblock->flags &ACPI_WMI_METHOD ) { +if (wblock->gblock.flags &ACPI_WMI_METHOD ) { wblock->dev.dev.type = &wmi_type_method;mutex_init (&wblock->char_mutex); goto out_init;
@@ -1109,7 +1108,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, wblock->dev.dev.bus = &wmi_bus_type; wblock->dev.dev.parent = wmi_bus_dev; -dev_set_name (&wblock->dev.dev,"%pUL" , gblock->guid); +dev_set_name (&wblock->dev.dev,"%pUL" , wblock->gblock.guid);device_initialize (&wblock->dev.dev);
@@ -1201,7 +1200,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) wblock->acpi_device = device; wblock->gblock = gblock[i]; - retval =wmi_create_device (wmi_bus_dev, &gblock[i], wblock, device); + retval =wmi_create_device (wmi_bus_dev, wblock, device);if (retval) {kfree (wblock);continue ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 421/532 platform/x86: wmi: use guid_t and guid_equal()
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit 67f472fdacf4a691b1c3c20c27800b23ce31e2de ]
Instead of hard-coding a 16 long byte array, use the available guid_t type and related methods.
Stable-dep-of: 028e6e204ace ("platform/x86: wmi: Break possible infinite loop when parsing GUID")
--- drivers/platform/x86/wmi.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/platform/x86/wmi.c +17 -17
@@ -39,7 +39,7 @@ MODULE_LICENSE("GPL");static LIST_HEAD (wmi_block_list); struct guid_block { - char guid[16]; + guid_t guid; union { char object_id[2]; struct {
@@ -124,7 +124,7 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)list_for_each_entry (wblock, &wmi_block_list, list) { block = &wblock->gblock; -if (memcmp (block->guid, &guid_input,16 ) ==0 ) { +if (guid_equal (&block->guid, &guid_input)) {if (out) *out = wblock;return true;
@@ -148,7 +148,7 @@ static const void *find_guid_context(struct wmi_block *wblock,while (*id->guid_string) {if (guid_parse (id->guid_string, &guid_input))continue ; -if (!memcmp (wblock->gblock.guid, &guid_input,16 )) +if (guid_equal (&wblock->gblock.guid, &guid_input))return id->context; id++; }
@@ -460,7 +460,7 @@ EXPORT_SYMBOL_GPL(wmi_set_block);static void wmi_dump_wdg (const struct guid_block *g) { -pr_info ("%pUL:\n" , g->guid); +pr_info ("%pUL:\n" , &g->guid);if (g->flags &ACPI_WMI_EVENT )pr_info ("\tnotify_id: 0x%02X\n" , g->notify_id);else
@@ -542,7 +542,7 @@ wmi_notify_handler handler, void *data)list_for_each_entry (block, &wmi_block_list, list) {acpi_status wmi_status; -if (memcmp (block->gblock.guid, &guid_input,16 ) ==0 ) { +if (guid_equal (&block->gblock.guid, &guid_input)) {if (block->handler && block->handler != wmi_notify_debug)return AE_ALREADY_ACQUIRED ;
@@ -582,7 +582,7 @@ acpi_status wmi_remove_notify_handler(const char *guid)list_for_each_entry (block, &wmi_block_list, list) {acpi_status wmi_status; -if (memcmp (block->gblock.guid, &guid_input,16 ) ==0 ) { +if (guid_equal (&block->gblock.guid, &guid_input)) {if (!block->handler || block->handler == wmi_notify_debug)return AE_NULL_ENTRY ;
@@ -693,7 +693,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, {struct wmi_block *wblock =dev_to_wblock (dev); -return sprintf (buf,"wmi:%pUL\n" , wblock->gblock.guid); +return sprintf (buf,"wmi:%pUL\n" , &wblock->gblock.guid); }static DEVICE_ATTR_RO (modalias);
@@ -702,7 +702,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, {struct wmi_block *wblock =dev_to_wblock (dev); -return sprintf (buf,"%pUL\n" , wblock->gblock.guid); +return sprintf (buf,"%pUL\n" , &wblock->gblock.guid); }static DEVICE_ATTR_RO (guid);
@@ -785,10 +785,10 @@ static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env) {struct wmi_block *wblock =dev_to_wblock (dev); -if (add_uevent_var (env,"MODALIAS=wmi:%pUL" , wblock->gblock.guid)) +if (add_uevent_var (env,"MODALIAS=wmi:%pUL" , &wblock->gblock.guid))return -ENOMEM ; -if (add_uevent_var (env,"WMI_GUID=%pUL" , wblock->gblock.guid)) +if (add_uevent_var (env,"WMI_GUID=%pUL" , &wblock->gblock.guid))return -ENOMEM ;return 0 ;
@@ -815,7 +815,7 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)if (WARN_ON (guid_parse (id->guid_string, &driver_guid)))continue ; -if (!memcmp (&driver_guid, wblock->gblock.guid,16 )) +if (guid_equal (&driver_guid, &wblock->gblock.guid))return 1 ; id++;
@@ -1108,7 +1108,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, wblock->dev.dev.bus = &wmi_bus_type; wblock->dev.dev.parent = wmi_bus_dev; -dev_set_name (&wblock->dev.dev,"%pUL" , wblock->gblock.guid); +dev_set_name (&wblock->dev.dev,"%pUL" , &wblock->gblock.guid);device_initialize (&wblock->dev.dev);
@@ -1128,12 +1128,12 @@ static void wmi_free_devices(struct acpi_device *device) } } -static bool guid_already_parsed (struct acpi_device *device,const u8 *guid) +static bool guid_already_parsed (struct acpi_device *device,const guid_t *guid) {struct wmi_block *wblock;list_for_each_entry (wblock, &wmi_block_list, list) { -if (memcmp (wblock->gblock.guid, guid,16 ) ==0 ) { +if (guid_equal (&wblock->gblock.guid, guid)) {/* * Because we historically didn't track the relationship * between GUIDs and ACPI nodes, we don't know whether
@@ -1188,7 +1188,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device)* case yet, so for now, we'll just ignore the duplicate * for device creation. */ -if (guid_already_parsed (device, gblock[i].guid)) +if (guid_already_parsed (device, &gblock[i].guid))continue ; wblock =kzalloc (sizeof (struct wmi_block ),GFP_KERNEL );
@@ -1225,7 +1225,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) retval =device_add (&wblock->dev.dev);if (retval) {dev_err (wmi_bus_dev,"failed to register %pUL\n" , - wblock->gblock.guid); + &wblock->gblock.guid);if (debug_event)wmi_method_enable (wblock,0 );list_del (&wblock->list);
@@ -1333,7 +1333,7 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, }if (debug_event) -pr_info ("DEBUG Event GUID: %pUL\n" , wblock->gblock.guid); +pr_info ("DEBUG Event GUID: %pUL\n" , &wblock->gblock.guid); acpi_bus_generate_netlink_event( wblock->acpi_device->pnp.device_class,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 422/532 platform/x86: wmi: move variables
In reply to Greg Kroah-HartmanFrom: Barnabás Pőcze <[email protected]>
[ Upstream commit f5431bf1e6781e876bdc8ae10fb1e7da6f1aa9b5 ]
Move some variables in order to keep them
in the narrowest possible scope.
Stable-dep-of: 028e6e204ace ("platform/x86: wmi: Break possible infinite loop when parsing GUID")
--- drivers/platform/x86/wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/platform/x86/wmi.c +4 -5
@@ -137,7 +137,6 @@ static const void *find_guid_context(struct wmi_block *wblock, struct wmi_driver *wdriver) {const struct wmi_device_id *id; -guid_t guid_input;if (wblock ==NULL || wdriver ==NULL )return NULL ;
@@ -146,6 +145,8 @@ static const void *find_guid_context(struct wmi_block *wblock, id = wdriver->id_table;while (*id->guid_string) { +guid_t guid_input; +if (guid_parse (id->guid_string, &guid_input))continue ;if (guid_equal (&wblock->gblock.guid, &guid_input))
@@ -618,7 +619,6 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) {struct acpi_object_list input;union acpi_object params[1 ]; -struct guid_block *gblock;struct wmi_block *wblock; input.count =1 ;
@@ -627,7 +627,7 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) params[0 ].integer.value = event;list_for_each_entry (wblock, &wmi_block_list, list) { - gblock = &wblock->gblock; +struct guid_block *gblock = &wblock->gblock;if ((gblock->flags &ACPI_WMI_EVENT ) && (gblock->notify_id == event))
@@ -1282,12 +1282,11 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,static void acpi_wmi_notify_handler (acpi_handle handle,u32 event,void *context) { -struct guid_block *block;struct wmi_block *wblock;bool found_it = false;list_for_each_entry (wblock, &wmi_block_list, list) { - block = &wblock->gblock; +struct guid_block *block = &wblock->gblock; if (wblock->acpi_device->handle == handle && (block->flags & ACPI_WMI_EVENT) &&
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 423/532 platform/x86: wmi: Break possible infinite loop when parsing GUID
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 028e6e204ace1f080cfeacd72c50397eb8ae8883 ]
The while-loop may break on one of the two conditions, either ID string is empty or GUID matches. The second one, may never be reached if the parsed string is not correct GUID. In such a case the loop will never advance to check the next ID.
Break possible infinite loop by factoring out guid_parse_and_compare() helper which may be moved to the generic header for everyone later on and preventing from similar mistake in the future.
Interestingly that firstly it appeared when WMI was turned into a bus driver, but later when duplicated GUIDs were checked, the while-loop has been replaced by for-loop and hence no mistake made again.
--- drivers/platform/x86/wmi.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/platform/x86/wmi.c +12 -10
@@ -133,6 +133,16 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)return false; } +static bool guid_parse_and_compare (const char *string,const guid_t *guid) +{ +guid_t guid_input; + +if (guid_parse (string, &guid_input)) +return false; + +return guid_equal (&guid_input, guid); +} +static const void *find_guid_context (struct wmi_block *wblock,struct wmi_driver *wdriver) {
@@ -145,11 +155,7 @@ static const void *find_guid_context(struct wmi_block *wblock, id = wdriver->id_table;while (*id->guid_string) { -guid_t guid_input; - -if (guid_parse (id->guid_string, &guid_input)) -continue ; -if (guid_equal (&wblock->gblock.guid, &guid_input)) +if (guid_parse_and_compare (id->guid_string, &wblock->gblock.guid))return id->context; id++; }
@@ -811,11 +817,7 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)return 0 ;while (*id->guid_string) { -guid_t driver_guid; - -if (WARN_ON (guid_parse (id->guid_string, &driver_guid))) -continue ; -if (guid_equal (&driver_guid, &wblock->gblock.guid)) +if (guid_parse_and_compare (id->guid_string, &wblock->gblock.guid))return 1 ; id++;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 424/532 kernel/trace: Fix cleanup logic of enable_trace_eprobe
In reply to Greg Kroah-HartmanFrom: Tzvetomir Stoyanov (VMware) <[email protected]>
[ Upstream commit cf0a624dc706c306294c14e6b3e7694702f25191 ]
The enable_trace_eprobe() function enables all event probes, attached to given trace probe. If an error occurs in enabling one of the event probes, all others should be roll backed. There is a bug in that roll back logic - instead of all event probes, only the failed one is disabled.
--- kernel/trace/trace_eprobe.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
kernel/trace/trace_eprobe.c +16 -2
@@ -725,6 +725,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,struct trace_eprobe *ep;bool enabled;int ret =0 ; +int cnt =0 ; tp =trace_probe_primary_from_call (call);if (WARN_ON_ONCE (!tp))
@@ -748,12 +749,25 @@ static int enable_trace_eprobe(struct trace_event_call *call,if (ret)break ; enabled = true; + cnt++; }if (ret) {/* Failed to enable one of them. Roll back all */ -if (enabled) -disable_eprobe (ep, file->tr); +if (enabled) { +/* +* It's a bug if one failed for something other than memory +* not being available but another eprobe succeeded. +*/ +WARN_ON_ONCE (ret != -ENOMEM ); + +list_for_each_entry (pos,trace_probe_probe_list (tp), list) { + ep = container_of(pos, struct trace_eprobe, tp); +disable_eprobe (ep, file->tr); +if (!--cnt) +break ; + } + }if (file)trace_probe_remove_file (tp, file);else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 425/532 igc: Fix launchtime before start of cycle
In reply to Greg Kroah-HartmanFrom: Florian Kauer <[email protected]>
[ Upstream commit c1bca9ac0bcb355be11354c2e68bc7bf31f5ac5a ]
It is possible (verified on a running system) that frames are processed by igc_tx_launchtime with a txtime before the start of the cycle (baset_est).
However, the result of txtime - baset_est is written into a u32, leading to a wrap around to a positive number. The following launchtime > 0 check will only branch to executing launchtime = 0 if launchtime is already 0.
Fix it by using a s32 before checking launchtime > 0.
--- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -1013,7 +1013,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime,ktime_t base_time = adapter->base_time;ktime_t now =ktime_get_clocktai ();ktime_t baset_est, end_of_cycle; -u32 launchtime; +s32 launchtime;s64 n; n =div64_s64 (ktime_sub_ns (now, base_time), cycle_time);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 426/532 igc: Fix inserting of empty frame for launchtime
In reply to Greg Kroah-HartmanFrom: Florian Kauer <[email protected]>
[ Upstream commit 0bcc62858d6ba62cbade957d69745e6adeed5f3d ]
The insertion of an empty frame was introduced with
commit db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") in order to ensure that the current cycle has at least one packet if there is some packet to be scheduled for the next cycle.
However, the current implementation does not properly check if a packet is already scheduled for the current cycle. Currently, an empty packet is always inserted if and only if txtime >= end_of_cycle && txtime > last_tx_cycle
but since last_tx_cycle is always either the end of the current cycle (end_of_cycle) or the end of a previous cycle, the second part (txtime > last_tx_cycle) is always true unless txtime == last_tx_cycle.
What actually needs to be checked here is if the last_tx_cycle was already written within the current cycle, so an empty frame should only be inserted if and only if
txtime >= end_of_cycle && end_of_cycle > last_tx_cycle.
This patch does not only avoid an unnecessary insertion, but it can actually be harmful to insert an empty packet if packets are already scheduled in the current cycle, because it can lead to a situation where the empty packet is actually processed as the first packet in the upcoming cycle shifting the packet with the first_flag even one cycle into the future, finally leading to a TX hang.
The TX hang can be reproduced on a i225 with:
sudo tc qdisc replace dev enp1s0 parent root handle 100 taprio \
num_tc 1 \
map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \
queues 1@0 \
base-time 0 \
sched-entry S 01 300000 \
flags 0x1 \
txtime-delay 500000 \
clockid CLOCK_TAI
sudo tc qdisc replace dev enp1s0 parent 100:1 etf \
clockid CLOCK_TAI \
delta 500000 \
offload \
skip_sock_checkand traffic generator
sudo trafgen -i traffic.cfg -o enp1s0 --cpp -n0 -q -t1400ns
with traffic.cfg
#define ETH_P_IP 0x0800
{
/* Ethernet Header */
0x30, 0x1f, 0x9a, 0xd0, 0xf0, 0x0e, # MAC Dest - adapt as needed
0x24, 0x5e, 0xbe, 0x57, 0x2e, 0x36, # MAC Src - adapt as needed
const16(ETH_P_IP),
/* IPv4 Header */
0b01000101, 0, # IPv4 version, IHL, TOS
const16(1028), # IPv4 total length (UDP length + 20 bytes (IP header))
const16(2), # IPv4 ident
0b01000000, 0, # IPv4 flags, fragmentation off
64, # IPv4 TTL
17, # Protocol UDP
csumip(14, 33), # IPv4 checksum
/* UDP Header */
10, 0, 48, 1, # IP Src - adapt as needed
10, 0, 48, 10, # IP Dest - adapt as needed
const16(5555), # UDP Src Port
const16(6666), # UDP Dest Port
const16(1008), # UDP length (UDP header 8 bytes + payload length)
csumudp(14, 34), # UDP checksum
/* Payload */
fill('W', 1000),
}and the observed message with that is for example
igc 0000:01:00.0 enp1s0: Detected Tx Unit Hang
Tx Queue <0> TDH <32> TDT <3c> next_to_use <3c> next_to_clean <32> buffer_info[next_to_clean] time_stamp <ffff26a8> next_to_watch <00000000632a1828> jiffies <ffff27f8> desc.status <1048000>
--- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -1026,7 +1026,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime, *first_flag = true; ring->last_ff_cycle = baset_est; -if (ktime_compare (txtime, ring->last_tx_cycle) >0 ) +if (ktime_compare (end_of_cycle, ring->last_tx_cycle) >0 ) *insert_empty = true; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 427/532 bpf, riscv: Support riscv jit to provide bpf_line_info
In reply to Greg Kroah-HartmanFrom: Pu Lehui <[email protected]>
[ Upstream commit 3cb70413041fdf028fa1ba3986fd0c6aec9e3dcb ]
Add support for riscv jit to provide bpf_line_info. We need to consider the prologue offset in ctx->offset, but unlike x86 and arm64, ctx->offset of riscv does not provide an extra slot for the prologue, so here we just calculate the len of prologue and add it to ctx->offset at the end. Both RV64 and RV32 have been tested.
Stable-dep-of: c56fb2aab235 ("riscv, bpf: Fix inconsistent JIT image generation")
--- arch/riscv/net/bpf_jit.h | 1 + arch/riscv/net/bpf_jit_core.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/riscv/net/bpf_jit.h +1 -0
@@ -69,6 +69,7 @@ struct rv_jit_context {struct bpf_prog *prog;u16 *insns;/* RV insns */ int ninsns; +int body_len;int epilogue_offset;int *offset;/* BPF to RV */ unsigned long flags;
arch/riscv/net/bpf_jit_core.c +7 -1
@@ -43,7 +43,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) {bool tmp_blinded = false, extra_pass = false;struct bpf_prog *tmp, *orig_prog = prog; -int pass =0 , prev_ninsns =0 , i; +int pass =0 , prev_ninsns =0 , prologue_len, i;struct rv_jit_data *jit_data;struct rv_jit_context *ctx;unsigned int image_size =0 ;
@@ -95,6 +95,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog = orig_prog; goto out_offset; } + ctx->body_len = ctx->ninsns;bpf_jit_build_prologue (ctx); ctx->epilogue_offset = ctx->ninsns;bpf_jit_build_epilogue (ctx);
@@ -154,6 +155,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)if (!prog->is_func || extra_pass) {bpf_jit_binary_lock_ro (jit_data->header); + prologue_len = ctx->epilogue_offset - ctx->body_len; +for (i =0 ; i < prog->len; i++) + ctx->offset[i] =ninsns_rvoff (prologue_len + + ctx->offset[i]); +bpf_prog_fill_jited_linfo (prog, ctx->offset); out_offset:kfree (ctx->offset);kfree (jit_data);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 428/532 riscv, bpf: Fix inconsistent JIT image generation
In reply to Greg Kroah-HartmanFrom: Björn Töpel <[email protected]>
[ Upstream commit c56fb2aab23505bb7160d06097c8de100b82b851 ]
In order to generate the prologue and epilogue, the BPF JIT needs to know which registers that are clobbered. Therefore, the during pre-final passes, the prologue is generated after the body of the program body-prologue-epilogue. Then, in the final pass, a proper prologue-body-epilogue JITted image is generated.
This scheme has worked most of the time. However, for some large programs with many jumps, e.g. the test_kmod.sh BPF selftest with hardening enabled (blinding constants), this has shown to be incorrect. For the final pass, when the proper prologue-body-epilogue is generated, the image has not converged. This will lead to that the final image will have incorrect jump offsets. The following is an excerpt from an incorrect image:
| ... | 3b8: 00c50663 beq a0,a2,3c4 <.text+0x3c4> | 3bc: 0020e317 auipc t1,0x20e | 3c0: 49630067 jalr zero,1174(t1) # 20e852 <.text+0x20e852> | ... | 20e84c: 8796 c.mv a5,t0 | 20e84e: 6422 c.ldsp s0,8(sp) # Epilogue start | 20e850: 6141 c.addi16sp sp,16 | 20e852: 853e c.mv a0,a5 # Incorrect jump target | 20e854: 8082 c.jr ra
The image has shrunk, and the epilogue offset is incorrect in the final pass.
Correct the problem by always generating proper prologue-body-epilogue outputs, which means that the first pass will only generate the body to track what registers that are touched.
--- arch/riscv/net/bpf_jit.h | 6 +++--- arch/riscv/net/bpf_jit_core.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-)
arch/riscv/net/bpf_jit.h +3 -3
@@ -69,7 +69,7 @@ struct rv_jit_context {struct bpf_prog *prog;u16 *insns;/* RV insns */ int ninsns; -int body_len; +int prologue_len;int epilogue_offset;int *offset;/* BPF to RV */ unsigned long flags;
@@ -215,8 +215,8 @@ static inline int rv_offset(int insn, int off, struct rv_jit_context *ctx)int from, to; off++;/* BPF branch is from PC+1, RV is from PC */ - from = (insn >0 ) ? ctx->offset[insn -1 ] :0 ; - to = (insn + off >0 ) ? ctx->offset[insn + off -1 ] :0 ; + from = (insn >0 ) ? ctx->offset[insn -1 ] : ctx->prologue_len; + to = (insn + off >0 ) ? ctx->offset[insn + off -1 ] : ctx->prologue_len;return ninsns_rvoff (to - from); }
arch/riscv/net/bpf_jit_core.c +13 -6
@@ -43,7 +43,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) {bool tmp_blinded = false, extra_pass = false;struct bpf_prog *tmp, *orig_prog = prog; -int pass =0 , prev_ninsns =0 , prologue_len, i; +int pass =0 , prev_ninsns =0 , i;struct rv_jit_data *jit_data;struct rv_jit_context *ctx;unsigned int image_size =0 ;
@@ -83,6 +83,12 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog = orig_prog; goto out_offset; } + +if (build_body (ctx, extra_pass,NULL )) { + prog = orig_prog; + goto out_offset; + } +for (i =0 ; i < prog->len; i++) { prev_ninsns +=32 ; ctx->offset[i] = prev_ninsns;
@@ -91,12 +97,15 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)for (i =0 ; i <NR_JIT_ITERATIONS ; i++) { pass++; ctx->ninsns =0 ; + +bpf_jit_build_prologue (ctx); + ctx->prologue_len = ctx->ninsns; +if (build_body (ctx, extra_pass, ctx->offset)) { prog = orig_prog; goto out_offset; } - ctx->body_len = ctx->ninsns; -bpf_jit_build_prologue (ctx); + ctx->epilogue_offset = ctx->ninsns;bpf_jit_build_epilogue (ctx);
@@ -155,10 +164,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)if (!prog->is_func || extra_pass) {bpf_jit_binary_lock_ro (jit_data->header); - prologue_len = ctx->epilogue_offset - ctx->body_len;for (i =0 ; i < prog->len; i++) - ctx->offset[i] =ninsns_rvoff (prologue_len + - ctx->offset[i]); + ctx->offset[i] =ninsns_rvoff (ctx->offset[i]);bpf_prog_fill_jited_linfo (prog, ctx->offset); out_offset:kfree (ctx->offset);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 429/532 drm/i915: Fix one wrong caching mode enum usage
In reply to Greg Kroah-HartmanFrom: Tvrtko Ursulin <[email protected]>
[ Upstream commit 113899c2669dff148b2a5bea4780123811aecc13 ]
Commit a4d86249c773 ("drm/i915/gt: Provide a utility to create a scratch buffer") mistakenly passed in uapi I915_CACHING_CACHED as argument to i915_gem_object_set_cache_coherency(), which actually takes internal enum i915_cache_level.
No functional issue since the value matches I915_CACHE_LLC (1 == 1), which is the intended caching mode, but lets clean it up nevertheless.
--- drivers/gpu/drm/i915/gt/intel_gtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_gtt.c +1 -1
@@ -547,7 +547,7 @@ __vm_create_scratch_for_read(struct i915_address_space *vm, unsigned long size)if (IS_ERR (obj))return ERR_CAST (obj); -i915_gem_object_set_cache_coherency (obj,I915_CACHING_CACHED ); +i915_gem_object_set_cache_coherency (obj,I915_CACHE_LLC ); vma =i915_vma_instance (obj, vm,NULL );if (IS_ERR (vma)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 430/532 octeontx2-pf: Add additional check for MCAM rules
In reply to Greg Kroah-HartmanFrom: Suman Ghosh <[email protected]>
[ Upstream commit 8278ee2a2646b9acf747317895e47a640ba933c9 ]
Due to hardware limitation, MCAM drop rule withether_type == 802.1Q and vlan_id == 0 is not supported. Hence rejecting such rules.
--- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 8 ++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +8 -0
@@ -827,6 +827,14 @@ static int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,return -EINVAL ; vlan_etype =be16_to_cpu (fsp->h_ext.vlan_etype); + +/* Drop rule with vlan_etype == 802.1Q +* and vlan_id == 0 is not supported +*/ +if (vlan_etype ==ETH_P_8021Q && !fsp->m_ext.vlan_tci && + fsp->ring_cookie ==RX_CLS_FLOW_DISC ) +return -EINVAL ; +/* Only ETH_P_8021Q and ETH_P_802AD types supported */ if (vlan_etype !=ETH_P_8021Q && vlan_etype !=ETH_P_8021AD )
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +15 -0
@@ -536,6 +536,21 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,return -EOPNOTSUPP ; } +if (!match.mask->vlan_id) { +struct flow_action_entry *act; +int i; + +flow_action_for_each (i, act, &rule->action) { +if (act->id ==FLOW_ACTION_DROP ) { +netdev_err (nic->netdev, +"vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n" , +ntohs (match.key->vlan_tpid), + match.key->vlan_id); +return -EOPNOTSUPP ; + } + } + } +if (match.mask->vlan_id || match.mask->vlan_dei || match.mask->vlan_priority) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 431/532 erofs: avoid infinite loop in z_erofs_do_read_page() when reading beyond EOF
In reply to Greg Kroah-HartmanFrom: Chunhai Guo <[email protected]>
[ Upstream commit 8191213a5835b0317c5e4d0d337ae1ae00c75253 ]
z_erofs_do_read_page() may loop infinitely due to the inappropriate truncation in the below statement. Since the offset is 64 bits and min_t() truncates the result to 32 bits. The solution is to replace unsigned int with a 64-bit type, such as erofs_off_t.
cur = end - min_t(unsigned int, offset + end - map->m_la, end);
- For example:
- offset = 0x400160000
- end = 0x370
- map->m_la = 0x160370
- offset + end - map->m_la = 0x400000000
- offset + end - map->m_la = 0x00000000 (truncated as unsigned int)
- Expected result:
- cur = 0
- Actual result:
- cur = 0x370
--- fs/erofs/zdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/zdata.c +1 -1
@@ -713,7 +713,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, tight &= (clt->mode >=COLLECT_PRIMARY_HOOKED && clt->mode !=COLLECT_PRIMARY_FOLLOWED_NOINPLACE ); - cur = end - min_t(unsigned int, offset + end - map->m_la, end); + cur = end -min_t (erofs_off_t, offset + end - map->m_la, end);if (!(map->m_flags &EROFS_MAP_MAPPED )) {zero_user_segment (page, cur, end); goto next_part;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 432/532 erofs: decouple basic mount options from fs_context
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit e62424651f43cb37e17ca26a7ee9ee42675f24bd ]
Previously, EROFS mount options are all in the basic types, so erofs_fs_context can be directly copied with assignment. However, when the multiple device feature is introduced, it's hard to handle multiple device information like the other basic mount options.
Let's separate basic mount option usage from fs_context, thus multiple device information can be handled gracefully then.
No logic changes.
Stable-dep-of: 18bddc5b6703 ("erofs: fix fsdax unavailability for chunk-based regular files")
--- fs/erofs/inode.c | 2 +- fs/erofs/internal.h | 16 ++++++++----- fs/erofs/super.c | 58 ++++++++++++++++++++++----------------------- fs/erofs/xattr.c | 4 ++-- fs/erofs/zdata.c | 8 +++---- 5 files changed, 45 insertions(+), 43 deletions(-)
fs/erofs/inode.c +1 -1
@@ -192,7 +192,7 @@ static struct page *erofs_read_inode(struct inode *inode, inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec; inode->i_flags &= ~S_DAX ; -if (test_opt (&sbi->ctx,DAX_ALWAYS ) &&S_ISREG (inode->i_mode) && +if (test_opt (&sbi->opt,DAX_ALWAYS ) &&S_ISREG (inode->i_mode) && vi->datalayout ==EROFS_INODE_FLAT_PLAIN ) inode->i_flags |=S_DAX ;if (!nblks)
fs/erofs/internal.h +10 -6
@@ -47,7 +47,7 @@ typedef u64 erofs_off_t;/* data type for filesystem-wide blocks number */ typedef u32 erofs_blk_t ; -struct erofs_fs_context { +struct erofs_mount_opts {#ifdef CONFIG_EROFS_FS_ZIP /* current strategy of how to use managed cache */ unsigned char cache_strategy;
@@ -60,6 +60,10 @@ struct erofs_fs_context {unsigned int mount_opt; }; +struct erofs_fs_context { +struct erofs_mount_opts opt; +}; +/* all filesystem-wide lz4 configurations */ struct erofs_sb_lz4_info {/* # of pages needed for EROFS lz4 rolling decompression */
@@ -69,6 +73,8 @@ struct erofs_sb_lz4_info { };struct erofs_sb_info { +struct erofs_mount_opts opt;/* options */ +#ifdef CONFIG_EROFS_FS_ZIP /* list for all registered superblocks, mainly for shrinker */ struct list_head list;
@@ -108,8 +114,6 @@ struct erofs_sb_info {u8 volume_name[16 ];/* volume name */ u32 feature_compat;u32 feature_incompat; - -struct erofs_fs_context ctx;/* options */ };#define EROFS_SB (sb) ((struct erofs_sb_info *)(sb)->s_fs_info)
@@ -121,9 +125,9 @@ struct erofs_sb_info {#define EROFS_MOUNT_DAX_ALWAYS 0x00000040#define EROFS_MOUNT_DAX_NEVER 0x00000080 -#define clear_opt (ctx, option) ((ctx)->mount_opt &= ~EROFS_MOUNT_##option) -#define set_opt (ctx, option) ((ctx)->mount_opt |= EROFS_MOUNT_##option) -#define test_opt (ctx, option) ((ctx)->mount_opt & EROFS_MOUNT_##option) +#define clear_opt (opt, option) ((opt)->mount_opt &= ~EROFS_MOUNT_##option) +#define set_opt (opt, option) ((opt)->mount_opt |= EROFS_MOUNT_##option) +#define test_opt (opt, option) ((opt)->mount_opt & EROFS_MOUNT_##option)enum {EROFS_ZIP_CACHE_DISABLED ,
fs/erofs/super.c +28 -30
158 lines not on this page · raw message
fs/erofs/xattr.c +2 -2
@@ -429,7 +429,7 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)static bool erofs_xattr_user_list (struct dentry *dentry) { -return test_opt (&EROFS_SB (dentry->d_sb)->ctx,XATTR_USER ); +return test_opt (&EROFS_SB (dentry->d_sb)->opt,XATTR_USER ); }static bool erofs_xattr_trusted_list (struct dentry *dentry)
@@ -476,7 +476,7 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,switch (handler->flags) {case EROFS_XATTR_INDEX_USER : -if (!test_opt (&sbi->ctx,XATTR_USER )) +if (!test_opt (&sbi->opt,XATTR_USER ))return -EOPNOTSUPP ;break ;case EROFS_XATTR_INDEX_TRUSTED :
fs/erofs/zdata.c +4 -4
@@ -695,7 +695,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, goto err_out;/* preload all compressed pages (maybe downgrade role if necessary) */ -if (should_alloc_managed_pages (fe, sbi->ctx.cache_strategy, map->m_la)) +if (should_alloc_managed_pages (fe, sbi->opt.cache_strategy, map->m_la)) cache_strategy =TRYALLOC ;else cache_strategy =DONTALLOC ;
@@ -797,7 +797,7 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,/* Use workqueue and sync decompression for atomic contexts only */ if (in_atomic () ||irqs_disabled ()) {queue_work (z_erofs_workqueue, &io->u.work); - sbi->ctx.readahead_sync_decompress = true; + sbi->opt.readahead_sync_decompress = true;return ; }z_erofs_decompressqueue_work (&io->u.work);
@@ -1412,8 +1412,8 @@ static void z_erofs_readahead(struct readahead_control *rac)struct erofs_sb_info *const sbi =EROFS_I_SB (inode);unsigned int nr_pages =readahead_count (rac); -bool sync = (sbi->ctx.readahead_sync_decompress && - nr_pages <= sbi->ctx.max_sync_decompress_pages); +bool sync = (sbi->opt.readahead_sync_decompress && + nr_pages <= sbi->opt.max_sync_decompress_pages);struct z_erofs_decompress_frontend f =DECOMPRESS_FRONTEND_INIT (inode);struct page *page, *head =NULL ;LIST_HEAD (pagepool);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 433/532 erofs: fix fsdax unavailability for chunk-based regular files
In reply to Greg Kroah-HartmanFrom: Xin Yin <[email protected]>
[ Upstream commit 18bddc5b67038722cb88fcf51fbf41a0277092cb ]
DAX can be used to share page cache between VMs, reducing guest memory overhead. And chunk based data format is widely used for VM and container image. So enable dax support for it, make erofs better used for VM scenarios.
--- fs/erofs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/inode.c +2 -1
@@ -193,7 +193,8 @@ static struct page *erofs_read_inode(struct inode *inode, inode->i_flags &= ~S_DAX ;if (test_opt (&sbi->opt,DAX_ALWAYS ) &&S_ISREG (inode->i_mode) && - vi->datalayout ==EROFS_INODE_FLAT_PLAIN ) + (vi->datalayout ==EROFS_INODE_FLAT_PLAIN || + vi->datalayout ==EROFS_INODE_CHUNK_BASED )) inode->i_flags |=S_DAX ;if (!nblks)/* measure inode.i_blocks as generic filesystems */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 434/532 wifi: airo: avoid uninitialized warning in airo_get_rate()
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 9373771aaed17f5c2c38485f785568abe3a9f8c1 ]
Quieten a gcc (11.3.0) build error or warning by checking the function call status and returning -EBUSY if the function call failed. This is similar to what several other wireless drivers do for the SIOCGIWRATE ioctl call when there is a locking problem.
drivers/net/wireless/cisco/airo.c: error: 'status_rid.currentXmitRate' is used uninitialized [-Werror=uninitialized]
--- drivers/net/wireless/cisco/airo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/cisco/airo.c +4 -1
@@ -6147,8 +6147,11 @@ static int airo_get_rate(struct net_device *dev, {struct airo_info *local = dev->ml_priv;StatusRid status_rid;/* Card status info */ +int ret; -readStatusRid (local, &status_rid,1 ); + ret =readStatusRid (local, &status_rid,1 ); +if (ret) +return -EBUSY ; vwrq->value =le16_to_cpu (status_rid.currentXmitRate) *500000 ;/* If more than one rate, set auto */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 435/532 bpf: cpumap: Fix memory leak in cpu_map_update_elem
In reply to Greg Kroah-HartmanFrom: Pu Lehui <[email protected]>
[ Upstream commit 4369016497319a9635702da010d02af1ebb1849d ]
Syzkaller reported a memory leak as follows:
BUG: memory leak
unreferenced object 0xff110001198ef748 (size 192):
comm "syz-executor.3", pid 17672, jiffies 4298118891 (age 9.906s)
hex dump (first 32 bytes):
00 00 00 00 4a 19 00 00 80 ad e3 e4 fe ff c0 00 ....J...........
00 b2 d3 0c 01 00 11 ff 28 f5 8e 19 01 00 11 ff ........(.......
backtrace:
[<ffffffffadd28087>] __cpu_map_entry_alloc+0xf7/0xb00
[<ffffffffadd28d8e>] cpu_map_update_elem+0x2fe/0x3d0
[<ffffffffadc6d0fd>] bpf_map_update_value.isra.0+0x2bd/0x520
[<ffffffffadc7349b>] map_update_elem+0x4cb/0x720
[<ffffffffadc7d983>] __se_sys_bpf+0x8c3/0xb90
[<ffffffffb029cc80>] do_syscall_64+0x30/0x40
[<ffffffffb0400099>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
BUG: memory leak
unreferenced object 0xff110001198ef528 (size 192):
comm "syz-executor.3", pid 17672, jiffies 4298118891 (age 9.906s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffffadd281f0>] __cpu_map_entry_alloc+0x260/0xb00
[<ffffffffadd28d8e>] cpu_map_update_elem+0x2fe/0x3d0
[<ffffffffadc6d0fd>] bpf_map_update_value.isra.0+0x2bd/0x520
[<ffffffffadc7349b>] map_update_elem+0x4cb/0x720
[<ffffffffadc7d983>] __se_sys_bpf+0x8c3/0xb90
[<ffffffffb029cc80>] do_syscall_64+0x30/0x40
[<ffffffffb0400099>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
BUG: memory leak
unreferenced object 0xff1100010fd93d68 (size 8):
comm "syz-executor.3", pid 17672, jiffies 4298118891 (age 9.906s)
hex dump (first 8 bytes):
00 00 00 00 00 00 00 00 ........
backtrace:
[<ffffffffade5db3e>] kvmalloc_node+0x11e/0x170
[<ffffffffadd28280>] __cpu_map_entry_alloc+0x2f0/0xb00
[<ffffffffadd28d8e>] cpu_map_update_elem+0x2fe/0x3d0
[<ffffffffadc6d0fd>] bpf_map_update_value.isra.0+0x2bd/0x520
[<ffffffffadc7349b>] map_update_elem+0x4cb/0x720
[<ffffffffadc7d983>] __se_sys_bpf+0x8c3/0xb90
[<ffffffffb029cc80>] do_syscall_64+0x30/0x40
[<ffffffffb0400099>] entry_SYSCALL_64_after_hwframe+0x61/0xc6In the cpu_map_update_elem flow, when kthread_stop is called before calling the threadfn of rcpu->kthread, since the KTHREAD_SHOULD_STOP bit of kthread has been set by kthread_stop, the threadfn of rcpu->kthread will never be executed, and rcpu->refcnt will never be 0, which will lead to the allocated rcpu, rcpu->queue and rcpu->queue->queue cannot be released.
Calling kthread_stop before executing kthread's threadfn will return -EINTR. We can complete the release of memory resources in this state.
--- kernel/bpf/cpumap.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-)
kernel/bpf/cpumap.c +24 -16
@@ -126,22 +126,6 @@ static void get_cpu_map_entry(struct bpf_cpu_map_entry *rcpu)atomic_inc (&rcpu->refcnt); } -/* called from workqueue, to workaround syscall using preempt_disable */ -static void cpu_map_kthread_stop (struct work_struct *work) -{ -struct bpf_cpu_map_entry *rcpu; - - rcpu = container_of(work, struct bpf_cpu_map_entry, kthread_stop_wq); - -/* Wait for flush in __cpu_map_entry_free(), via full RCU barrier, -* as it waits until all in-flight call_rcu() callbacks complete. -*/ -rcu_barrier (); - -/* kthread_stop will wake_up_process and wait for it to complete */ -kthread_stop (rcpu->kthread); -} -static void __cpu_map_ring_cleanup (struct ptr_ring *ring) {/* The tear-down procedure should have made sure that queue is
@@ -169,6 +153,30 @@ static void put_cpu_map_entry(struct bpf_cpu_map_entry *rcpu) } } +/* called from workqueue, to workaround syscall using preempt_disable */ +static void cpu_map_kthread_stop (struct work_struct *work) +{ +struct bpf_cpu_map_entry *rcpu; +int err; + + rcpu = container_of(work, struct bpf_cpu_map_entry, kthread_stop_wq); + +/* Wait for flush in __cpu_map_entry_free(), via full RCU barrier, +* as it waits until all in-flight call_rcu() callbacks complete. +*/ +rcu_barrier (); + +/* kthread_stop will wake_up_process and wait for it to complete */ + err =kthread_stop (rcpu->kthread); +if (err) { +/* kthread_stop may be called before cpu_map_kthread_run +* is executed, so we need to release the memory related +* to rcpu. +*/ +put_cpu_map_entry (rcpu); + } +} +static void cpu_map_bpf_prog_run_skb (struct bpf_cpu_map_entry *rcpu,struct list_head *listp,struct xdp_cpumap_stats *stats)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 436/532 net/sched: flower: Ensure both minimum and maximum ports are specified
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit d3f87278bcb80bd7f9519669d928b43320363d4f ]
The kernel does not currently validate that both the minimum and maximum ports of a port range are specified. This can lead user space to think that a filter matching on a port range was successfully added, when in fact it was not. For example, with a patched (buggy) iproute2 that only sends the minimum port, the following commands do not return an error:
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp src_port 100-200 action pass
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp dst_port 100-200 action pass
# tc filter show dev swp1 ingress
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
eth_type ipv4
ip_proto udp
not_in_hw
action order 1: gact action pass
random type none pass val 0
index 1 ref 1 bind 1 filter protocol ip pref 1 flower chain 0 handle 0x2
eth_type ipv4
ip_proto udp
not_in_hw
action order 1: gact action pass
random type none pass val 0
index 2 ref 1 bind 1
Fix by returning an error unless both ports are specified:
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp src_port 100-200 action pass Error: Both min and max source ports must be specified. We have an error talking to the kernel
# tc filter add dev swp1 ingress pref 1 proto ip flower ip_proto udp dst_port 100-200 action pass Error: Both min and max destination ports must be specified. We have an error talking to the kernel
--- net/sched/cls_flower.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/sched/cls_flower.c +10 -0
@@ -784,6 +784,16 @@ static int fl_set_key_port_range(struct nlattr **tb, struct fl_flow_key *key,TCA_FLOWER_KEY_PORT_SRC_MAX , &mask->tp_range.tp_max.src, TCA_FLOWER_UNSPEC, sizeof(key->tp_range.tp_max.src)); +if (mask->tp_range.tp_min.dst != mask->tp_range.tp_max.dst) { +NL_SET_ERR_MSG (extack, +"Both min and max destination ports must be specified" ); +return -EINVAL ; + } +if (mask->tp_range.tp_min.src != mask->tp_range.tp_max.src) { +NL_SET_ERR_MSG (extack, +"Both min and max source ports must be specified" ); +return -EINVAL ; + }if (mask->tp_range.tp_min.dst && mask->tp_range.tp_max.dst &&ntohs (key->tp_range.tp_max.dst) <=ntohs (key->tp_range.tp_min.dst)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 437/532 riscv: mm: fix truncation warning on RV32
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
[ Upstream commit b690e266dae2f85f4dfea21fa6a05e3500a51054 ]
lkp reports below sparse warning when building for RV32:arch/riscv/mm/init.c:1204:48: sparse: warning: cast truncates bits from constant value (100000000 becomes 0)
IMO, the reason we didn't see this truncates bug in real world is "0" means MEMBLOCK_ALLOC_ACCESSIBLE in memblock and there's no RV32 HW with more than 4GB memory.
Fix it anyway to make sparse happy.
--- arch/riscv/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/init.c +1 -1
@@ -843,7 +843,7 @@ static void __init reserve_crashkernel(void)*/ crash_base =memblock_phys_alloc_range (crash_size,PMD_SIZE , search_start, -min (search_end, (unsigned long )SZ_4G )); +min (search_end, (unsigned long )(SZ_4G -1 )));if (crash_base ==0 ) {/* Try again without restricting region to 32bit addressible memory */ crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 438/532 netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit f72207a5c0dbaaf6921cf9a6c0d2fd0bc249ea78 ]
The simple_write_to_buffer() function is designed to handle partial writes. It returns negatives on error, otherwise it returns the number of bytes that were able to be copied. This code doesn't check the return properly. We only know that the first byte is written, the rest of the buffer might be uninitialized.
There is no need to use the simple_write_to_buffer() function. Partial writes are prohibited by the "if (*ppos != 0)" check at the start of the function. Just use memdup_user() and copy the whole buffer.
--- drivers/net/netdevsim/dev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/netdevsim/dev.c +3 -6
@@ -168,13 +168,10 @@ static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file, cookie_len = (count -1 ) /2 ;if ((count -1 ) %2 )return -EINVAL ; - buf =kmalloc (count,GFP_KERNEL | __GFP_NOWARN); -if (!buf) -return -ENOMEM ; - ret =simple_write_to_buffer (buf, count, ppos, data, count); -if (ret <0 ) - goto free_buf; + buf =memdup_user (data, count); +if (IS_ERR (buf)) +return PTR_ERR (buf); fa_cookie =kmalloc (sizeof (*fa_cookie) + cookie_len,GFP_KERNEL | __GFP_NOWARN);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 439/532 net/sched: make psched_mtu() RTNL-less safe
In reply to Greg Kroah-HartmanFrom: Pedro Tammela <[email protected]>
[ Upstream commit 150e33e62c1fa4af5aaab02776b6c3812711d478 ]
Eric Dumazet says[1]:
-------
Speaking of psched_mtu(), I see that net/sched/sch_pie.c is using it without holding RTNL, so dev->mtu can be changed underneath. KCSAN could issue a warning.
-------
Annotate dev->mtu with READ_ONCE() so KCSAN don't issue a warning.
[1] https://lore.kernel.org/all/CANn89iJoJO5VtaJ-2=_d2aOQhb0Xw8iBT_Cxqp2HyuS-zj6azw@mail.gmail.com/
v1 -> v2: Fix commit message
--- include/net/pkt_sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/pkt_sched.h +1 -1
@@ -141,7 +141,7 @@ extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1];*/ static inline unsigned int psched_mtu (const struct net_device *dev) { -return dev->mtu + dev->hard_header_len; +return READ_ONCE (dev->mtu) + dev->hard_header_len; }static inline struct net *qdisc_net (struct Qdisc *q)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 440/532 net/sched: sch_qfq: refactor parsing of netlink parameters
In reply to Greg Kroah-HartmanFrom: Pedro Tammela <[email protected]>
[ Upstream commit 25369891fcef373540f8b4e0b3bccf77a04490d5 ]
Two parameters can be transformed into netlink policies and validated while parsing the netlink message.
Stable-dep-of: 3e337087c3b5 ("net/sched: sch_qfq: account for stab overhead in qfq_enqueue")
--- net/sched/sch_qfq.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
net/sched/sch_qfq.c +11 -14
@@ -113,6 +113,7 @@#define QFQ_MTU_SHIFT 16/* to support TSO/GSO */ #define QFQ_MIN_LMAX 512/* see qfq_slot_insert */ +#define QFQ_MAX_LMAX (1UL << QFQ_MTU_SHIFT)#define QFQ_MAX_AGG_CLASSES 8/* max num classes per aggregate allowed */
@@ -214,9 +215,14 @@ static struct qfq_class *qfq_find_class(struct Qdisc *sch, u32 classid) return container_of(clc, struct qfq_class, common); } +static struct netlink_range_validation lmax_range = { + .min =QFQ_MIN_LMAX , + .max =QFQ_MAX_LMAX , +}; +static const struct nla_policy qfq_policy[TCA_QFQ_MAX +1 ] = { - [TCA_QFQ_WEIGHT ] = { .type =NLA_U32 }, - [TCA_QFQ_LMAX ] = { .type =NLA_U32 }, + [TCA_QFQ_WEIGHT ] =NLA_POLICY_RANGE (NLA_U32 ,1 ,QFQ_MAX_WEIGHT ), + [TCA_QFQ_LMAX ] =NLA_POLICY_FULL_RANGE (NLA_U32 , &lmax_range), };/*
@@ -408,17 +414,13 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, } err =nla_parse_nested_deprecated (tb,TCA_QFQ_MAX , tca[TCA_OPTIONS ], - qfq_policy,NULL ); + qfq_policy, extack);if (err <0 )return err; -if (tb[TCA_QFQ_WEIGHT ]) { +if (tb[TCA_QFQ_WEIGHT ]) weight =nla_get_u32 (tb[TCA_QFQ_WEIGHT ]); -if (!weight || weight > (1UL <<QFQ_MAX_WSHIFT )) { -pr_notice ("qfq: invalid weight %u\n" , weight); -return -EINVAL ; - } - }else +else weight =1 ;if (tb[TCA_QFQ_LMAX ])
@@ -426,11 +428,6 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,else lmax =psched_mtu (qdisc_dev (sch)); -if (lmax <QFQ_MIN_LMAX || lmax > (1UL <<QFQ_MTU_SHIFT )) { -pr_notice ("qfq: invalid max length %u\n" , lmax); -return -EINVAL ; - } - inv_w =ONE_FP / weight; weight =ONE_FP / inv_w;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 441/532 net/sched: sch_qfq: account for stab overhead in qfq_enqueue
In reply to Greg Kroah-HartmanFrom: Pedro Tammela <[email protected]>
[ Upstream commit 3e337087c3b5805fe0b8a46ba622a962880b5d64 ]
Lion says:
-------
In the QFQ scheduler a similar issue to CVE-2023-31436 persists.
Consider the following code in net/sched/sch_qfq.c:
static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free)
{
unsigned int len = qdisc_pkt_len(skb), gso_segs;
// ...
if (unlikely(cl->agg->lmax < len)) {
pr_debug("qfq: increasing maxpkt from %u to %u for class %u",
cl->agg->lmax, len, cl->common.classid);
err = qfq_change_agg(sch, cl, cl->agg->class_weight, len);
if (err) {
cl->qstats.drops++;
return qdisc_drop(skb, sch, to_free);
}
// ...
}Similarly to CVE-2023-31436, "lmax" is increased without any bounds checks according to the packet length "len". Usually this would not impose a problem because packet sizes are naturally limited.
This is however not the actual packet length, rather the "qdisc_pkt_len(skb)" which might apply size transformations according to "struct qdisc_size_table" as created by "qdisc_get_stab()" in net/sched/sch_api.c if the TCA_STAB option was set when modifying the qdisc.
A user may choose virtually any size using such a table.
As a result the same issue as in CVE-2023-31436 can occur, allowing heap out-of-bounds read / writes in the kmalloc-8192 cache.
-------
We can create the issue with the following commands:
tc qdisc add dev $DEV root handle 1: stab mtu 2048 tsize 512 mpu 0 \
overhead 999999999 linklayer ethernet qfq
tc class add dev $DEV parent 1: classid 1:1 htb rate 6mbit burst 15k tc filter add dev $DEV parent 1: matchall classid 1:1 ping -I $DEV 1.1.1.2
This is caused by incorrectly assuming that qdisc_pkt_len() returns a length within the QFQ_MIN_LMAX < len < QFQ_MAX_LMAX.
--- net/sched/sch_qfq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/sched/sch_qfq.c +6 -1
@@ -381,8 +381,13 @@ static int qfq_change_agg(struct Qdisc *sch, struct qfq_class *cl, u32 weight, u32 lmax) {struct qfq_sched *q =qdisc_priv (sch); -struct qfq_aggregate *new_agg =qfq_find_agg (q, lmax, weight); +struct qfq_aggregate *new_agg; +/* 'lmax' can range from [QFQ_MIN_LMAX, pktlen + stab overhead] */ +if (lmax >QFQ_MAX_LMAX ) +return -EINVAL ; + + new_agg =qfq_find_agg (q, lmax, weight);if (new_agg ==NULL ) {/* create new aggregate */ new_agg =kzalloc (sizeof (*new_agg),GFP_ATOMIC );if (new_agg ==NULL )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 442/532 nvme-pci: remove nvme_queue from nvme_iod
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit a53232cb3abef51524f06ee9d8fbc3364ad95794 ]
We can get the nvme_queue from the req just as easily, so remove the duplicate path to the same structure to save some space.
Stable-dep-of: b8f6446b6853 ("nvme-pci: fix DMA direction of unmapping integrity data")
--- drivers/nvme/host/pci.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/nvme/host/pci.c +13 -15
@@ -224,7 +224,6 @@ struct nvme_queue {struct nvme_iod {struct nvme_request req;struct nvme_command cmd; -struct nvme_queue *nvmeq;bool use_sgl;int aborted;int npages;/* In the PRP list. 0 means small pool in use */
@@ -422,11 +421,6 @@ static int nvme_init_request(struct blk_mq_tag_set *set, struct request *req, {struct nvme_dev *dev = set->driver_data;struct nvme_iod *iod =blk_mq_rq_to_pdu (req); -int queue_idx = (set == &dev->tagset) ? hctx_idx +1 :0 ; -struct nvme_queue *nvmeq = &dev->queues[queue_idx]; - -BUG_ON (!nvmeq); - iod->nvmeq = nvmeq;nvme_req (req)->ctrl = &dev->ctrl;nvme_req (req)->cmd = &iod->cmd;
@@ -529,7 +523,7 @@ static void **nvme_pci_iod_list(struct request *req)static inline bool nvme_pci_use_sgls (struct nvme_dev *dev,struct request *req) { -struct nvme_iod *iod =blk_mq_rq_to_pdu (req); +struct nvme_queue *nvmeq = req->mq_hctx->driver_data;int nseg =blk_rq_nr_phys_segments (req);unsigned int avg_seg_size;
@@ -537,7 +531,7 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)if (!nvme_ctrl_sgl_supported (&dev->ctrl))return false; -if (!iod->nvmeq->qid) +if (!nvmeq->qid)return false;if (!sgl_threshold || avg_seg_size < sgl_threshold)return false;
@@ -846,6 +840,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,int nr_mapped;if (blk_rq_nr_phys_segments (req) ==1 ) { +struct nvme_queue *nvmeq = req->mq_hctx->driver_data;struct bio_vec bv =req_bvec (req);if (!is_pci_p2pdma_page (bv.bv_page)) {
@@ -853,7 +848,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,return nvme_setup_prp_simple (dev, req, &cmnd->rw, &bv); -if (iod->nvmeq->qid && sgl_threshold && +if (nvmeq->qid && sgl_threshold &&nvme_ctrl_sgl_supported (&dev->ctrl))return nvme_setup_sgl_simple (dev, req, &cmnd->rw, &bv);
@@ -963,12 +958,16 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,static void nvme_pci_complete_rq (struct request *req) { -struct nvme_iod *iod =blk_mq_rq_to_pdu (req); -struct nvme_dev *dev = iod->nvmeq->dev; +struct nvme_queue *nvmeq = req->mq_hctx->driver_data; +struct nvme_dev *dev = nvmeq->dev; + +if (blk_integrity_rq (req)) { +struct nvme_iod *iod =blk_mq_rq_to_pdu (req); -if (blk_integrity_rq (req))dma_unmap_page (dev->dev, iod->meta_dma,rq_integrity_vec (req)->bv_len,rq_data_dir (req)); + } +if (blk_rq_nr_phys_segments (req))nvme_unmap_data (dev, req);nvme_complete_rq (req);
@@ -1194,8 +1193,7 @@ static int adapter_delete_sq(struct nvme_dev *dev, u16 sqid)static void abort_endio (struct request *req,blk_status_t error) { -struct nvme_iod *iod =blk_mq_rq_to_pdu (req); -struct nvme_queue *nvmeq = iod->nvmeq; +struct nvme_queue *nvmeq = req->mq_hctx->driver_data;dev_warn (nvmeq->dev->ctrl.device,"Abort status: 0x%x" ,nvme_req (req)->status);
@@ -1249,7 +1247,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)static enum blk_eh_timer_return nvme_timeout (struct request *req,bool reserved) {struct nvme_iod *iod =blk_mq_rq_to_pdu (req); -struct nvme_queue *nvmeq = iod->nvmeq; +struct nvme_queue *nvmeq = req->mq_hctx->driver_data;struct nvme_dev *dev = nvmeq->dev;struct request *abort_req;struct nvme_command cmd = { };
Signature · 1 line
2.39.2