7.1.5-rc1 review
Subsystems (15)
Greg Kroah-Hartman
maintainerPATCH 1473/2077 net/liquidio: drop cached VF pci_dev LUT
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 5c0e3ba4f500fd4314ceb42f07f16bc445156431 ]
The PF SR-IOV enable path caches VF pci_dev pointers in dpiring_to_vfpcidev_lut[] by iterating with pci_get_device(). Those entries do not own a reference, because the iterator drops the previous device reference on each step. The cached pointer is then dereferenced later when handling OCTEON_VF_FLR_REQUEST.
Replace the cached VF mapping with runtime lookup on the mailbox DPI
ring: derive the VF index from q_no, resolve the VF via exported PCI IOV helpers, validate it with the PF pointer and VF ID, then issue pcie_flr() and drop the reference with pci_dev_put(). Remove the unused VF lookup table initialization and cleanup.
--- .../net/ethernet/cavium/liquidio/lio_main.c | 27 --------------- .../ethernet/cavium/liquidio/octeon_device.h | 3 -- .../ethernet/cavium/liquidio/octeon_mailbox.c | 33 ++++++++++++++++++- 3 files changed, 32 insertions(+), 31 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +0 -27
@@ -3781,9 +3781,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)static int octeon_enable_sriov (struct octeon_device *oct) {unsigned int num_vfs_alloced = oct->sriov_info.num_vfs_alloced; -struct pci_dev *vfdev;int err; -u32 u;if (OCTEON_CN23XX_PF (oct) && num_vfs_alloced) { err = pci_enable_sriov(oct->pci_dev,
@@ -3796,23 +3794,6 @@ static int octeon_enable_sriov(struct octeon_device *oct)return err; } oct->sriov_info.sriov_enabled =1 ; - -/* init lookup table that maps DPI ring number to VF pci_dev -* struct pointer -*/ - u =0 ; - vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , -OCTEON_CN23XX_VF_VID ,NULL ); -while (vfdev) { -if (vfdev->is_virtfn && - (vfdev->physfn == oct->pci_dev)) { - oct->sriov_info.dpiring_to_vfpcidev_lut[u] = - vfdev; - u += oct->sriov_info.rings_per_vf; - } - vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , -OCTEON_CN23XX_VF_VID , vfdev); - } }return num_vfs_alloced;
@@ -3820,8 +3801,6 @@ static int octeon_enable_sriov(struct octeon_device *oct)static int lio_pci_sriov_disable (struct octeon_device *oct) { -int u; -if (pci_vfs_assigned (oct->pci_dev)) {dev_err (&oct->pci_dev->dev,"VFs are still assigned to VMs.\n" );return -EPERM ;
@@ -3829,12 +3808,6 @@ static int lio_pci_sriov_disable(struct octeon_device *oct)pci_disable_sriov (oct->pci_dev); - u =0 ; -while (u <MAX_POSSIBLE_VFS ) { - oct->sriov_info.dpiring_to_vfpcidev_lut[u] =NULL ; - u += oct->sriov_info.rings_per_vf; - } - oct->sriov_info.num_vfs_alloced =0 ;dev_info (&oct->pci_dev->dev,"oct->pf_num:%d disabled VFs\n" , oct->pf_num);
drivers/net/ethernet/cavium/liquidio/octeon_device.h +0 -3
@@ -390,9 +390,6 @@ struct octeon_sriov_info {struct lio_trusted_vf trusted_vf; -/*lookup table that maps DPI ring number to VF pci_dev struct pointer*/ -struct pci_dev *dpiring_to_vfpcidev_lut[MAX_POSSIBLE_VFS ]; -u64 vf_macaddr[MAX_POSSIBLE_VFS ];u16 vf_vlantci[MAX_POSSIBLE_VFS ];
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c +32 -1
@@ -26,6 +26,31 @@#include "octeon_mailbox.h" #include "cn23xx_pf_device.h" +static struct pci_dev *lio_vf_pci_dev_by_qno (struct octeon_device *oct,u32 q_no) +{ +struct pci_dev *vfdev =NULL ; +int vfidx; + +if (!oct->sriov_info.rings_per_vf) +return NULL ; + +if (q_no % oct->sriov_info.rings_per_vf) +return NULL ; + + vfidx = q_no / oct->sriov_info.rings_per_vf; +if (vfidx >= oct->sriov_info.num_vfs_alloced) +return NULL ; + +while ((vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , +OCTEON_CN23XX_VF_VID , vfdev))) { +if (pci_physfn (vfdev) &&pci_physfn (vfdev) == oct->pci_dev && +pci_iov_vf_id (vfdev) == vfidx) +return vfdev; + } + +return NULL ; +} +/** * octeon_mbox_read: * @mbox: Pointer mailbox
@@ -237,6 +262,7 @@ static int octeon_mbox_process_cmd(struct octeon_mbox *mbox, struct octeon_mbox_cmd *mbox_cmd) {struct octeon_device *oct = mbox->oct_dev; +struct pci_dev *vfdev;switch (mbox_cmd->msg.s.cmd) {case OCTEON_VF_ACTIVE :
@@ -260,7 +286,12 @@ static int octeon_mbox_process_cmd(struct octeon_mbox *mbox,dev_info (&oct->pci_dev->dev,"got a request for FLR from VF that owns DPI ring %u\n" , mbox->q_no); -pcie_flr (oct->sriov_info.dpiring_to_vfpcidev_lut[mbox->q_no]); + vfdev =lio_vf_pci_dev_by_qno (oct, mbox->q_no); +if (!vfdev) +break ; + +pcie_flr (vfdev); +pci_dev_put (vfdev);break ;case OCTEON_PF_CHANGED_VF_MACADDR :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1474/2077 net: usb: lan78xx: disable VLAN filter in promiscuous mode
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enrico Pozzobon <[email protected]>
[ Upstream commit 60444706aa17616efc03190d099ac347e28b3d0a ]
The hardware VLAN filter (RFE_CTL_VLAN_FILTER_) drops VLAN-tagged frames whose VID has not been registered via lan78xx_vlan_rx_add_vid(). It is left enabled in promiscuous mode, so packet capture (e.g. tcpdump or Wireshark) does not see tagged frames for unregistered VIDs.
Clear the filter while the interface is promiscuous and restore it from NETIF_F_HW_VLAN_CTAG_FILTER otherwise. Enforce the same condition in lan78xx_set_features() so netdev_update_features() cannot re-enable the filter while promiscuous.
--- drivers/net/usb/lan78xx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/usb/lan78xx.c +14 -4
@@ -1499,6 +1499,17 @@ static void lan78xx_deferred_multicast_write(struct work_struct *param)return ; } +static void lan78xx_update_vlan_filter (struct lan78xx_priv *pdata, +struct net_device *netdev, +netdev_features_t features) +{ +if ((features &NETIF_F_HW_VLAN_CTAG_FILTER ) && + !(netdev->flags &IFF_PROMISC )) + pdata->rfe_ctl |=RFE_CTL_VLAN_FILTER_ ; +else + pdata->rfe_ctl &= ~RFE_CTL_VLAN_FILTER_ ; +} +static void lan78xx_set_multicast (struct net_device *netdev) {struct lan78xx_net *dev =netdev_priv (netdev);
@@ -1533,6 +1544,8 @@ static void lan78xx_set_multicast(struct net_device *netdev) } } +lan78xx_update_vlan_filter (pdata, dev->net, dev->net->features); +if (netdev_mc_count (dev->net)) {struct netdev_hw_addr *ha;int i;
@@ -3074,10 +3087,7 @@ static int lan78xx_set_features(struct net_device *netdev,else pdata->rfe_ctl &= ~RFE_CTL_VLAN_STRIP_ ; -if (features &NETIF_F_HW_VLAN_CTAG_FILTER ) - pdata->rfe_ctl |=RFE_CTL_VLAN_FILTER_ ; -else - pdata->rfe_ctl &= ~RFE_CTL_VLAN_FILTER_ ; +lan78xx_update_vlan_filter (pdata, netdev, features);spin_unlock_irqrestore (&pdata->rfe_ctl_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1475/2077 gpio: dwapb: Defer clock gating until noirq
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Wang <[email protected]>
[ Upstream commit d775b9451eb8f52021dea6483ad758fef81dbf1e ]
GPIO consumers such as gpio-keys can enable IRQ wake and adjust the wake trigger type from their suspend callbacks. If the DWAPB controller suspends first, masking interrupts and disabling its clocks in the normal suspend phase prevents that late wake configuration from reliably reaching the hardware. Systems with real DWAPB bus clocks then fail to wake from s2idle through GPIO keys.
Save the register context in the normal suspend callback, but defer IRQ masking and clock gating until suspend_noirq. At that point all consumers have finished configuring wake IRQs, so keep the clocks enabled when wake lines are armed and only gate them when no wake source is active. Resume_noirq reenables clocks, if they were gated, before the normal resume path restores registers.
Propagate wake requests to the parent irqchip while keeping the local wake mask in sync with failures.
--- drivers/gpio/gpio-dwapb.c | 79 +++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 12 deletions(-)
drivers/gpio/gpio-dwapb.c +67 -12
@@ -118,6 +118,7 @@ struct dwapb_gpio {unsigned int flags;struct reset_control *rst;struct clk_bulk_data clks[DWAPB_NR_CLOCKS ]; +bool clocks_on_for_wake; struct dwapb_gpio_port ports[] __counted_by(nr_ports); };
@@ -365,11 +366,24 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)struct dwapb_gpio *gpio =to_dwapb_gpio (gc);struct dwapb_context *ctx = gpio->ports[0 ].ctx;irq_hw_number_t bit =irqd_to_hwirq (d); +u32 wake_en = ctx->wake_en;if (enable) - ctx->wake_en |=BIT (bit); + wake_en |=BIT (bit);else - ctx->wake_en &= ~BIT (bit); + wake_en &= ~BIT (bit); + +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +if (d->parent_data && !!ctx->wake_en != !!wake_en) { +int err; + + err =irq_chip_set_wake_parent (d, enable); +if (err) +return err; + } +#endif + + ctx->wake_en = wake_en;return 0 ; }
@@ -749,6 +763,8 @@ static int dwapb_gpio_suspend(struct device *dev)int i; scoped_guard(gpio_generic_lock_irqsave, gen_gc) { + gpio->clocks_on_for_wake = false; +for (i =0 ; i < gpio->nr_ports; i++) {unsigned int offset;unsigned int idx = gpio->ports[i].idx;
@@ -770,11 +786,38 @@ static int dwapb_gpio_suspend(struct device *dev) ctx->int_pol =dwapb_read (gpio,GPIO_INT_POLARITY ); ctx->int_type =dwapb_read (gpio,GPIO_INTTYPE_LEVEL ); ctx->int_deb =dwapb_read (gpio,GPIO_PORTA_DEBOUNCE ); + } + } + } + +return 0 ; +} + +static int dwapb_gpio_suspend_noirq (struct device *dev) +{ +struct dwapb_gpio *gpio =dev_get_drvdata (dev); +struct gpio_generic_chip *gen_gc = &gpio->ports[0 ].chip; +bool wake_enabled = false; +int i; + + scoped_guard(gpio_generic_lock_irqsave, gen_gc) { +for (i =0 ; i < gpio->nr_ports; i++) { +unsigned int idx = gpio->ports[i].idx; +struct dwapb_context *ctx = gpio->ports[i].ctx; -/* Mask out interrupts */ +if (idx ==0 ) { + wake_enabled = ctx->wake_en;dwapb_write (gpio,GPIO_INTMASK , ~ctx->wake_en); +break ; } } + + gpio->clocks_on_for_wake = wake_enabled; + } + +if (wake_enabled) { +device_set_wakeup_path (dev); +return 0 ; }clk_bulk_disable_unprepare (DWAPB_NR_CLOCKS , gpio->clks);
@@ -782,18 +825,27 @@ static int dwapb_gpio_suspend(struct device *dev)return 0 ; } -static int dwapb_gpio_resume (struct device *dev) +static int dwapb_gpio_resume_noirq (struct device *dev) {struct dwapb_gpio *gpio =dev_get_drvdata (dev); -struct gpio_chip *gc = &gpio->ports[0 ].chip.gc; -struct gpio_generic_chip *gen_gc =to_gpio_generic_chip (gc); -int i, err; +int err; + +if (gpio->clocks_on_for_wake) +return 0 ; err =clk_bulk_prepare_enable (DWAPB_NR_CLOCKS , gpio->clks); -if (err) { +if (err)dev_err (gpio->dev,"Cannot reenable APB/Debounce clocks\n" ); -return err; - } + +return err; +} + +static int dwapb_gpio_resume (struct device *dev) +{ +struct dwapb_gpio *gpio =dev_get_drvdata (dev); +struct gpio_chip *gc = &gpio->ports[0 ].chip.gc; +struct gpio_generic_chip *gen_gc =to_gpio_generic_chip (gc); +int i;guard (gpio_generic_lock_irqsave)(gen_gc);
@@ -827,8 +879,11 @@ static int dwapb_gpio_resume(struct device *dev)return 0 ; } -static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, - dwapb_gpio_suspend, dwapb_gpio_resume); +static const struct dev_pm_ops dwapb_gpio_pm_ops = { + SYSTEM_SLEEP_PM_OPS(dwapb_gpio_suspend, dwapb_gpio_resume) +NOIRQ_SYSTEM_SLEEP_PM_OPS (dwapb_gpio_suspend_noirq, + dwapb_gpio_resume_noirq) +};static struct platform_driver dwapb_gpio_driver = { .driver = {
Signature · 1 line
2.53.0
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 23 Jul 2026 15:23:00 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v7.x/stable-review/patch-7.1.5-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-7.1.y
and the diffstat can be found below.thanks,
greg k-h
perf fails to build with:
In file included from builtin-sched.c:28:builtin-sched.c: In function 'latency_switch_event':
builtin-sched.c:1196:34: error: 'struct perf_sample' has no member named 'file_offset'
1196 | sample->file_offset, cpu);
| ^~
which is due to 6018a2a9ff1baa45426f7a52f8ec4f7d32fedfce ("perf sched: Replace BUG_ON on invalid CPU with graceful skip"), we need to backport a490187f22b4bfae7ef752edbe3fb13017ca11c ("perf sample: Add file_offset field to struct perf_sample")
Signature · 1 line
Florian
Quoted 27 lines · Florian Fainelli
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 23 Jul 2026 15:23:00 +0000. Anything received after that time might be too late.
Quoted 7 lines
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v7.x/stable-review/
patch-7.1.5-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-
rc.git linux-7.1.y
and the diffstat can be found below.perf fails to build with:
In file included from builtin-sched.c:28:
builtin-sched.c: In function 'latency_switch_event':
builtin-sched.c:1196:34: error: 'structperf_sample' has no member named 'file_offset'
1196 |sample->file_offset, cpu); | ^~
Quoted 4 lines
which is due to
6018a2a9ff1baa45426f7a52f8ec4f7d32fedfce("perf sched:
ReplaceBUG_ONon invalid CPU with graceful skip"), we need to backporta490187f22b4bfae7ef752edbe3fb13017ca11c("perf sample: Addfile_offsetfield to structperf_sample")
Was that enough to make perf build for you? I also ran into this error:
util/libdw.c: In function ‘libdw__addr2line’:util/libdw.c:204:25: error: implicit declaration of function ‘inline_node__clear_frames’ [-Wimplicit-function-declaration]
204 | inline_node__clear_frames(node);
| ^~~~~~~~~~~~~~~~~~~~~~~~~Which from a quick check was fixed by picking up 674dea094ef659 ("perf
srcline: Introduce inline_node__clear_frames()"). But then I ran into yet another error:
util/session.c: In function ‘perf_session__deliver_event’:util/session.c:1619:14: error: ‘evsel’ undeclared (first use in this function)
1619 | if ((evsel->core.attr.sample_type & PERF_SAMPLE_CPU) &&
| ^~~~~
util/session.c:1619:14: note: each undeclared identifier is reported only once for each function it appears in
Ciao, Thorsten
Greg Kroah-Hartman
maintainerQuoted 45 lines · Thorsten Leemhuis
Quoted 27 lines · Florian Fainelli
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 7.1.5 release. There are 2077 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 23 Jul 2026 15:23:00 +0000. Anything received after that time might be too late.
Quoted 7 lines
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v7.x/stable-review/
patch-7.1.5-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-
rc.git linux-7.1.y
and the diffstat can be found below.perf fails to build with:
In file included from builtin-sched.c:28:
builtin-sched.c: In function 'latency_switch_event':
builtin-sched.c:1196:34: error: 'structperf_sample' has no member named 'file_offset'
1196 |sample->file_offset, cpu); | ^~Quoted 4 lines
which is due to
6018a2a9ff1baa45426f7a52f8ec4f7d32fedfce("perf sched:
ReplaceBUG_ONon invalid CPU with graceful skip"), we need to backporta490187f22b4bfae7ef752edbe3fb13017ca11c("perf sample: Addfile_offsetfield to structperf_sample")Was that enough to make perf build for you? I also ran into this error:
util/libdw.c: In function ‘libdw__addr2line’:util/libdw.c:204:25: error: implicit declaration of function ‘inline_node__clear_frames’ [-Wimplicit-function-declaration]204 | inline_node__clear_frames(node); | ^~~~~~~~~~~~~~~~~~~~~~~~~Which from a quick check was fixed by picking up
674dea094ef659("perf
srcline: Introduceinline_node__clear_frames()"). But then I ran into yet another error:
Quoted 7 lines
util/session.c: In function ‘perf_session__deliver_event’:util/session.c:1619:14: error: ‘evsel’ undeclared (first use in this function)
1619 | if ((evsel->core.attr.sample_type&PERF_SAMPLE_CPU) &&| ^~~~~
util/session.c:1619:14: note: each undeclared identifier is reported only once for each function it appears in
Argh, I haven't checked perf builds in a long time. And yes, they are broken. Let me go fix these up for 6.18 and 7.1 and then drop all the perf patches for older kernels as systems should always be using the newest perf tool, not the older one, anyway.
I'll do that and then push out some -rc2 releases...
thanks,
greg k-h
Sasha Levin
maintainerQuoted 7 lines · Florian Fainelli
builtin-sched.c:1196:34: error: 'struct
perf_sample' has no member named 'file_offset'which is due to
6018a2a9ff1baa45426f7a52f8ec4f7d32fedfce("perf sched:
ReplaceBUG_ONon invalid CPU with graceful skip"), we need to backporta490187f22b4bfae7ef752edbe3fb13017ca11c("perf sample: Addfile_offsetfield to structperf_sample")
Greg has queued 7a490187f22b for 7.1 (ordered right before the perf-sched patch), so this is resolved for -rc2.
The other two perf build errors reported in this thread are covered as
well: the libdw.c inline_node__clear_frames() failure is fixed by 674dea094ef6 ("perf srcline: Introduce inline_node__clear_frames()"), which is now also queued.
Thorsten's third error ('evsel' undeclared in perf_session__deliver_event at util/session.c) doesn't apply to the queue itself: that code block comes from upstream a2e59fb79f449f ("perf session: Bound nr_cpus_avail and validate sample CPU"), which isn't queued for 7.1. His local cherry-pick of 7a490187f22b pulled in that surrounding context without the evsel declaration; the backport in the queue doesn't carry it. I verified the current queue's perf_session__deliver_event has no evsel reference and that perf from the current 7.1 queue builds cleanly, so -rc2 should be good.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 1476/2077 drm: Guard DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Mader <[email protected]>
[ Upstream commit ac7c6b4308c5e757eb278d47b9c0761c31ac9d6b ]
The client cap is currently advertised unconditionally, even for drivers that do not support plane color pipelines. If clients supporting the latter, like Wayland compositors or tools like drm_info, enable the client cap on such drivers they will be left without both color pipeline and the legacy properties COLOR_ENCODING and COLOR_RANGE, effectively breaking YUV->RGB conversion support.
Prevent that by only marking the cap supported if there are actually planes with color pipelines.
Note: while the color pipeline replacement for the legacy properties is still under review (1), we can assume that it will work as a drop-in replacement. That means any plane on any hardware currently supporting the legacy properties will be able to offer a functionally equal color pipeline and there will be no technical reason keep using the legacy properties if both the driver and the client support the new API.
[1] https://lore.kernel.org/dri-devel/[email protected]/
--- drivers/gpu/drm/drm_ioctl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_ioctl.c +13 -1
@@ -373,13 +373,25 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)return -EINVAL ; file_priv->supports_virtualized_cursor_plane = req->value;break ; -case DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE : +case DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE : { +struct drm_plane *plane; +bool has_plane_with_color_pipeline = false; +if (!file_priv->atomic)return -EINVAL ;if (req->value >1 )return -EINVAL ; +drm_for_each_plane (plane, dev) { +if (plane->color_pipeline_property) { + has_plane_with_color_pipeline = true; +break ; + } + } +if (!has_plane_with_color_pipeline) +return -EOPNOTSUPP ; file_priv->plane_color_pipeline = req->value;break ; + }default :return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/2077 tracing: Make tracepoint_printk static as not exported
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Dooks <[email protected]>
[ Upstream commit d5c6785f94ead7cd76b38af301ac63cb673485bc ]
The tracepoint_printk symbol is not exported, so make it static to remove the following sparse warning:
kernel/trace/trace.c:90:5: warning: symbol 'tracepoint_printk' was not declared. Should it be static?
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -87,7 +87,7 @@ void __init disable_tracing_selftest(const char *reason)/* Pipe tracepoints to printk */ static struct trace_iterator *tracepoint_print_iter; -int tracepoint_printk; +static int tracepoint_printk;static bool tracepoint_printk_stop_on_boot__initdata ;static bool traceoff_after_boot__initdata ;static DEFINE_STATIC_KEY_FALSE (tracepoint_printk_key);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/2077 accel/amdxdna: Fix potential amdxdna_umap lifetime race
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Hou <[email protected]>
[ Upstream commit 14f172eff9c19f8043a9858845f33cd034f3a41e ]
amdxdna_umap_release() calls the blocking mmu_interval_notifier_remove() before removing the object from abo->mem.umap_list. If aie2_populate_range() runs concurrently, it may obtain a reference to an amdxdna_umap that is being released, leading to a potential use-after-free.
Use kref_get_unless_zero() in aie2_populate_range() when acquiring a reference. If the reference count has already dropped to zero, release is in progress and the entry is skipped.
--- drivers/accel/amdxdna/aie2_ctx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +2 -2
@@ -963,7 +963,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo) found = false;down_write (&xdna->notifier_lock);list_for_each_entry (mapp, &abo->mem.umap_list, node) { -if (mapp->invalid) { +if (mapp->invalid &&kref_get_unless_zero (&mapp->refcnt)) { found = true;break ; }
@@ -974,7 +974,7 @@ static int aie2_populate_range(struct amdxdna_gem_obj *abo)up_write (&xdna->notifier_lock);return 0 ; } -kref_get (&mapp->refcnt); +up_write (&xdna->notifier_lock); mm = mapp->notifier.mm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/2077 drm/v3d: Reject invalid indirect BO handle in indirect CSD setup
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit 2f8b8593c7832fad655290cef9e99af05b1b52b3 ]
v3d_get_cpu_indirect_csd_params() looks up the indirect buffer object from a userspace-supplied handle but never checks the result. A bogus or stale handle makes drm_gem_object_lookup() return NULL, which is then stored in info->indirect and only dereferenced later when the indirect CSD job runs, turning a userspace mistake into a NULL pointer dereference in the kernel.
Bail out with -ENOENT as soon as the lookup fails, so the bad handle is rejected at submission time.
--- drivers/gpu/drm/v3d/v3d_submit.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/v3d/v3d_submit.c +2 -0
@@ -484,6 +484,8 @@ v3d_get_cpu_indirect_csd_params(struct drm_file *file_priv, sizeof(indirect_csd.wg_uniform_offsets)); info->indirect =drm_gem_object_lookup (file_priv, indirect_csd.indirect); +if (!info->indirect) +return -ENOENT ; return v3d_setup_csd_jobs_and_bos(file_priv, v3d, &indirect_csd.submit, &info->job, &info->clean_job,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1480/2077 selftests: gpio: add gpio-cdev-uaf to .gitignore
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cihan Karadag <[email protected]>
[ Upstream commit 4ad805f0e41acf56ac54855c666d34c59ad66fe7 ]
Commit c7f92042d3f3 ("selftests: gpio: Add gpio-cdev-uaf tests") added the gpio-cdev-uaf binary to TEST_GEN_PROGS_EXTENDED but never added it to .gitignore. Building it with:
make -C tools/testing/selftests/gpio TARGETS=gpio
leaves gpio-cdev-uaf as an untracked file.
--- tools/testing/selftests/gpio/.gitignore | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/gpio/.gitignore +1 -0
@@ -2,3 +2,4 @@ gpio-mockup-cdev gpio-chip-info gpio-line-name +gpio-cdev-uaf
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1481/2077 net: mdio: select REGMAP_MMIO instead of depending on it
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 1a3267a8c9ecabb8e27f5cbda6d19295d5e41beb ]
REGMAP_MMIO is a hidden (non-user-visible) tristate symbol. Using depends on it is incorrect because there is no way for the user to enable it directly. Change to select, which is the convention used by every other driver in the tree that needs REGMAP_MMIO.
--- drivers/net/mdio/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mdio/Kconfig +2 -1
@@ -122,7 +122,8 @@ config MDIO_MVUSB config MDIO_MSCC_MIIM tristate "Microsemi MIIM interface support" - depends on HAS_IOMEM && REGMAP_MMIO + depends on HAS_IOMEM + select REGMAP_MMIO help This driver supports the MIIM (MDIO) interface found in the network switches of the Microsemi SoCs; it is recommended to switch on
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/2077 net/sched: cake: reject overhead values that underflow length
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit b7f97cae7ec1b6c3c32843c42be218690d310467 ]
CAKE accepts signed overhead values and stores them in an s16, but the adjusted packet length calculation uses unsigned arithmetic. A negative effective length can therefore wrap to a large value.
Such configurations make rate accounting depend on integer wraparound rather than on the packet size userspace intended to model. A static netlink lower bound is not enough because packets reaching CAKE can be smaller than any reasonable manual-overhead allowance.
Fold the signed overhead adjustment into the existing datapath MPU clamp so negative adjusted lengths are clamped before link-layer framing adjustments.
--- net/sched/sch_cake.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/sched/sch_cake.c +1 -4
@@ -1389,10 +1389,7 @@ static u32 cake_calc_overhead(struct cake_sched_data *qd, u32 len, u32 off)if (qd->min_netlen > len)WRITE_ONCE (qd->min_netlen, len); - len += q->rate_overhead; - -if (len < q->rate_mpu) - len = q->rate_mpu; + len =max ((s32 )len + q->rate_overhead, (s32 )q->rate_mpu);if (q->atm_mode ==CAKE_ATM_ATM ) { len +=47 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1483/2077 octeontx2-pf: check DMAC extraction support before filtering
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit 235acadd310533ba386ae61ad155b72bee381559 ]
Currently, configuring a VF MAC address via the PF (e.g., 'ip link set <pf> vf 0 mac <mac>') blindly attempts to install a DMAC-based hardware filter. However, the hardware parser profile might not support DMAC extraction.
Check if the hardware parsing profile supports DMAC extraction before adding the filter. Additionally, emit a warning message to inform the operator if the MAC filter installation fails due to missing DMAC extraction support. Update config->mac only after hardware programming succeeds in otx2_set_vf_mac().
--- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +37 -6
@@ -2521,10 +2521,42 @@ EXPORT_SYMBOL(otx2_config_hwtstamp_set);static int otx2_do_set_vf_mac (struct otx2_nic *pf,int vf,const u8 *mac) { +struct npc_get_field_status_req *freq; +struct npc_get_field_status_rsp *frsp;struct npc_install_flow_req *req;int err;mutex_lock (&pf->mbox.lock); + +/* Skip installing the DMAC filter if the hardware parser profile +* does not support DMAC extraction. +*/ + freq =otx2_mbox_alloc_msg_npc_get_field_status (&pf->mbox); +if (!freq) { + err = -ENOMEM ; + goto out; + } + + freq->field =NPC_DMAC ; + err =otx2_sync_mbox_msg (&pf->mbox); +if (err) + goto out; + + frsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp + (&pf->mbox.mbox,0 , &freq->hdr); +if (IS_ERR (frsp)) { + err =PTR_ERR (frsp); + goto out; + } + +if (!frsp->enable) { +netdev_warn (pf->netdev, +"VF %d MAC filter not installed: DMAC extraction not supported by parser profile\n" , + vf); + err = -EOPNOTSUPP ; + goto out; + } + req =otx2_mbox_alloc_msg_npc_install_flow (&pf->mbox);if (!req) { err = -ENOMEM ;
@@ -2563,13 +2595,12 @@ static int otx2_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)if (!is_valid_ether_addr (mac))return -EINVAL ; - config = &pf->vf_configs[vf]; -ether_addr_copy (config->mac, mac); - ret =otx2_do_set_vf_mac (pf, vf, mac); -if (ret ==0 ) -dev_info (&pdev->dev, -"Load/Reload VF driver\n" ); +if (ret ==0 ) { + config = &pf->vf_configs[vf]; +ether_addr_copy (config->mac, mac); +dev_info (&pdev->dev,"Load/Reload VF driver\n" ); + }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1484/2077 perf/x86/amd/core: Avoid enabling BRS from the SVM reload path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 07c60dda9c059c09f83d42a3ebda2e7cc1cf3bc2 ]
Branch Sampling (BRS) and Last Branch Record (LBR) are mutually exclusive hardware features, and users of both are tracked via cpuc->lbr_users.
When SVM is toggled on a CPU, the host perf events are reprogrammed to update the HostOnly filter bit (set when virtualization is enabled, cleared when it is disabled). On PerfMonV2-capable processors, this reprogramming is performed by calling amd_pmu_enable_all() to rewrite the event selectors. However, amd_pmu_enable_all() also calls amd_brs_enable_all(), which enables BRS whenever cpuc->lbr_users > 0. Having active LBR events satisfies this gating on processors that have LBR but not BRS. The kernel then tries to set the BRS enable bit in DebugExtnCfg (MSR 0xc000010f). Since that bit is deprecated on such hardware, the write results in a #GP:
Call Trace: <IRQ> amd_pmu_enable_all+0x1d/0x90 amd_pmu_disable_virt+0x62/0xb0 kvm_arch_disable_virtualization_cpu+0xa/0x40 [kvm] hardware_disable_nolock+0x1a/0x30 [kvm] __flush_smp_call_function_queue+0x9b/0x410 __sysvec_call_function+0x18/0xc0 sysvec_call_function+0x69/0x90 </IRQ> <TASK> asm_sysvec_call_function+0x16/0x20 RIP: 0010:cpuidle_enter_state+0xc4/0x450 ? cpuidle_enter_state+0xb7/0x450 cpuidle_enter+0x29/0x40 cpuidle_idle_call+0xf5/0x160 do_idle+0x7b/0xe0 cpu_startup_entry+0x26/0x30 start_secondary+0x115/0x140 secondary_startup_64_no_verify+0x194/0x19b </TASK>
Fix this by ensuring that BRS is not enabled from the event selector reprogramming path even when cpuc->lbr_users > 0.
--- arch/x86/events/amd/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/events/amd/core.c +8 -4
@@ -752,13 +752,11 @@ static void amd_pmu_enable_event(struct perf_event *event)x86_pmu_enable_event (event); } -static void amd_pmu_enable_all (int added) +static void __amd_pmu_enable_all (void ) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);int idx; -amd_brs_enable_all (); -for_each_set_bit (idx, x86_pmu.cntr_mask,X86_PMC_IDX_MAX ) {/* only activate events which are marked as active */ if (!test_bit (idx, cpuc->active_mask))
@@ -773,6 +771,12 @@ static void amd_pmu_enable_all(int added) } } +static void amd_pmu_enable_all (int added) +{ +amd_brs_enable_all (); +__amd_pmu_enable_all (); +} +static void amd_pmu_v2_enable_event (struct perf_event *event) {struct hw_perf_event *hwc = &event->hw;
@@ -1559,7 +1563,7 @@ static inline void amd_pmu_reload_virt(void)* set global enable bits once again */ amd_pmu_v2_disable_all (); -amd_pmu_enable_all (0 ); +__amd_pmu_enable_all ();amd_pmu_v2_enable_all (0 );return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1485/2077 gpio: mvebu: free generic chips on unbind
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit b11c513ad943f35cf5e8007d3a56279c79b7ed4b ]
irq_alloc_domain_generic_chips() allocates generic chip data that must be freed via irq_domain_remove_generic_chips(). The devres action mvebu_gpio_remove_irq_domain() only called irq_domain_remove(), which only frees the generic chips if IRQ_DOMAIN_FLAG_DESTROY_GC is set. Call irq_domain_remove_generic_chips() explicitly before irq_domain_remove() instead.
--- drivers/gpio/gpio-mvebu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-mvebu.c +1 -0
@@ -1110,6 +1110,7 @@ static void mvebu_gpio_remove_irq_domain(void *data) {struct irq_domain *domain = data; +irq_domain_remove_generic_chips (domain);irq_domain_remove (domain); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1486/2077 ipv4: igmp: Fix potential UAF in igmp_gq_start_timer()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 7b19c0f81ed1fdaec6bc522569be367199a9edf3 ]
A race condition exists between device teardown (inetdev_destroy) and incoming IGMP query processing (igmp_rcv), leading to a Use-After-Free in the IGMP timer callback.
During device destruction, inetdev_destroy() drops the primary reference to in_device, which can drop its refcount to 0. The actual freeing of in_device memory is deferred via RCU (using call_rcu()).
Concurrently, igmp_rcv() runs under RCU read lock and obtains the in_device pointer. Because the memory is RCU-protected, CPU-0 can safely dereference in_device even if its refcount has hit 0.
However, if CPU-0 calls igmp_gq_start_timer() and re-arms the timer, it attempts to acquire a reference using in_dev_hold(). This increments the refcount from 0 to 1, triggering a "refcount_t: addition on 0" warning. Since the in_device memory is still scheduled to be freed after the RCU grace period (as the free callback does not check the refcount again), the device is freed while the timer is still armed. When the timer expires, it accesses the freed memory, causing a kernel panic.
Fix this by using refcount_inc_not_zero() (via a new helper in_dev_hold_safe()) to prevent acquiring a reference if the device is already being destroyed. If the refcount is 0, we do not arm the timer.
A similar issue in IPv6 MLD is fixed in a subsequent patch.
--- include/linux/inetdevice.h | 5 +++++ net/ipv4/igmp.c | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
include/linux/inetdevice.h +5 -0
@@ -293,6 +293,11 @@ static inline void in_dev_put(struct in_device *idev)#define __in_dev_put (idev) refcount_dec(&(idev)->refcnt)#define in_dev_hold (idev) refcount_inc(&(idev)->refcnt) +static inline bool in_dev_hold_safe (struct in_device *idev) +{ +return refcount_inc_not_zero (&idev->refcnt); +} +#endif /* __KERNEL__ */ static __inline____be32 inet_make_mask (int logmask)
net/ipv4/igmp.c +9 -5
@@ -248,16 +248,20 @@ static void igmp_gq_start_timer(struct in_device *in_dev)return ; in_dev->mr_gq_running =1 ; -if (!mod_timer (&in_dev->mr_gq_timer, exp)) -in_dev_hold (in_dev); +if (in_dev_hold_safe (in_dev)) { +if (mod_timer (&in_dev->mr_gq_timer, exp)) +in_dev_put (in_dev); + } }static void igmp_ifc_start_timer (struct in_device *in_dev,int delay) { -int tv =get_random_u32_below (delay); +if (in_dev_hold_safe (in_dev)) { +int tv =get_random_u32_below (delay); -if (!mod_timer (&in_dev->mr_ifc_timer, jiffies+tv+2 )) -in_dev_hold (in_dev); +if (mod_timer (&in_dev->mr_ifc_timer, jiffies + tv +2 )) +in_dev_put (in_dev); + } }static void igmp_mod_timer (struct ip_mc_list *im,int max_delay)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1487/2077 ipv6: mcast: Fix potential UAF in MLD delayed work
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9b26518b6896a16b809b1e42986f4ebac7bccc1e ]
A race condition exists between device teardown and incoming MLD query processing, leading to a Use-After-Free in the MLD delayed work.
During device destruction, the primary reference to inet6_dev is dropped, which can drop its refcount to 0. The actual freeing of inet6_dev memory is deferred via RCU.
Concurrently, the packet receive path runs under RCU read lock and obtains the inet6_dev pointer. Because the memory is RCU-protected, CPU-0 can safely dereference inet6_dev even if its refcount has hit 0.
However, if CPU-0 calls igmp6_event_query() and schedules delayed work, it attempts to acquire a reference using in6_dev_hold(). This increments the refcount from 0 to 1, triggering a "refcount_t: addition on 0" warning. Since the inet6_dev memory is still scheduled to be freed after the RCU grace period, the device is freed while the work is still scheduled. When the work runs, it accesses the freed memory, causing a kernel panic.
Fix this by using refcount_inc_not_zero() (via a new helper in6_dev_hold_safe()) to prevent acquiring a reference if the device is already being destroyed. If the refcount is 0, we do not schedule the work.
--- include/net/addrconf.h | 5 +++++ net/ipv6/mcast.c | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 12 deletions(-)
include/net/addrconf.h +5 -0
@@ -446,6 +446,11 @@ static inline void in6_dev_hold(struct inet6_dev *idev)refcount_inc (&idev->refcnt); } +static inline bool in6_dev_hold_safe (struct inet6_dev *idev) +{ +return refcount_inc_not_zero (&idev->refcnt); +} +/* called with rcu_read_lock held */ static inline bool ip6_ignore_linkdown (const struct net_device *dev) {
net/ipv6/mcast.c +28 -12
@@ -1080,8 +1080,10 @@ static void mld_gq_start_work(struct inet6_dev *idev)mc_assert_locked (idev); idev->mc_gq_running =1 ; -if (!mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_gq_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_gq_stop_work (struct inet6_dev *idev)
@@ -1099,8 +1101,10 @@ static void mld_ifc_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_ifc_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_ifc_stop_work (struct inet6_dev *idev)
@@ -1118,8 +1122,10 @@ static void mld_dad_start_work(struct inet6_dev *idev, unsigned long delay)mc_assert_locked (idev); -if (!mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) -in6_dev_hold (idev); +if (in6_dev_hold_safe (idev)) { +if (mod_delayed_work (mld_wq, &idev->mc_dad_work, tv +2 )) +in6_dev_put (idev); + } }static void mld_dad_stop_work (struct inet6_dev *idev)
@@ -1405,18 +1411,23 @@ static void mld_process_v2(struct inet6_dev *idev, struct mld2_query *mld,void igmp6_event_query (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_query_lock); -if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_query_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_query_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_query_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_query_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
@@ -1573,18 +1584,23 @@ static void mld_query_work(struct work_struct *work)void igmp6_event_report (struct sk_buff *skb) {struct inet6_dev *idev =__in6_dev_get (skb->dev); +bool put = false;if (!idev || idev->dead) goto out;spin_lock_bh (&idev->mc_report_lock); -if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS ) { +if (skb_queue_len (&idev->mc_report_queue) <MLD_MAX_SKBS && +in6_dev_hold_safe (idev)) {__skb_queue_tail (&idev->mc_report_queue, skb); -if (!mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) -in6_dev_hold (idev); +if (mod_delayed_work (mld_wq, &idev->mc_report_work,0 )) + put = true; skb =NULL ; }spin_unlock_bh (&idev->mc_report_lock); + +if (put) +in6_dev_put (idev); out:kfree_skb (skb); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1488/2077 ipv4: igmp: annotate data-races around im->users
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 061c0aa740d5d3847cd600a74c66a165bee1fbe0 ]
/proc/net/igmp walks IPv4 multicast memberships under RCU and prints im->users without holding RTNL, while multicast join and leave paths update the field while holding RTNL. Annotate this intentional lockless snapshot with READ_ONCE() and the matching writers with WRITE_ONCE().
Stable-dep-of: 3546deaa0c30 ("ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()")
--- net/ipv4/igmp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/igmp.c +7 -4
@@ -1545,7 +1545,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr, }if (im) { - im->users++; +WRITE_ONCE (im->users, im->users +1 );ip_mc_add_src (in_dev, &addr, mode,0 ,NULL ,0 ); goto out; }
@@ -1554,7 +1554,7 @@ static void ____ip_mc_inc_group(struct in_device *in_dev, __be32 addr,if (!im) goto out; - im->users =1 ; +WRITE_ONCE (im->users,1 ); im->interface = in_dev;in_dev_hold (in_dev); im->multiaddr = addr;
@@ -1788,7 +1788,10 @@ void __ip_mc_dec_group(struct in_device *in_dev, __be32 addr, gfp_t gfp) (i =rtnl_dereference (*ip)) !=NULL ; ip = &i->next_rcu) {if (i->multiaddr == addr) { -if (--i->users ==0 ) { +int new_users = i->users -1 ; + +WRITE_ONCE (i->users, new_users); +if (new_users ==0 ) {ip_mc_hash_remove (in_dev, i); *ip = i->next_rcu; in_dev->mc_count--;
@@ -2982,7 +2985,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) delta = im->timer.expires - jiffies;seq_printf (seq,"\t\t\t\t%08X %5d %d:%08lX\t\t%d\n" , - im->multiaddr, im->users, + im->multiaddr,READ_ONCE (im->users), im->tm_running, im->tm_running ?jiffies_delta_to_clock_t (delta) :0 , im->reporter);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/2077 ipv4: igmp: annotate data-races around timer-related fields
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuyang Huang <[email protected]>
[ Upstream commit 3289d17b7a1321e103b8aec4ad82675c03c4764f ]
/proc/net/igmp walks the multicast list locklessly under RCU and reads timer-related fields (im->tm_running, im->reporter, im->timer.expires) to print the timer state of multicast memberships. Concurrently, these fields are modified under im->lock spinlock in timer management paths (igmp_stop_timer(), igmp_start_timer(), and igmp_timer_expire()). Fix this intentional lockless snapshot by annotating the lockless reads with READ_ONCE() and the updates with WRITE_ONCE().
Stable-dep-of: 3546deaa0c30 ("ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()")
--- net/ipv4/igmp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
net/ipv4/igmp.c +13 -11
@@ -220,8 +220,8 @@ static void igmp_stop_timer(struct ip_mc_list *im)spin_lock_bh (&im->lock);if (timer_delete (&im->timer))refcount_dec (&im->refcnt); - im->tm_running =0 ; - im->reporter =0 ; +WRITE_ONCE (im->tm_running,0 ); +WRITE_ONCE (im->reporter,0 ); im->unsolicit_count =0 ;spin_unlock_bh (&im->lock); }
@@ -231,7 +231,7 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay) {int tv =get_random_u32_below (max_delay); - im->tm_running =1 ; +WRITE_ONCE (im->tm_running,1 );if (refcount_inc_not_zero (&im->refcnt)) {if (mod_timer (&im->timer, jiffies + tv +2 ))ip_ma_put (im);
@@ -271,7 +271,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)if (timer_delete (&im->timer)) {if ((long )(im->timer.expires-jiffies) < max_delay) {add_timer (&im->timer); - im->tm_running =1 ; +WRITE_ONCE (im->tm_running,1 );spin_unlock_bh (&im->lock);return ; }
@@ -861,12 +861,12 @@ static void igmp_timer_expire(struct timer_list *t)struct in_device *in_dev = im->interface;spin_lock (&im->lock); - im->tm_running =0 ; +WRITE_ONCE (im->tm_running,0 );if (im->unsolicit_count && --im->unsolicit_count)igmp_start_timer (im,unsolicited_report_interval (in_dev)); - im->reporter =1 ; +WRITE_ONCE (im->reporter,1 );spin_unlock (&im->lock);if (IGMP_V1_SEEN (in_dev))
@@ -1329,7 +1329,7 @@ static void __igmp_group_dropped(struct ip_mc_list *im, gfp_t gfp) !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; - reporter = im->reporter; + reporter =READ_ONCE (im->reporter);igmp_stop_timer (im);if (!in_dev->dead) {
@@ -2967,6 +2967,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v)struct ip_mc_list *im = v;struct igmp_mc_iter_state *state =igmp_mc_seq_private (seq);char *querier; +int tm_running;long delta;#ifdef CONFIG_IP_MULTICAST
@@ -2982,13 +2983,14 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) state->dev->ifindex, state->dev->name, state->in_dev->mc_count, querier); } - delta = im->timer.expires - jiffies; + tm_running =READ_ONCE (im->tm_running); + delta =READ_ONCE (im->timer.expires) - jiffies;seq_printf (seq,"\t\t\t\t%08X %5d %d:%08lX\t\t%d\n" , im->multiaddr,READ_ONCE (im->users), - im->tm_running, - im->tm_running ?jiffies_delta_to_clock_t (delta) :0 , - im->reporter); + tm_running, + tm_running ?jiffies_delta_to_clock_t (delta) :0 , +READ_ONCE (im->reporter)); }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1490/2077 ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 3546deaa0c30a14c7cdb5dc8f2432cb428f0cd36 ]
When a timer is deleted and not re-armed in igmp_mod_timer(), or stopped in igmp_stop_timer(), the code currently decrements the reference counter of the multicast list entry @im using refcount_dec(&im->refcnt).
However, both functions can be called from the RCU reader path:
- igmp_mod_timer() via igmp_heard_query() -> for_each_pmc_rcu()
- igmp_stop_timer() via igmp_rcv() -> igmp_heard_report()
If the group im was concurrently removed from the list by ip_mc_dec_group(), its reference count might have already been decremented to 1.
In this case, timer_delete() succeeds, and refcount_dec() decrements the refcount from 1 to 0. Since refcount_dec() does not free the object when it hits 0 (unlike ip_ma_put()), the im structure is leaked.
Fix this by using ip_ma_put(im) instead of refcount_dec(&im->refcnt), and deferring the put until after the spinlock is released.
--- net/ipv4/igmp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/igmp.c +12 -2
@@ -217,13 +217,18 @@ static void ip_sf_list_clear_all(struct ip_sf_list *psf)static void igmp_stop_timer (struct ip_mc_list *im) { +bool put = false; +spin_lock_bh (&im->lock);if (timer_delete (&im->timer)) -refcount_dec (&im->refcnt); + put = true;WRITE_ONCE (im->tm_running,0 );WRITE_ONCE (im->reporter,0 ); im->unsolicit_count =0 ;spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }/* It must be called with locked im->lock */
@@ -266,6 +271,8 @@ static void igmp_ifc_start_timer(struct in_device *in_dev, int delay)static void igmp_mod_timer (struct ip_mc_list *im,int max_delay) { +bool put = false; +spin_lock_bh (&im->lock); im->unsolicit_count =0 ;if (timer_delete (&im->timer)) {
@@ -275,10 +282,13 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)spin_unlock_bh (&im->lock);return ; } -refcount_dec (&im->refcnt); + put = true; }igmp_start_timer (im, max_delay);spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1491/2077 netfilter: nft_lookup: fix catchall element handling with inverted lookups
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamaki Yanagawa <[email protected]>
[ Upstream commit e6107a4c74b54cb33e3bce162a63048ae5a6b198 ]
nft_lookup_eval() decides whether a lookup matched (found) from the direct set lookup and priv->invert before falling back to the catchall element used by interval sets (e.g. nft_set_rbtree) for the open-ended default range. Since found is never recomputed after ext is replaced by the catchall lookup, inverted lookups (NFT_LOOKUP_F_INV, "!= @set") can wrongly match or wrongly skip the catchall element, producing the wrong verdict. Fold the catchall lookup into ext before computing found, matching the order already used by nft_objref_map_eval().
--- net/netfilter/nft_lookup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nft_lookup.c +5 -5
@@ -103,13 +103,13 @@ void nft_lookup_eval(const struct nft_expr *expr,bool found; ext =nft_set_do_lookup (net, set, ®s->data[priv->sreg]); +if (!ext) + ext =nft_set_catchall_lookup (net, set); + found = !!ext ^ priv->invert;if (!found) { - ext =nft_set_catchall_lookup (net, set); -if (!ext) { - regs->verdict.code =NFT_BREAK ; -return ; - } + regs->verdict.code =NFT_BREAK ; +return ; }if (ext) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1492/2077 ipvs: pass parsed transport offset to state handlers
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit bae7ce7bafb59e42dc0e0e2999fdd9d1cffe3866 ]
IPVS callers already parse the packet into struct ip_vs_iphdr before updating connection state. For IPv6 this records the real transport-header offset after extension headers in iph.len.
Pass this parsed transport offset through ip_vs_set_state() and the protocol state_transition() callback so protocol handlers can use the same packet context as scheduling and NAT handling. This patch only changes the common callback plumbing and adapts the protocol callback signatures; TCP and SCTP start using the value in follow-up patches.
Stable-dep-of: 2500fa3958b1 ("ipvs: use parsed transport offset in TCP state lookup")
--- include/net/ip_vs.h | 3 ++- net/netfilter/ipvs/ip_vs_core.c | 10 +++++----- net/netfilter/ipvs/ip_vs_proto_sctp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_tcp.c | 3 ++- net/netfilter/ipvs/ip_vs_proto_udp.c | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-)
include/net/ip_vs.h +2 -1
@@ -744,7 +744,8 @@ struct ip_vs_protocol {void (*state_transition)(struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd); +struct ip_vs_proto_data *pd, +unsigned int iph_len);int (*register_app)(struct netns_ipvs *ipvs,struct ip_vs_app *inc);
net/netfilter/ipvs/ip_vs_core.c +5 -5
@@ -398,10 +398,10 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)static inline void ip_vs_set_state (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd,unsigned int iph_len) {if (likely (pd->pp->state_transition)) - pd->pp->state_transition (cp, direction, skb, pd); + pd->pp->state_transition (cp, direction, skb, pd, iph_len); } static inline int
@@ -803,7 +803,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,ip_vs_in_stats (cp, skb);/* set state */ -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph->len);/* transmit the first SYN packet */ ret = cp->packet_xmit (skb, cp, pd->pp, iph);
@@ -1484,7 +1484,7 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd, after_nat:ip_vs_out_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_OUTPUT , skb, pd, iph->len); skb->ipvs_property =1 ;if (!(cp->flags &IP_VS_CONN_F_NFCT ))ip_vs_notrack (skb);
@@ -2233,7 +2233,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stateIP_VS_DBG_PKT (11 , af, pp, skb, iph.off,"Incoming packet" );ip_vs_in_stats (cp, skb); -ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd); +ip_vs_set_state (cp,IP_VS_DIR_INPUT , skb, pd, iph.len);if (cp->packet_xmit) ret = cp->packet_xmit (skb, cp, pp, &iph);/* do not touch skb anymore */
net/netfilter/ipvs/ip_vs_proto_sctp.c +2 -1
@@ -468,7 +468,8 @@ set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void sctp_state_transition (struct ip_vs_conn *cp,int direction, -const struct sk_buff *skb,struct ip_vs_proto_data *pd) +const struct sk_buff *skb,struct ip_vs_proto_data *pd, +unsigned int iph_len) {spin_lock_bh (&cp->lock);set_sctp_state (pd, cp, direction, skb);
net/netfilter/ipvs/ip_vs_proto_tcp.c +2 -1
@@ -579,7 +579,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,static void tcp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {struct tcphdr _tcph, *th;
net/netfilter/ipvs/ip_vs_proto_udp.c +2 -1
@@ -444,7 +444,8 @@ static const char * udp_state_name(int state)static void udp_state_transition (struct ip_vs_conn *cp,int direction,const struct sk_buff *skb, -struct ip_vs_proto_data *pd) +struct ip_vs_proto_data *pd, +unsigned int iph_len) {if (unlikely (!pd)) {pr_err ("UDP no ns data\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1493/2077 ipvs: use parsed transport offset in TCP state lookup
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit 2500fa3958b1ba51c2b065e39db1b04dfa7e23a2 ]
TCP state handling reparses the skb to find the TCP header. For IPv6 it uses sizeof(struct ipv6hdr), while the surrounding IPVS code already parsed the packet with ip_vs_fill_iph_skb() and has the real transport-header offset in iph.len.
This makes TCP state handling look at the wrong bytes when an IPv6 packet carries extension headers. Use the parsed transport offset passed down from ip_vs_set_state() when reading the TCP header.
For IPv4 and for IPv6 packets without extension headers, the passed offset matches the previous value.
--- net/netfilter/ipvs/ip_vs_proto_tcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/netfilter/ipvs/ip_vs_proto_tcp.c +1 -7
@@ -584,13 +584,7 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction, {struct tcphdr _tcph, *th; -#ifdef CONFIG_IP_VS_IPV6 -int ihl = cp->af ==AF_INET ?ip_hdrlen (skb) :sizeof (struct ipv6hdr ); -#else -int ihl =ip_hdrlen (skb); -#endif - - th =skb_header_pointer (skb, ihl,sizeof (_tcph), &_tcph); + th =skb_header_pointer (skb, iph_len,sizeof (_tcph), &_tcph);if (th ==NULL )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1494/2077 ipvs: fix PMTU for GUE/GRE tunnel ICMP errors
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
[ Upstream commit 6b335af0d0d1ff44ac579d106953bf19299e5233 ]
When an ICMP Fragmentation Needed error is received for a tunneled IPVS connection, ip_vs_in_icmp() recomputes the MTU that the original packet can use by subtracting the tunnel overhead from the reported next-hop MTU.
The current code always subtracts sizeof(struct iphdr), which is only the IPIP overhead. For GUE and GRE tunnels, ipvs_udp_decap() and ipvs_gre_decap() already compute the additional tunnel header length, but that value is scoped to the decapsulation block and is lost before the ICMP_FRAG_NEEDED handling. As a result, the ICMP error sent back to the client advertises an MTU that is too large, so PMTUD can fail to converge for GUE/GRE-tunneled real servers.
With a reported next-hop MTU of 1400, a GUE tunnel currently returns 1380 to the client. The correct value is 1368:
1400 - sizeof(struct iphdr) - sizeof(struct udphdr) - sizeof(struct guehdr)
Hoist the tunnel header length into the main ip_vs_in_icmp() scope and subtract sizeof(struct iphdr) + ulen in the Fragmentation Needed path. The IPIP path keeps ulen as 0, so its existing 1400 - 20 = 1380 result is unchanged.
Stable-dep-of: 3f7a535ff0fa ("ipvs: ensure inner headers in ICMP errors are in headroom")
--- net/netfilter/ipvs/ip_vs_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +3 -3
@@ -1767,6 +1767,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,bool tunnel, new_cp = false;union nf_inet_addr *raddr;char *outer_proto ="IPIP" ; +int ulen =0 ; *related =1 ;
@@ -1831,7 +1832,6 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Error for our tunnel must arrive at LOCAL_IN */ (skb_rtable(skb)->rt_flags & RTCF_LOCAL)) {__u8 iproto; -int ulen;/* Non-first fragment has no UDP/GRE header */ if (unlikely (cih->frag_off &htons (IP_OFFSET )))
@@ -1936,8 +1936,8 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (dest_dst) mtu =dst_mtu (dest_dst->dst_cache); } -if (mtu >68 +sizeof (struct iphdr )) - mtu -=sizeof (struct iphdr ); +if (mtu >68 +sizeof (struct iphdr ) + ulen) + mtu -=sizeof (struct iphdr ) + ulen; info =htonl (mtu); }/* Strip outer IP, ICMP and IPIP/UDP/GRE, go to IP header of
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1495/2077 ipvs: ensure inner headers in ICMP errors are in headroom
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3f7a535ff0fa627a0132803e4c2f903ceffcbc1c ]
Sashiko points out that after stripping the outer headers with pskb_pull() we should ensure the inner IP headers in ICMP errors from tunnels are present in the skb headroom for functions like ipv4_update_pmtu(), icmp_send() and IP_VS_DBG().
Also, add more checks for the length of the inner headers.
--- net/netfilter/ipvs/ip_vs_core.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
net/netfilter/ipvs/ip_vs_core.c +15 -6
@@ -1767,6 +1767,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,bool tunnel, new_cp = false;union nf_inet_addr *raddr;char *outer_proto ="IPIP" ; +unsigned int hlen_ipip;int ulen =0 ; *related =1 ;
@@ -1804,9 +1805,10 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Now find the contained IP header */ offset +=sizeof (_icmph); cih =skb_header_pointer (skb, offset,sizeof (_ciph), &_ciph); -if (cih ==NULL ) +if (!(cih && cih->version ==4 && cih->ihl >=5 ))return NF_ACCEPT ;/* The packet looks wrong, ignore */ raddr = (union nf_inet_addr *)&cih->daddr; + hlen_ipip = cih->ihl *4 ;/* Special case for errors for IPIP/UDP/GRE tunnel packets */ tunnel = false;
@@ -1822,9 +1824,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Only for known tunnel */ if (!dest || dest->tun_type !=IP_VS_CONN_F_TUNNEL_TYPE_IPIP )return NF_ACCEPT ; - offset += cih->ihl *4 ; + offset += hlen_ipip; cih =skb_header_pointer (skb, offset,sizeof (_ciph), &_ciph); -if (cih ==NULL ) +if (!(cih && cih->version ==4 && cih->ihl >=5 ))return NF_ACCEPT ;/* The packet looks wrong, ignore */ tunnel = true; } else if ((cih->protocol == IPPROTO_UDP || /* Can be UDP encap */
@@ -1836,7 +1838,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,/* Non-first fragment has no UDP/GRE header */ if (unlikely (cih->frag_off &htons (IP_OFFSET )))return NF_ACCEPT ; - offset2 = offset + cih->ihl *4 ; + offset2 = offset + hlen_ipip;if (cih->protocol ==IPPROTO_UDP ) { ulen =ipvs_udp_decap (ipvs, skb, offset2,AF_INET , raddr, &iproto);
@@ -1905,6 +1907,7 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related, }if (tunnel) { +unsigned int hlen_orig = cih->ihl *4 ;__be32 info = ic->un.gateway;__u8 type = ic->type;__u8 code = ic->code;
@@ -1921,6 +1924,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related, goto ignore_tunnel; offset2 -= ihl +sizeof (_icmph);skb_reset_network_header (skb); +/* Ensure the IP header is present in headroom */ +if (!pskb_may_pull (skb, hlen_ipip)) + goto ignore_tunnel;IP_VS_DBG (12 ,"ICMP for %s %pI4->%pI4: mtu=%u\n" , outer_proto, &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, mtu);
@@ -1936,8 +1942,8 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (dest_dst) mtu =dst_mtu (dest_dst->dst_cache); } -if (mtu >68 +sizeof (struct iphdr ) + ulen) - mtu -=sizeof (struct iphdr ) + ulen; +if (mtu >68 + hlen_ipip + ulen) + mtu -= hlen_ipip + ulen; info =htonl (mtu); }/* Strip outer IP, ICMP and IPIP/UDP/GRE, go to IP header of
@@ -1946,6 +1952,9 @@ ip_vs_in_icmp(struct netns_ipvs *ipvs, struct sk_buff *skb, int *related,if (pskb_pull (skb, offset2) ==NULL ) goto ignore_tunnel;skb_reset_network_header (skb); +/* Ensure the IP header is present in headroom */ +if (!pskb_may_pull (skb, hlen_orig)) + goto ignore_tunnel;IP_VS_DBG (12 ,"Sending ICMP for %pI4->%pI4: t=%u, c=%u, i=%u\n" , &ip_hdr (skb)->saddr, &ip_hdr (skb)->daddr, type, code,ntohl (info));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1496/2077 s390/zcrypt: Remove the empty file
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rongguang Wei <[email protected]>
[ Upstream commit 575f87b9d4882b0d621192fdd754d7e09dbd5789 ]
The files has no real user because CEX2 and CEX3 device drivers are removed, also remove these empty files.
--- drivers/s390/crypto/zcrypt_cex2a.c | 0 drivers/s390/crypto/zcrypt_cex2a.h | 0 drivers/s390/crypto/zcrypt_cex2c.c | 0 drivers/s390/crypto/zcrypt_cex2c.h | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 drivers/s390/crypto/zcrypt_cex2a.c delete mode 100644 drivers/s390/crypto/zcrypt_cex2a.h delete mode 100644 drivers/s390/crypto/zcrypt_cex2c.c delete mode 100644 drivers/s390/crypto/zcrypt_cex2c.h
drivers/s390/crypto/zcrypt_cex2a.c deleted +0 -0
drivers/s390/crypto/zcrypt_cex2a.h deleted +0 -0
drivers/s390/crypto/zcrypt_cex2c.c deleted +0 -0
drivers/s390/crypto/zcrypt_cex2c.h deleted +0 -0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1497/2077 cifs: validate DFS referral string offsets
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 027a84ac6b50c12ef767c15abfc58aa865820e9e ]
parse_dfs_referrals() validates that the response header and referral array fit in the received buffer, but each referral also contains string offsets supplied by the server.
Those offsets are used to compute the DfsPath and NetworkAddress string pointers without checking whether they still point inside the response buffer. A malformed referral can therefore make the computed pointer exceed the end of the buffer. The resulting negative max_len is then passed to cifs_strndup_from_utf16(), and the non-Unicode path forwards it to kstrndup() as a size_t, allowing strnlen() to read out of bounds.
Validate each string offset before deriving the string pointer.
--- fs/smb/client/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/smb/client/misc.c +8 -0
@@ -752,6 +752,10 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, node->ref_flag =le16_to_cpu (ref->ReferralEntryFlags);/* copy DfsPath */ +if (le16_to_cpu (ref->DfsPathOffset) > data_end - (char *)ref) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } temp = (char *)ref +le16_to_cpu (ref->DfsPathOffset); max_len = data_end - temp; node->path_name = cifs_strndup_from_utf16(temp, max_len,
@@ -762,6 +766,10 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, }/* copy link target UNC */ +if (le16_to_cpu (ref->NetworkAddressOffset) > data_end - (char *)ref) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } temp = (char *)ref +le16_to_cpu (ref->NetworkAddressOffset); max_len = data_end - temp; node->node_name = cifs_strndup_from_utf16(temp, max_len,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1498/2077 SUNRPC: release lower rpc_clnt if killed waiting for XPRT_LOCKED
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 29bacb096d43bd04062f6655e50ceeed27fe6d2f ]
xs_tcp_tls_setup_socket() creates a temporary "lower" rpc_clnt with rpc_create() to drive the inner TLS handshake, then waits for XPRT_LOCKED on its xprt with TASK_KILLABLE so a stuck handshake can be aborted by signal. When the wait is interrupted, the function jumps to out_unlock without releasing lower_clnt. The success path and the out_close error path both call rpc_shutdown_client(lower_clnt); only the killed-wait path skips it, leaking the clnt and its underlying xprt.
Call rpc_shutdown_client() on this path before joining out_unlock. xprt_release_write() is not needed here because XPRT_LOCKED was never acquired.
--- net/sunrpc/xprtsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sunrpc/xprtsock.c +4 -1
@@ -2734,8 +2734,11 @@ static void xs_tcp_tls_setup_socket(struct work_struct *work) lower_xprt =rcu_dereference (lower_clnt->cl_xprt);rcu_read_unlock (); -if (wait_on_bit_lock (&lower_xprt->state,XPRT_LOCKED ,TASK_KILLABLE )) +if (wait_on_bit_lock (&lower_xprt->state,XPRT_LOCKED ,TASK_KILLABLE )) { +/* XPRT_LOCKED was never acquired. */ +rpc_shutdown_client (lower_clnt); goto out_unlock; + } status =xs_tls_handshake_sync (lower_xprt, &upper_xprt->xprtsec);if (status) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1499/2077 SUNRPC: pin upper rpc_clnt across the TLS connect_worker
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 46bc86c833956219bbfd246c1ffd832a479c5199 ]
The TLS connect path has a use-after-free: nothing pins the upper rpc_clnt across the delayed connect_worker. xs_connect() stores task->tk_client in sock_xprt::clnt as a raw pointer and queues the worker; for TLS-secured transports that worker is xs_tcp_tls_setup_socket(), which reads several fields out of the saved pointer (cl_timeout, cl_program, cl_prog, cl_vers, cl_cred, cl_stats) to construct the args for the inner handshake rpc_clnt.
The xprt does not reference the rpc_clnt; the rpc_clnt references the xprt. xs_destroy() does cancel the connect_worker, but it runs only when the xprt's refcount drops to zero, which cannot happen until the rpc_clnt releases its cl_xprt reference in rpc_free_client_work(). When a TLS handshake fails fatally (for example, an mTLS mount whose client cert does not match the server), the connecting task is woken with -EACCES and exits, the mount caller invokes rpc_shutdown_client(), and the upper rpc_clnt is freed before the queued connect_worker fires. xs_tcp_tls_setup_socket() then dereferences the freed clnt, producing the refcount_t underflow Michael Nemanov reported.
Take a reference on the upper rpc_clnt in xs_connect() for TLS transports via a new rpc_hold_client() helper, and drop it in the connect_worker's exit path with rpc_release_client(). The xprt_lock_connect() / xprt_unlock_connect() pairing already serialises xs_connect() with xs_tcp_tls_setup_socket(), so the take and release are balanced one-for-one.
The non-TLS connect worker (xs_tcp_setup_socket) never reads sock_xprt::clnt, so leave that path alone and avoid the clnt-holds-xprt-holds-clnt cycle that would otherwise prevent xprt destruction.
--- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 19 +++++++++++++++++-- net/sunrpc/xprtsock.c | 11 ++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-)
include/linux/sunrpc/clnt.h +1 -0
@@ -190,6 +190,7 @@ int rpc_switch_client_transport(struct rpc_clnt *, const struct rpc_timeout *); void rpc_shutdown_client(struct rpc_clnt *); +void rpc_hold_client (struct rpc_clnt *);void rpc_release_client (struct rpc_clnt *);void rpc_task_release_transport (struct rpc_task *);void rpc_task_release_client (struct rpc_task *);
net/sunrpc/clnt.c +17 -2
@@ -1026,8 +1026,23 @@ rpc_free_auth(struct rpc_clnt *clnt)return NULL ; } -/* -* Release reference to the RPC client +/** +* rpc_hold_client - acquire a reference on an rpc_clnt +* @clnt: rpc_clnt to pin +* +* Pairs with rpc_release_client(). +*/ +void rpc_hold_client (struct rpc_clnt *clnt) +{ +refcount_inc (&clnt->cl_count); +} + +/** +* rpc_release_client - release a reference on an rpc_clnt +* @clnt: rpc_clnt to release +* +* Pairs with rpc_hold_client(). The rpc_clnt's resources are +* freed once its reference count drops to zero. */ void rpc_release_client (struct rpc_clnt *clnt)
net/sunrpc/xprtsock.c +10 -1
@@ -2761,6 +2761,7 @@ static void xs_tcp_tls_setup_socket(struct work_struct *work) out_unlock:current_restore_flags (pflags,PF_MEMALLOC ); upper_transport->clnt =NULL ; +rpc_release_client (upper_clnt);xprt_unlock_connect (upper_xprt, upper_transport);return ;
@@ -2808,7 +2809,15 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) }else dprintk ("RPC: xs_connect scheduled xprt %p\n" , xprt); - transport->clnt = task->tk_client; +/* +* Only the TLS connect_worker reads transport->clnt; pinning +* the upper rpc_clnt unconditionally would form a cycle with +* cl_xprt and prevent xprt destruction. +*/ +if (xprt->xprtsec.policy !=RPC_XPRTSEC_NONE ) { +rpc_hold_client (task->tk_client); + transport->clnt = task->tk_client; + }queue_delayed_work (xprtiod_workqueue, &transport->connect_worker, delay);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1500/2077 dm era: fix NULL pointer dereference in metadata_open()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 9ae672606c17891d90b282e3490b817620549599 ]
metadata_open() returns NULL when kzalloc_obj() fails, but the caller era_ctr() only checks IS_ERR(md). Since IS_ERR(NULL) returns false, the NULL pointer is treated as a valid result and later assigned to era->md, leading to a NULL pointer dereference when the metadata is accessed.
Fix this by returning ERR_PTR(-ENOMEM) on allocation failure, consistent with dm-cache-metadata.c, dm-thin-metadata.c, and dm-clone-metadata.c which all use ERR_PTR(-ENOMEM) for the same pattern.
--- drivers/md/dm-era-target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-era-target.c +4 -2
@@ -810,8 +810,10 @@ static struct era_metadata *metadata_open(struct block_device *bdev,int r;struct era_metadata *md =kzalloc_obj (*md); -if (!md) -return NULL ; +if (!md) { +DMERR ("could not allocate metadata struct" ); +return ERR_PTR (-ENOMEM ); + } md->bdev = bdev; md->block_size = block_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1501/2077 smb: client: fix busy dentry warning on unmount after DIO
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
[ Upstream commit 75f5c412fa867efa0bf9b646bffe0d912109e84a ]
Commit c68337442f03 ("cifs: Fix busy dentry used after unmounting") fixed the issue in cifs where deferred close of a file led to a dentry reference count not being released in umount, by flushing deferredclose_wq in cifs_kill_sb() to solve it.
However, the cifs DIO path suffers from the same busy-dentry problem caused by a delayed dentry reference-count release:
[dio] [cifsd] [close + umount]
netfs_unbuffered_write_iter_locked
...
cifs_demultiplex_thread
netfs_unbuffered_write
cifs_issue_write netfs_wait_for_in_progress_stream [1]
... netfs_write_subrequest_terminated netfs_subreq_clear_in_progress netfs_wake_collector // wake [1] netfs_put_subrequest netfs_put_request queue_work(system_dfl_wq, xxx) [2] // dio write return cifs_close _cifsFileInfo_put // cfile->count 2->1 --cfile->count [3] // umount cifs_kill_sb kill_anon_super // warning triggered! shrink_dcache_for_umount [4]
[system_dfl_wq] [5]netfs_free_request
...
_cifsFileInfo_put
// cfile->count 1->0
--cfile->count
queue_work(fileinfo_put_wq, xxx)
[fileinfo_put_wq] [6]cifsFileInfo_put_work
cifsFileInfo_put_final
dput
If the umount path is triggered before [5], it results warning:
BUG: Dentry 00000000eab1f070{i=9a917b66ae404fec,n=test} still in use (1)[unmount of cifs cifs]
The existing per-inode ictx->io_count wait in cifs_evict_inode() does not
help: it lives in the inode eviction path, which runs after shrink_dcache_for_umount() has already warned about the busy dentries.
Fix it by adding a per-superblock outstanding-rreq counter that is incremented in cifs_init_request() and decremented in cifs_free_request(). In cifs_kill_sb(), before kill_anon_super(), wait for this counter to reach 0 - which guarantees that all cleanup_work for this sb have run and thus all relevant cfile puts are queued on fileinfo_put_wq or serverclose_wq. Then drain the workqueue so the dentry refs are dropped.
This is a targeted wait, not a flush of the system-wide system_dfl_wq.
--- fs/smb/client/cifs_fs_sb.h | 1 + fs/smb/client/cifsfs.c | 12 ++++++++++++ fs/smb/client/connect.c | 1 + fs/smb/client/file.c | 5 +++++ 4 files changed, 19 insertions(+)
fs/smb/client/cifs_fs_sb.h +1 -0
@@ -56,6 +56,7 @@ struct cifs_sb_info {struct smb3_fs_context *ctx;atomic_t active;atomic_t mnt_cifs_flags; +atomic_t outstanding_rreq;/* nr of rreqs not yet fully deinitialized */ struct delayed_work prune_tlinks;struct rcu_head rcu;
fs/smb/client/cifsfs.c +12 -0
@@ -309,6 +309,18 @@ static void cifs_kill_sb(struct super_block *sb)/* Wait for all opened files to release */ flush_workqueue (deferredclose_wq); +/* +* Wait for all in-flight netfs I/O requests to finish their +* cleanup_work so that any cifsFileInfo final puts they queue +* to fileinfo_put_wq/serverclose_wq have been queued, then +* drain the workqueue so the cfile dentry refs are dropped to +* avoid the busy dentry warning. +*/ +wait_var_event (&cifs_sb->outstanding_rreq, + !atomic_read (&cifs_sb->outstanding_rreq)); +flush_workqueue (serverclose_wq); +flush_workqueue (fileinfo_put_wq); +/* finally release root dentry */ dput (cifs_sb->root); cifs_sb->root =NULL ;
fs/smb/client/connect.c +1 -0
@@ -3479,6 +3479,7 @@ int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)spin_lock_init (&cifs_sb->tlink_tree_lock); cifs_sb->tlink_tree =RB_ROOT ; +atomic_set (&cifs_sb->outstanding_rreq,0 );cifs_dbg (FYI ,"file mode: %04ho dir mode: %04ho\n" , ctx->file_mode, ctx->dir_mode);
fs/smb/client/file.c +5 -0
@@ -288,6 +288,7 @@ static int cifs_init_request(struct netfs_io_request *rreq, struct file *file)return smb_EIO1 (smb_eio_trace_not_netfs_writeback, rreq->origin); } +atomic_inc (&cifs_sb->outstanding_rreq);return 0 ; }
@@ -309,9 +310,13 @@ static void cifs_rreq_done(struct netfs_io_request *rreq)static void cifs_free_request (struct netfs_io_request *rreq) { struct cifs_io_request *req = container_of(rreq, struct cifs_io_request, rreq); +struct cifs_sb_info *cifs_sb =CIFS_SB (rreq->inode->i_sb);if (req->cfile)cifsFileInfo_put (req->cfile); + +if (atomic_dec_and_test (&cifs_sb->outstanding_rreq)) +wake_up_var (&cifs_sb->outstanding_rreq); }static void cifs_free_subrequest (struct netfs_io_subrequest *subreq)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1502/2077 regulator: core: regulator_lock_two() should test for EDEADLK not EDEADLOCK
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Tabi <[email protected]>
[ Upstream commit d38f8bd771c4999b797d7074b348cf201414bd34 ]
Compare against -EDEADLK, which is what ww_mutex_lock() actually returns and what every other deadlock check in this file already uses.
Function regulator_lock_two() acquires two regulators via regulator_lock_nested() -> ww_mutex_lock(). On contention, ww_mutex_lock() returns -EDEADLK, which is the caller's signal to drop the lock it holds and retry the acquisition in the canonical order.
However, regulator_lock_two() tests the return value against -EDEADLOCK rather than -EDEADLK. On most architectures, EDEADLK and EDEADLOCK are the same value, so the comparison happens to be correct and the bug is invisible. But on MIPS, SPARC, and PowerPC, those two errors have different values. The test is wrong: a genuine -EDEADLK backoff no longer matches -EDEADLOCK, so instead of unlocking and retrying, the code falls into WARN_ON(ret) and returns with only one of the two regulators locked.
In practice, this is a bug only on MIPS, because the regulator core is not built or used on the other two platforms.
In general, EDEADLK is preferred over EDEADLOCK for new code.
--- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
@@ -248,7 +248,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1, ret =regulator_lock_nested (rdev1, ww_ctx);WARN_ON (ret); ret =regulator_lock_nested (rdev2, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret); goto exit; }
@@ -264,7 +264,7 @@ static void regulator_lock_two(struct regulator_dev *rdev1,swap (held, contended); ret =regulator_lock_nested (contended, ww_ctx); -if (ret != -EDEADLOCK ) { +if (ret != -EDEADLK ) {WARN_ON (ret);break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1503/2077 drm/fb-helper: Only consider active CRTCs for vblank sync
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit 06c2b8d7ea2bcb014dd974fc3bc6d128d65d7477 ]
Only synchronize fbdev output to the vblank of an active CRTC. Go over the list of CRTCs and pick the first that matches. Fixes warnings as the one shown below
[ 77.201354] WARNING: drivers/gpu/drm/drm_vblank.c:1320 at drm_crtc_wait_one_vblank+0x194/0x1cc [drm], CPU#1: kworker/1:7/1867 [ 77.201354] omapdrm omapdrm.0: [drm] vblank wait timed out on crtc 0
This currently happens if the fbdev output is not on CRTC 0.
Atomic and non-atomic drivers require distinct code paths. As for other fbdev operations, implement both and select the correct one at runtime.
Not finding an active CRTC is not a bug. Do not wait in this case, but flush the display update as before.
v4:
- avoid possible deadlocks with locking context (Sashiko)
v3:
- drop excessive state validation (Jani)
- acquire plane and CRTC mutices (Sashiko)
v2:
- move look-up code into separate helper
- support drivers with legacy modesetting
v1:
- see https://lore.kernel.org/dri-devel/[email protected]/
--- drivers/gpu/drm/drm_fb_helper.c | 92 ++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +91 -1
@@ -225,16 +225,106 @@ static void drm_fb_helper_resume_worker(struct work_struct *work)console_unlock (); } +static int find_crtc_index_atomic (struct drm_fb_helper *helper) +{ +struct drm_device *dev = helper->dev; +int crtc_index = -EINVAL ; +struct drm_modeset_acquire_ctx ctx; +struct drm_plane *plane; +int ret =0 ; + +drm_modeset_acquire_init (&ctx,0 ); + +retry: +drm_for_each_plane (plane, dev) { +const struct drm_plane_state *plane_state; + +if (plane->type !=DRM_PLANE_TYPE_PRIMARY ) +continue ; + + ret =drm_modeset_lock (&plane->mutex, &ctx); +if (ret) + goto err_drm_modeset_lock; + plane_state = plane->state; + +if (plane_state->fb == helper->fb && plane_state->crtc) { +struct drm_crtc *crtc = plane_state->crtc; + + ret =drm_modeset_lock (&crtc->mutex, &ctx); +if (ret) + goto err_drm_modeset_lock; +if (crtc->state->active) + crtc_index = crtc->index; +drm_modeset_unlock (&crtc->mutex); + } +drm_modeset_unlock (&plane->mutex); + +if (crtc_index >=0 ) +break ; + } + +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); + +return crtc_index; + +err_drm_modeset_lock: +if (ret == -EDEADLK ) { +drm_modeset_backoff (&ctx); + goto retry; + } +return ret; +} + +static int find_crtc_index_legacy (struct drm_fb_helper *helper) +{ +struct drm_device *dev = helper->dev; +struct drm_crtc *crtc; + +drm_for_each_crtc (crtc, dev) { +struct drm_plane *plane = crtc->primary; + +if (!crtc->enabled) +continue ; +if (!plane || plane->fb != helper->fb) +continue ;/* CRTC doesn't display fbdev emulation */ + +return crtc->index; + } + +return -EINVAL ; +} + +static int drm_fb_helper_find_crtc_index (struct drm_fb_helper *helper) +{ +struct drm_device *dev = helper->dev; +int crtc_index; + +mutex_lock (&dev->mode_config.mutex); + +if (drm_drv_uses_atomic_modeset (dev)) + crtc_index =find_crtc_index_atomic (helper); +else + crtc_index =find_crtc_index_legacy (helper); + +mutex_unlock (&dev->mode_config.mutex); + +return crtc_index; +} +static void drm_fb_helper_fb_dirty (struct drm_fb_helper *helper) {struct drm_device *dev = helper->dev;struct drm_clip_rect *clip = &helper->damage_clip;struct drm_clip_rect clip_copy; +int crtc_index;unsigned long flags;int ret;mutex_lock (&helper->lock); -drm_client_modeset_wait_for_vblank (&helper->client,0 ); + crtc_index =drm_fb_helper_find_crtc_index (helper); +if (crtc_index >=0 ) +drm_client_modeset_wait_for_vblank (&helper->client, crtc_index);mutex_unlock (&helper->lock);if (drm_WARN_ON_ONCE (dev, !helper->funcs->fb_dirty))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1504/2077 selftests/net: fix EVP_MD_CTX leak in tcp_mmap
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yan <[email protected]>
[ Upstream commit f4ef35efbb49527293309f668ea73ec5de9b8e7a ]
In tcp_mmap.c, both child_thread() and main() allocate an EVP_MD_CTX via EVP_MD_CTX_new() when integrity checking is enabled, but neither function releases the context. child_thread() misses the free in its common cleanup block, and main() returns without freeing the context.
This results in a SHA256 context leak on every run that uses the ‑i (integrity) option. Add the missing EVP_MD_CTX_free() calls to the appropriate cleanup paths to fix the leak.
--- tools/testing/selftests/net/tcp_mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/net/tcp_mmap.c +4 -0
@@ -313,6 +313,8 @@ void *child_thread(void *arg) tcp_info_get_rcv_mss(fd)); } error: +if (ctx) +EVP_MD_CTX_free (ctx);munmap (buffer, buffer_sz);close (fd);if (zflg)
@@ -606,6 +608,8 @@ int main(int argc, char *argv[])EVP_DigestFinal_ex (ctx, digest, &digest_len);send (fd, digest, (size_t )SHA256_DIGEST_LENGTH ,0 ); } +if (ctx) +EVP_MD_CTX_free (ctx);close (fd);munmap (buffer, buffer_sz);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1505/2077 net/mlx5: Fix L3 tunnel entropy refcount leak
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit c914307e1d41c2cb7bcdcbfde4cd2f214f6aa027 ]
mlx5_tun_entropy_refcount_inc() counts both VXLAN and L2-to-L3 tunnel reformat entries as entropy-enabling users. The matching decrement path only handled VXLAN, leaving L2-to-L3 tunnel entries counted after release.
Handle MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL in mlx5_tun_entropy_refcount_dec() as well so the enabling entry refcount remains balanced.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c +2 -1
@@ -176,7 +176,8 @@ void mlx5_tun_entropy_refcount_dec(struct mlx5_tun_entropy *tun_entropy, int reformat_type) {mutex_lock (&tun_entropy->lock); -if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN ) +if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN || + reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL ) tun_entropy->num_enabling_entries--;else if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_NVGRE && --tun_entropy->num_disabling_entries ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1506/2077 ethtool: rss: Fix hfunc and input_xfrm parsing on big endian
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit b62869a81a7ce388d1fbb0fac5fa8300ea614d81 ]
ETHTOOL_A_RSS_HFUNC and ETHTOOL_A_RSS_INPUT_XFRM are NLA_U32 attributes, but ethnl_rss_set() and ethnl_rss_create_doit() parse them with ethnl_update_u8(), which reads a single byte.
On little endian this happens to read the least significant byte and works as long as the value fits in a byte. On big endian it reads the most significant byte, so the requested value is parsed incorrectly.
The destination fields in struct ethtool_rxfh_param are u8, so the attribute can't be read directly with ethnl_update_u32(). Cap the hfunc policy at U8_MAX so an out of range value is rejected instead of being silently truncated into the u8 field, and add ethnl_update_u8_u32() to read the full u32 and narrow it into the u8 destination.
--- net/ethtool/netlink.h | 28 ++++++++++++++++++++++++++++ net/ethtool/rss.c | 14 ++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-)
net/ethtool/netlink.h +28 -0
@@ -115,6 +115,34 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr, *mod = true; } +/** +* ethnl_update_u8_u32() - update u8 value from an NLA_U32 attribute +* @dst: value to update +* @attr: netlink attribute with new value or null +* @mod: pointer to bool for modification tracking +* +* Some attributes are NLA_U32 on the wire but are stored in a u8. Read the +* full 32-bit value from NLA_U32 netlink attribute @attr and narrow it into +* the u8 pointed to by @dst; do nothing if @attr is null. +* Bool pointed to by @mod is set to true if this function changed the value +* of *dst, otherwise it is left as is. +*/ +static inline void ethnl_update_u8_u32 (u8 *dst,const struct nlattr *attr, +bool *mod) +{ +u32 val; + +if (!attr) +return ; + val =nla_get_u32 (attr); +DEBUG_NET_WARN_ON_ONCE (val >U8_MAX ); +if (*dst == val) +return ; + + *dst = val; + *mod = true; +} +/** * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute * @dst: value to update
net/ethtool/rss.c +8 -6
@@ -574,7 +574,7 @@ static const struct nla_policy ethnl_rss_flows_policy[] = {const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_FLOW_HASH +1 ] = { [ETHTOOL_A_RSS_HEADER ] =NLA_POLICY_NESTED (ethnl_header_policy), [ETHTOOL_A_RSS_CONTEXT ] = { .type =NLA_U32 , }, - [ETHTOOL_A_RSS_HFUNC ] =NLA_POLICY_MIN (NLA_U32 ,1 ), + [ETHTOOL_A_RSS_HFUNC ] =NLA_POLICY_RANGE (NLA_U32 ,1 ,U8_MAX ), [ETHTOOL_A_RSS_INDIR ] = { .type =NLA_BINARY , }, [ETHTOOL_A_RSS_HKEY ] =NLA_POLICY_MIN (NLA_BINARY ,1 ), [ETHTOOL_A_RSS_INPUT_XFRM] =
@@ -855,7 +855,7 @@ ethnl_rss_set(struct ethnl_req_info *req_info, struct genl_info *info) indir_mod = !!tb[ETHTOOL_A_RSS_INDIR ]; rxfh.hfunc = data.hfunc; -ethnl_update_u8 (&rxfh.hfunc, tb[ETHTOOL_A_RSS_HFUNC ], &mod); +ethnl_update_u8_u32 (&rxfh.hfunc, tb[ETHTOOL_A_RSS_HFUNC ], &mod);if (rxfh.hfunc == data.hfunc) rxfh.hfunc =ETH_RSS_HASH_NO_CHANGE ;
@@ -864,7 +864,8 @@ ethnl_rss_set(struct ethnl_req_info *req_info, struct genl_info *info) goto exit_free_indir; rxfh.input_xfrm = data.input_xfrm; -ethnl_update_u8 (&rxfh.input_xfrm, tb[ETHTOOL_A_RSS_INPUT_XFRM ], &mod); +ethnl_update_u8_u32 (&rxfh.input_xfrm, tb[ETHTOOL_A_RSS_INPUT_XFRM ], + &mod); xfrm_sym = rxfh.input_xfrm || data.input_xfrm;if (rxfh.input_xfrm == data.input_xfrm) rxfh.input_xfrm =RXH_XFRM_NO_CHANGE ;
@@ -938,7 +939,7 @@ const struct ethnl_request_ops ethnl_rss_request_ops = {const struct nla_policy ethnl_rss_create_policy[ETHTOOL_A_RSS_INPUT_XFRM +1 ] = { [ETHTOOL_A_RSS_HEADER ] =NLA_POLICY_NESTED (ethnl_header_policy), [ETHTOOL_A_RSS_CONTEXT ] =NLA_POLICY_MIN (NLA_U32 ,1 ), - [ETHTOOL_A_RSS_HFUNC ] =NLA_POLICY_MIN (NLA_U32 ,1 ), + [ETHTOOL_A_RSS_HFUNC ] =NLA_POLICY_RANGE (NLA_U32 ,1 ,U8_MAX ), [ETHTOOL_A_RSS_INDIR ] =NLA_POLICY_MIN (NLA_BINARY ,1 ), [ETHTOOL_A_RSS_HKEY ] =NLA_POLICY_MIN (NLA_BINARY ,1 ), [ETHTOOL_A_RSS_INPUT_XFRM] =
@@ -1054,14 +1055,15 @@ int ethnl_rss_create_doit(struct sk_buff *skb, struct genl_info *info) goto exit_clean_data; indir_user_size = ret; -ethnl_update_u8 (&rxfh.hfunc, tb[ETHTOOL_A_RSS_HFUNC ], &mod); +ethnl_update_u8_u32 (&rxfh.hfunc, tb[ETHTOOL_A_RSS_HFUNC ], &mod); ret =rss_set_prep_hkey (dev, info, &data, &rxfh, &mod);if (ret) goto exit_free_indir; rxfh.input_xfrm =RXH_XFRM_NO_CHANGE ; -ethnl_update_u8 (&rxfh.input_xfrm, tb[ETHTOOL_A_RSS_INPUT_XFRM ], &mod); +ethnl_update_u8_u32 (&rxfh.input_xfrm, tb[ETHTOOL_A_RSS_INPUT_XFRM ], + &mod); ctx =ethtool_rxfh_ctx_alloc (ops, data.indir_size, data.hkey_size);if (!ctx) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1507/2077 octeontx2-af: fix VF bringup affecting PF promiscuous state
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harman Kalra <[email protected]>
[ Upstream commit fabb881df322da25442f98d23f5fa371e3c78ec4 ]
Mbox handling of nix_set_rx_mode for a VF with promiscuous and all_multi flags set to false causes deletion of the PF's promiscuous and allmulti MCAM rules. This occurs because the APIs that enable/disable these rules operate only on the PF, even when the mbox request is made via a VF interface.
Guard both rvu_npc_enable_allmulti_entry() and rvu_npc_enable_promisc_entry() disable paths with an is_vf() check so that a VF bringing up or tearing down its interface cannot inadvertently clear the PF's MCAM rules.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 -2
@@ -4548,7 +4548,7 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,rvu_npc_install_allmulti_entry (rvu, pcifunc, nixlf, pfvf->rx_chan_base); }else { -if (!nix_rx_multicast) +if (!nix_rx_multicast && !is_vf (pcifunc))rvu_npc_enable_allmulti_entry (rvu, pcifunc, nixlf, false); }
@@ -4558,7 +4558,7 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req, pfvf->rx_chan_base, pfvf->rx_chan_cnt); else - if (!nix_rx_multicast) + if (!nix_rx_multicast && !is_vf(pcifunc))rvu_npc_enable_promisc_entry (rvu, pcifunc, nixlf, false);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1508/2077 drm/xe: remove duplicate <kunit/test-bug.h> include
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anas Khan <[email protected]>
[ Upstream commit 91426ce50d14a49bde53b3ad1e48393556ba92cd ]
xe_pci.c includes <kunit/test-bug.h> twice, separated only by the <kunit/test.h> include. Drop the redundant second include; this is a non-functional cleanup flagged by scripts/checkincludes.pl.
--- drivers/gpu/drm/xe/tests/xe_pci.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/xe/tests/xe_pci.c +0 -1
@@ -9,7 +9,6 @@#include <kunit/test-bug.h> #include <kunit/test.h> -#include <kunit/test-bug.h> #include <kunit/visibility.h> #define PLATFORM_CASE (platform__, graphics_step__) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1509/2077 drm/xe: free madvise VMA array on L2 flush failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 14abbed336a2d1bbd726c25d148d2ec0ff928073 ]
xe_vm_madvise_ioctl() allocates madvise_range.vmas in get_vmas(). After get_vmas() succeeds with at least one VMA, error paths must go through free_vmas so the array is released before the madvise details are destroyed.
The L2 flush validation path added for PAT madvise rejects some SVM/userptr ranges after get_vmas() has succeeded, but jumps directly to madv_fini. This skips kfree(madvise_range.vmas), leaking the VMA array on each failed ioctl.
Jump to free_vmas instead, matching the other validation failure paths after get_vmas() has succeeded.
--- drivers/gpu/drm/xe/xe_vm_madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_vm_madvise.c +1 -1
@@ -643,7 +643,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil xe_device_is_l2_flush_optimized(xe) && (pat_index != 19 && coh_mode != XE_COH_2WAY))) { err = -EINVAL ; - goto madv_fini; + goto free_vmas; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1510/2077 smb: client: fix overflow in passthrough ioctl bounds check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a4f27ad055392fa164f5649e89a3637b033c5fcc ]
smb2_ioctl_query_info() validates the PASSTHRU_FSCTL response payload before copying it to userspace.
The payload offset and length both come from 32-bit fields. The bounds check currently adds OutputOffset and qi.input_buffer_length directly, so the addition can wrap in 32-bit arithmetic before the result is compared against the response buffer length.
A malicious server can use a large OutputOffset and a small OutputCount to make the wrapped sum pass the bounds check. The later copy_to_user() then reads from io_rsp + OutputOffset, outside the response buffer.
Use size_add() for the offset plus length check so overflow is treated as out of bounds.
--- fs/smb/client/smb2ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +2 -2
@@ -1772,8 +1772,8 @@ smb2_ioctl_query_info(const unsigned int xid,if (le32_to_cpu (io_rsp->OutputCount) < qi.input_buffer_length) qi.input_buffer_length =le32_to_cpu (io_rsp->OutputCount);if (qi.input_buffer_length >0 && -le32_to_cpu (io_rsp->OutputOffset) + qi.input_buffer_length - > rsp_iov[1 ].iov_len) { +size_add (le32_to_cpu (io_rsp->OutputOffset), + qi.input_buffer_length) > rsp_iov[1 ].iov_len) { rc = -EFAULT ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1511/2077 drm/imagination: make pvr_fw_trace_init_mask_ops static
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Dooks <[email protected]>
[ Upstream commit c804aadc4ce3dcb34d6f2ecc9a159c148210805a ]
The pvr_fw_trace_init_mask_ops is not used outside pvr_fw_trace.c so make it static to avoid the following sparse warning:
drivers/gpu/drm/imagination/pvr_fw_trace.c:74:31: warning: symbol 'pvr_fw_trace_init_mask_ops' was not declared. Should it be static?
--- drivers/gpu/drm/imagination/pvr_fw_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/imagination/pvr_fw_trace.c +1 -1
@@ -71,7 +71,7 @@ pvr_fw_trace_init_mask_set(const char *val, const struct kernel_param *kp)return 0 ; } -const struct kernel_param_ops pvr_fw_trace_init_mask_ops = { +static const struct kernel_param_ops pvr_fw_trace_init_mask_ops = { .set = pvr_fw_trace_init_mask_set, .get = param_get_hexint, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1512/2077 tracing/remotes: Fix leak in trace_remote_alloc_buffer() error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit ec082d0b978b5fb4c11205ccce63587ac94c74e1 ]
If page allocation fails in trace_remote_alloc_buffer(), desc->nr_cpus is not yet incremented for the current CPU. As a consequence, on error, half-allocated rb_desc will not be freed in trace_remote_free_buffer().
Increment desc->nr_cpus as soon as the first allocation for the current CPU has succeeded.
--- kernel/trace/trace_remote.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_remote.c +2 -1
@@ -1006,6 +1006,8 @@ int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size,if (!rb_desc->meta_va) goto err; + desc->nr_cpus++; +for (id =0 ; id < nr_pages; id++) { rb_desc->page_va[id] = (unsigned long )__get_free_page (GFP_KERNEL );if (!rb_desc->page_va[id])
@@ -1013,7 +1015,6 @@ int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size, rb_desc->nr_page_va++; } - desc->nr_cpus++; desc->struct_len += offsetof(struct ring_buffer_desc , page_va); desc->struct_len +=struct_size (rb_desc, page_va, rb_desc->nr_page_va); rb_desc =__next_ring_buffer_desc (rb_desc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1513/2077 tracing/remotes: Fix struct_len in trace_remote_alloc_buffer()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit d471d4f86e8689ad15309e49da8e5e4e9bb9ce87 ]
Pre-calculate desc->struct_len up-front in trace_remote_alloc_buffer() with trace_buffer_desc_size() to fix double-counting.
While at it, use the accessor __first_ring_buffer_desc().
--- kernel/trace/trace_remote.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
kernel/trace/trace_remote.c +4 -11
@@ -979,27 +979,22 @@ EXPORT_SYMBOL_GPL(trace_remote_free_buffer);int trace_remote_alloc_buffer (struct trace_buffer_desc *desc,size_t desc_size,size_t buffer_size,const struct cpumask *cpumask) { +size_t min_desc_size =trace_buffer_desc_size (buffer_size,cpumask_weight (cpumask));unsigned int nr_pages =max (DIV_ROUND_UP (buffer_size,PAGE_SIZE ),2UL ) +1 ; -void *desc_end = desc + desc_size;struct ring_buffer_desc *rb_desc;int cpu, ret = -ENOMEM ; -if (desc_size <struct_size (desc, __data,0 )) +if (desc_size < min_desc_size)return -EINVAL ; desc->nr_cpus =0 ; - desc->struct_len =struct_size (desc, __data,0 ); + desc->struct_len = min_desc_size; - rb_desc = (struct ring_buffer_desc *)&desc->__data[0 ]; + rb_desc =__first_ring_buffer_desc (desc);for_each_cpu (cpu, cpumask) {unsigned int id; -if ((void *)rb_desc +struct_size (rb_desc, page_va, nr_pages) > desc_end) { - ret = -EINVAL ; - goto err; - } - rb_desc->cpu = cpu; rb_desc->nr_page_va =0 ; rb_desc->meta_va = (unsigned long )__get_free_page (GFP_KERNEL );
@@ -1015,8 +1010,6 @@ int trace_remote_alloc_buffer(struct trace_buffer_desc *desc, size_t desc_size, rb_desc->nr_page_va++; } - desc->struct_len += offsetof(struct ring_buffer_desc , page_va); - desc->struct_len +=struct_size (rb_desc, page_va, rb_desc->nr_page_va); rb_desc =__next_ring_buffer_desc (rb_desc); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1514/2077 ring-buffer: Allow sparse CPU masks in ring_buffer_desc()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 601ddaceb861be7eb557278109966320a6f3478c ]
No user currently relies on sparse CPU masks, but the descriptor logic already supports them via linear fallback. Remove the arbitrary limitation.
--- kernel/trace/ring_buffer.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/trace/ring_buffer.c +1 -4
@@ -2220,10 +2220,7 @@ static struct ring_buffer_desc *ring_buffer_desc(struct trace_buffer_desc *tracesize_t len;int i; -if (!trace_desc) -return NULL ; - -if (cpu >= trace_desc->nr_cpus) +if (!trace_desc || !trace_desc->nr_cpus)return NULL ; end = (struct ring_buffer_desc *)((void *)trace_desc + trace_desc->struct_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1515/2077 idpf: add padding to PTP virtchnl structures
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemyslaw Korba <[email protected]>
commit d1e8f9fd6b98307bc8d2863c7baa465d8a5a43be upstream.
Add padding to virtchnl2 PTP structures to match the Control Plane expected message sizes:
* virtchnl2_ptp_get_dev_clk_time: 8 -> 16 bytes
* virtchnl2_ptp_set_dev_clk_time: 8 -> 16 bytes
* virtchnl2_ptp_get_cross_time: 16 -> 24 bytes
The FW expects the above sizes and PTP negotiation fails due to the mismatch. Previously neither the FW nor the driver checked message/reply sizes strictly, so the problem appeared only after recent validation improvements.
reproduction steps:
ptp4l -i <pf> -m
Observe: failed to open /dev/ptp0: Permission denied
--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/idpf/virtchnl2.h +9 -3
@@ -1572,13 +1572,15 @@ VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2* struct virtchnl2_ptp_get_dev_clk_time - Associated with message * VIRTCHNL2_OP_PTP_GET_DEV_CLK_TIME. * @dev_time_ns: Device clock time value in nanoseconds +* @pad: Padding for future extensions * * PF/VF sends this message to receive the time from the main timer. */ struct virtchnl2_ptp_get_dev_clk_time {__le64 dev_time_ns; +u8 pad[8 ]; }; -VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_ptp_get_dev_clk_time); +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_ptp_get_dev_clk_time);/** * struct virtchnl2_ptp_get_cross_time: Associated with message
@@ -1586,26 +1588,30 @@ VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_* @sys_time_ns: System counter value expressed in nanoseconds, read * synchronously with device time * @dev_time_ns: Device clock time value expressed in nanoseconds +* @pad: Padding for future extensions * * PF/VF sends this message to receive the cross time. */ struct virtchnl2_ptp_get_cross_time {__le64 sys_time_ns;__le64 dev_time_ns; +u8 pad[8 ]; }; -VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_ptp_get_cross_time); +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_ptp_get_cross_time);/** * struct virtchnl2_ptp_set_dev_clk_time: Associated with message * VIRTCHNL2_OP_PTP_SET_DEV_CLK_TIME. * @dev_time_ns: Device time value expressed in nanoseconds to set +* @pad: Padding for future extensions * * PF/VF sends this message to set the time of the main timer. */ struct virtchnl2_ptp_set_dev_clk_time {__le64 dev_time_ns; +u8 pad[8 ]; }; -VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_ptp_set_dev_clk_time); +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_ptp_set_dev_clk_time);/** * struct virtchnl2_ptp_adj_dev_clk_fine: Associated with message
Greg Kroah-Hartman
maintainerPATCH 1516/2077 mlxsw: fix refcount leak in mlxsw_sp_port_lag_join()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 41c8c1d65b32beacd8d916a22457b4f6e47f45af upstream.
When mlxsw_sp_port_lag_index_get() fails, mlxsw_sp_port_lag_join() returns an error without releasing the lag reference obtained by the earlier mlxsw_sp_lag_get(). All other error paths in the function jump to the cleanup label that ends with mlxsw_sp_lag_put(), so this is a single missed release.
Fix the leak by replacing the bare 'return err' with a goto to the existing error cleanup label, which will drop the reference safely.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -1
@@ -4360,7 +4360,7 @@ static int mlxsw_sp_port_lag_join(struct lag_id = lag->lag_id; err =mlxsw_sp_port_lag_index_get (mlxsw_sp, lag_id, &port_index);if (err) -return err; + goto err_lag_uppers_bridge_join; err =mlxsw_sp_lag_uppers_bridge_join (mlxsw_sp_port, lag_dev, extack);
Greg Kroah-Hartman
maintainerPATCH 1517/2077 mlxsw: fix refcount leak in mlxsw_sp_vrs_lpm_tree_replace()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 21cf8dc478a49e8de039c2739b1646a774cb1944 upstream.
When mlxsw_sp_vrs_lpm_tree_replace() fails after replacing some VRs, the error rollback loop does not correctly revert the preceding replacements. The loop decrements the index but fails to update the vr pointer, which still points to the VR that caused the failure. As a result, the condition and the rollback call always operate on the same VR, potentially calling mlxsw_sp_vr_lpm_tree_replace() multiple times on it while never rolling back the earlier VRs. Those VRs continue to hold a reference to new_tree acquired via mlxsw_sp_lpm_tree_hold(), leaking the reference count of new_tree.
Fix by reinitializing vr inside the error loop with the updated index:
vr = &mlxsw_sp->router->vrs[i];
so that the loop correctly iterates over all VRs that were actually replaced.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -0
@@ -1018,6 +1018,7 @@ static int mlxsw_sp_vrs_lpm_tree_replace err_tree_replace:for (i--; i >=0 ; i--) { + vr = &mlxsw_sp->router->vrs[i];if (!mlxsw_sp_vr_lpm_tree_should_replace (vr, proto, new_id))continue ; mlxsw_sp_vr_lpm_tree_replace(mlxsw_sp,
Greg Kroah-Hartman
maintainerPATCH 1518/2077 vduse: Fix race in vduse_dev_msg_sync and vduse_dev_read_iter
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Tianci <[email protected]>
commit ae9c13b6fd79087cc5a216ee1649b6f012c2a238 upstream.
There is one race case in vduse_dev_msg_sync and vduse_dev_read_iter:
vduse_dev_read_iter():
lock(msg_lock);
dequeue_msg(send_list);
unlock(msg_lock);
vduse_dev_msg_sync():
wait_timeout() finish
lock(msg_lock);
check msg->complete is false
list_del(msg); <- double list_del() crash!To fix this case, we shall ensure vduse_msg is on send_list or recv_list outside the msg_lock critical section.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +27 -10
@@ -364,6 +364,7 @@ static ssize_t vduse_dev_read_iter(strucstruct file *file = iocb->ki_filp;struct vduse_dev *dev = file->private_data;struct vduse_dev_msg *msg; +struct vduse_dev_request req;int size =sizeof (struct vduse_dev_request );ssize_t ret;
@@ -375,12 +376,11 @@ static ssize_t vduse_dev_read_iter(struc msg =vduse_dequeue_msg (&dev->send_list);if (msg)break ; +spin_unlock (&dev->msg_lock); - ret = -EAGAIN ;if (file->f_flags &O_NONBLOCK ) - goto unlock; +return -EAGAIN ; -spin_unlock (&dev->msg_lock); ret =wait_event_interruptible_exclusive (dev->waitq, !list_empty (&dev->send_list));if (ret)
@@ -388,17 +388,34 @@ static ssize_t vduse_dev_read_iter(strucspin_lock (&dev->msg_lock); } + +memcpy (&req, &msg->req,sizeof (req)); +/* +* We must ensure vduse_msg is on send_list or recv_list before unlock +* dev->msg_lock. Because vduse_dev_msg_sync() may be timeout when we +* copy data to userspace, and will call list_del() for this msg. +*/ +vduse_enqueue_msg (&dev->recv_list, msg);spin_unlock (&dev->msg_lock); - ret =copy_to_iter (&msg->req, size, to); -spin_lock (&dev->msg_lock); + + ret =copy_to_iter (&req, size, to);if (ret != size) { +/* +* Roll back: move msg back to send_list if still pending. +* +* NOTE: +* vduse_find_msg() must use req.request_id instead of `msg`. +* A malicious userspace may reply to this request, and wake up +* the caller, after which `msg` will have already been freed. +* And here vduse_find_msg() will return NULL then do nothing. +*/ +spin_lock (&dev->msg_lock); + msg =vduse_find_msg (&dev->recv_list, req.request_id); +if (msg) +vduse_enqueue_msg_head (&dev->send_list, msg); +spin_unlock (&dev->msg_lock); ret = -EFAULT ; -vduse_enqueue_msg_head (&dev->send_list, msg); - goto unlock; } -vduse_enqueue_msg (&dev->recv_list, msg); -unlock: -spin_unlock (&dev->msg_lock);return ret; }
Greg Kroah-Hartman
maintainerPATCH 1519/2077 VDUSE: avoid leaking information to userspace
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <[email protected]>
commit 9c1523803445ee0348f62b77793266dd981596e0 upstream.
The bounceing is not necessarily page aligned, so current VDUSE can leak kernel information through mapping bounce pages to userspace. Allocate bounce pages with __GFP_ZERO to avoid leaking information to userspace.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/iova_domain.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/vdpa_user/iova_domain.c +1 -1
@@ -124,7 +124,7 @@ static int vduse_domain_map_bounce_page(if (!map->bounce_page) { head_map = &domain->bounce_maps[(iova &PAGE_MASK ) >>BOUNCE_MAP_SHIFT ];if (!head_map->bounce_page) { - tmp_page =alloc_page (GFP_ATOMIC ); + tmp_page =alloc_page (GFP_ATOMIC | __GFP_ZERO);if (!tmp_page)return -ENOMEM ;if (cmpxchg (&head_map->bounce_page,NULL , tmp_page))
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
@@ -999,7 +999,7 @@ static void *vduse_dev_alloc_coherent(unif (!token.group)return NULL ; - addr =alloc_pages_exact (size, flag); + addr =alloc_pages_exact (size, flag | __GFP_ZERO);if (!addr)return NULL ;
Greg Kroah-Hartman
maintainerPATCH 1520/2077 ASoC: SOF: ipc4-control: Fix TOCTOU in sof_ipc4_bytes_put
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 3ad673e7139cf214afd24321a829aad6575f4163 upstream.
In sof_ipc4_bytes_put(), the copy size is derived from the old data->size in the buffer rather than the incoming new data's size field from ucontrol. If the new data has a different size, the copy uses the wrong length: it may truncate valid data or copy stale bytes.
Fix by validating and using the incoming data's sof_abi_hdr.size from ucontrol before copying.
--- sound/soc/sof/ipc4-control.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
sound/soc/sof/ipc4-control.c +7 -4
@@ -562,6 +562,8 @@ static int sof_ipc4_bytes_put(struct sndstruct snd_soc_component *scomp = scontrol->scomp;struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);struct sof_abi_hdr *data = cdata->data; +const struct sof_abi_hdr *new_hdr = + (const struct sof_abi_hdr *)ucontrol->value.bytes.data;size_t size;int ret;
@@ -572,15 +574,16 @@ static int sof_ipc4_bytes_put(struct sndreturn -EINVAL ; } -/* scontrol->max_size has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (data->size > scontrol->max_size -sizeof (*data)) { +/* Validate the new data's size, not the old one */ +if (new_hdr->size > scontrol->max_size -sizeof (*new_hdr)) {dev_err_ratelimited (scomp->dev,"data size too big %u bytes max is %zu\n" , - data->size, scontrol->max_size -sizeof (*data)); + new_hdr->size, + scontrol->max_size -sizeof (*new_hdr));return -EINVAL ; } - size = data->size +sizeof (*data); + size = new_hdr->size +sizeof (*new_hdr);/* copy from kcontrol */ memcpy (data, ucontrol->value.bytes.data, size);
Greg Kroah-Hartman
maintainerPATCH 1521/2077 ASoC: SOF: ipc4-control: Validate notification payload size
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 5bdfeccb7fbf6e000fc783cd8412732e67c1ad0c upstream.
Validate MODULE_NOTIFICATION payload length before reading bytes/channel data in control update handling.
--- sound/soc/sof/ipc4-control.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
sound/soc/sof/ipc4-control.c +23 -0
@@ -883,6 +883,16 @@ static void sof_ipc4_control_update(stru*/ if (type ==SND_SOC_TPLG_TYPE_BYTES ) {struct sof_abi_hdr *data = cdata->data; +size_t source_size =struct_size (msg_data, data, msg_data->num_elems); + +if (source_size > ndata->event_data_size) { +dev_warn (sdev->dev, +"%s: invalid bytes notification size for %s (%zu, %u)\n" , + __func__, scontrol->name, source_size, + ndata->event_data_size); + scontrol->comp_data_dirty = true; + goto notify; + }if (msg_data->num_elems > scontrol->max_size -sizeof (*data)) { dev_warn(sdev->dev,
@@ -895,6 +905,17 @@ static void sof_ipc4_control_update(stru scontrol->size =sizeof (*cdata) +sizeof (*data) + data->size; } }else { +size_t source_size =struct_size (msg_data, chanv, msg_data->num_elems); + +if (source_size > ndata->event_data_size) { +dev_warn (sdev->dev, +"%s: invalid channel notification size for %s (%zu, %u)\n" , + __func__, scontrol->name, source_size, + ndata->event_data_size); + scontrol->comp_data_dirty = true; + goto notify; + } +for (i =0 ; i < msg_data->num_elems; i++) {u32 channel = msg_data->chanv[i].channel;
@@ -922,6 +943,8 @@ static void sof_ipc4_control_update(stru scontrol->comp_data_dirty = true; } +notify: +/* * Look up the ALSA kcontrol of the scontrol to be able to send a * notification to user space
Greg Kroah-Hartman
maintainerPATCH 1522/2077 ASoC: SOF: ipc3-control: Use overflow checks in control_update size calc
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 8791977d7289f6e9d2b014f60a5455f053a7bc04 upstream.
In sof_ipc3_control_update(), the expected_size calculation uses firmware-provided cdata->num_elems in arithmetic that could overflow on 32-bit platforms, wrapping to a small value. This would allow the cdata->rhdr.hdr.size comparison to pass with mismatched sizes, potentially leading to out-of-bounds access in snd_sof_update_control.
Use check_mul_overflow() and check_add_overflow() to detect and reject overflowed size calculations.
--- sound/soc/sof/ipc3-control.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
sound/soc/sof/ipc3-control.c +16 -4
@@ -626,16 +626,28 @@ static void sof_ipc3_control_update(strureturn ; } - expected_size =sizeof (struct sof_ipc_ctrl_data );switch (cdata->type) {case SOF_CTRL_TYPE_VALUE_CHAN_GET :case SOF_CTRL_TYPE_VALUE_CHAN_SET : - expected_size += cdata->num_elems * -sizeof (struct sof_ipc_ctrl_value_chan ); +if (check_mul_overflow ((size_t )cdata->num_elems, +sizeof (struct sof_ipc_ctrl_value_chan ), + &expected_size)) +return ; +if (check_add_overflow (expected_size, +sizeof (struct sof_ipc_ctrl_data ), + &expected_size)) +return ;break ;case SOF_CTRL_TYPE_DATA_GET :case SOF_CTRL_TYPE_DATA_SET : - expected_size += cdata->num_elems +sizeof (struct sof_abi_hdr ); +if (check_add_overflow ((size_t )cdata->num_elems, +sizeof (struct sof_abi_hdr ), + &expected_size)) +return ; +if (check_add_overflow (expected_size, +sizeof (struct sof_ipc_ctrl_data ), + &expected_size)) +return ;break ;default :return ;
Greg Kroah-Hartman
maintainerPATCH 1523/2077 ASoC: SOF: ipc3-control: Fix TOCTOU in bytes_put and bytes_get
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 1f97760417b5faa60e9642fd0ed61eb17d0b1b39 upstream.
In sof_ipc3_bytes_put(), the size used for the memcpy is derived from the old data->size already in the buffer, not the incoming new data's size field. If the new data has a different size, the copy length is
wrong: it may truncate valid data or copy stale bytes.
Similarly, sof_ipc3_bytes_get() checks data->size against max_size without accounting for the sizeof(struct sof_ipc_ctrl_data) offset of the flex array within the allocation.
Fix bytes_put to validate and use the incoming data's sof_abi_hdr.size from ucontrol before copying. Fix bytes_get to subtract sizeof(*cdata) from the bounds check to match the actual available space.
--- sound/soc/sof/ipc3-control.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
sound/soc/sof/ipc3-control.c +16 -7
@@ -315,10 +315,13 @@ static int sof_ipc3_bytes_get(struct snd }/* be->max has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (data->size > scontrol->max_size -sizeof (*data)) { +if (data->size > scontrol->max_size -sizeof (*cdata) - +sizeof (*data)) {dev_err_ratelimited (scomp->dev,"%u bytes of control data is invalid, max is %zu\n" , - data->size, scontrol->max_size -sizeof (*data)); + data->size, + scontrol->max_size -sizeof (*cdata) - +sizeof (*data));return -EINVAL ; }
@@ -336,6 +339,8 @@ static int sof_ipc3_bytes_put(struct sndstruct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;struct snd_soc_component *scomp = scontrol->scomp;struct sof_abi_hdr *data = cdata->data; +const struct sof_abi_hdr *new_hdr = + (const struct sof_abi_hdr *)ucontrol->value.bytes.data;size_t size;if (scontrol->max_size >sizeof (ucontrol->value.bytes.data)) {
@@ -344,14 +349,18 @@ static int sof_ipc3_bytes_put(struct sndreturn -EINVAL ; } -/* scontrol->max_size has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (data->size > scontrol->max_size -sizeof (*data)) { -dev_err_ratelimited (scomp->dev,"data size too big %u bytes max is %zu\n" , - data->size, scontrol->max_size -sizeof (*data)); +/* Validate the new data's size, not the old one */ +if (new_hdr->size > scontrol->max_size -sizeof (*cdata) - +sizeof (*new_hdr)) { +dev_err_ratelimited (scomp->dev, +"data size too big %u bytes max is %zu\n" , + new_hdr->size, + scontrol->max_size -sizeof (*cdata) - +sizeof (*new_hdr));return -EINVAL ; } - size = data->size +sizeof (*data); + size = new_hdr->size +sizeof (*new_hdr);/* copy from kcontrol */ memcpy (data, ucontrol->value.bytes.data, size);
Greg Kroah-Hartman
maintainerPATCH 1524/2077 ASoC: SOF: topology: validate vendor array size before parsing
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 8468dd79cfb2ffbdeaf7c353f63d64941cb8ba05 upstream.
sof_parse_token_sets() reads array->size while iterating over topology private data. The loop condition only checks that some data remains, so a malformed topology with a truncated trailing vendor array can make the parser read the size field before a full vendor-array header is available.
Validate that the remaining private data contains a complete snd_soc_tplg_vendor_array header before reading array->size.
The declared array size check also needs to remain signed. asize is an int, but sizeof(*array) has type size_t, so comparing them directly promotes negative asize values to unsigned and lets them pass the check, as reported in the stable review thread reference below.
Cast sizeof(*array) to int when validating the declared array size. This rejects negative, zero and otherwise too-small sizes before the parser dispatches to the tuple-specific code.
--- sound/soc/sof/topology.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/sof/topology.c +4 -1
@@ -733,10 +733,13 @@ static int sof_parse_token_sets(struct sint ret;while (array_size >0 && total < count * token_instance_num) { +if (array_size < (int )sizeof (*array)) +return -EINVAL ; + asize =le32_to_cpu (array->size);/* validate asize */ -if (asize <sizeof (*array)) { +if (asize < (int )sizeof (*array)) {dev_err (scomp->dev,"error: invalid array size 0x%x\n" , asize);return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 1525/2077 tipc: restrict socket queue dumps in enqueue tracepoints
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Xiasong <[email protected]>
commit acd7df8d955480a6f6e5bb809da67b1500cc3cf4 upstream.
tipc_sk_enqueue() runs with sk->sk_lock.slock held while the socket is owned by user context. The spinlock protects the backlog queue in this path, but it does not serialize against the socket owner consuming or purging sk_receive_queue.
KASAN reported:
CPU: 14 UID: 0 PID: 1050 Comm: tipc3 Not tainted 7.1.0-rc6+ #126 PREEMPT(lazy)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x76/0xa0 lib/dump_stack.c:123
print_report+0xce/0x5b0 mm/kasan/report.c:482
kasan_report+0xc6/0x100 mm/kasan/report.c:597
__asan_report_load4_noabort+0x14/0x30 mm/kasan/report_generic.c:380
tipc_skb_dump+0x1327/0x16f0 net/tipc/trace.c:73
tipc_list_dump+0x208/0x2e0 net/tipc/trace.c:187
tipc_sk_dump+0xaf6/0xd60 net/tipc/socket.c:3996
trace_event_raw_event_tipc_sk_class+0x312/0x5a0 net/tipc/trace.h:188
tipc_sk_rcv+0xb1d/0x1d50 net/tipc/socket.c:2497
tipc_node_xmit+0x1c3/0x1440 net/tipc/node.c:1689
__tipc_sendmsg+0x97a/0x1440 net/tipc/socket.c:1512
tipc_sendmsg+0x52/0x80 net/tipc/socket.c:1400
sock_sendmsg+0x2f6/0x3e0 net/socket.c:825
splice_to_socket+0x7f9/0x1010 fs/splice.c:884
do_splice+0xe21/0x2330 fs/splice.c:936
__do_splice+0x153/0x260 fs/splice.c:1431
__x64_sys_splice+0x150/0x230 fs/splice.c:1616
x64_sys_call+0xeb5/0x2790 arch/x86/entry/syscall_64.c:41
do_syscall_64+0xf3/0x620 arch/x86/entry/syscall_64.c:63
entry_SYSCALL_64_after_hwframe+0x76/0x7e arch/x86/entry/entry_64.S:130
RIP: 0033:0x71624e8aafe2
Code: 08 0f 85 71 3a ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 66 2e 0f 1f 84 00 00 00 00 00 66
RSP: 002b:0000716157ffed68 EFLAGS: 00000246 ORIG_RAX: 0000000000000113
RAX: ffffffffffffffda RBX: 0000716157fff6c0 RCX: 000071624e8aafe2
RDX: 000000000000005f RSI: 0000000000000000 RDI: 0000000000000066
RBP: 0000716157ffed90 R08: 0000000000008000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: ffffffffffffff00
R13: 0000000000000021 R14: 0000000000000000 R15: 00007fff89799c40
</TASK>The TIPC_DUMP_ALL tracepoints in tipc_sk_enqueue() also dump sk_receive_queue and can therefore dereference skbs that the socket owner has already dequeued or freed. Restrict these dumps to TIPC_DUMP_SK_BKLGQ, which matches the queue protected by the held spinlock.
Keep the change limited to the enqueue path, where the unsafe queue dump is reachable while the socket is owned by user context.
--- net/tipc/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/tipc/socket.c +3 -3
@@ -2455,17 +2455,17 @@ static void tipc_sk_enqueue(struct sk_buatomic_set (dcnt,0 ); lim =rcvbuf_limit (sk, skb) +atomic_read (dcnt);if (likely (!sk_add_backlog (sk, skb, lim))) { -trace_tipc_sk_overlimit1 (sk, skb,TIPC_DUMP_ALL , +trace_tipc_sk_overlimit1 (sk, skb,TIPC_DUMP_SK_BKLGQ ,"bklg & rcvq >90% allocated!" );continue ; } -trace_tipc_sk_dump (sk, skb,TIPC_DUMP_ALL ,"err_overload!" ); +trace_tipc_sk_dump (sk, skb,TIPC_DUMP_SK_BKLGQ ,"err_overload!" );/* Overload => reject message back to sender */ onode =tipc_own_addr (sock_net (sk));sk_drops_inc (sk);if (tipc_msg_reverse (onode, &skb,TIPC_ERR_OVERLOAD )) { -trace_tipc_sk_rej_msg (sk, skb,TIPC_DUMP_ALL , +trace_tipc_sk_rej_msg (sk, skb,TIPC_DUMP_SK_BKLGQ ,"@sk_enqueue!" );__skb_queue_tail (xmitq, skb); }
Greg Kroah-Hartman
maintainerPATCH 1526/2077 net: qrtr: fix 32-bit integer overflow in qrtr_endpoint_post()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 20054869770c7df060c5ecee3e8bbf9029c47191 upstream.
qrtr_endpoint_post() validates an incoming packet with
if (!size || len != ALIGN(size, 4) + hdrlen) goto err;
where size comes from the wire. On 32-bit, size_t is 32 bits and ALIGN(size, 4) wraps to 0 for size >= 0xfffffffd, so the check passes and skb_put_data(skb, data + hdrlen, size) writes past the hdrlen-sized skb and oopses the kernel. 64-bit is unaffected.
This is the 32-bit residual of ad9d24c9429e2 ("net: qrtr: fix OOB Read in qrtr_endpoint_post"), which fixed only the 64-bit case.
Reject any size that cannot fit the buffer before the ALIGN.
--- net/qrtr/af_qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/qrtr/af_qrtr.c +1 -1
@@ -496,7 +496,7 @@ int qrtr_endpoint_post(struct qrtr_endpoif (cb->dst_port ==QRTR_PORT_CTRL_LEGACY ) cb->dst_port =QRTR_PORT_CTRL ; -if (!size || len !=ALIGN (size,4 ) + hdrlen) +if (!size || size > len || len !=ALIGN (size,4 ) + hdrlen) goto err; if ((cb->type == QRTR_TYPE_NEW_SERVER ||
Greg Kroah-Hartman
maintainerPATCH 1527/2077 net: atm: reject out-of-range traffic classes in QoS validation
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
commit cdf19f380e46192e7084be559638aab1f6ed86a2 upstream.
Reject ATM traffic classes above ATM_ANYCLASS in check_tp(). SO_ATMQOS stores the supplied QoS after check_qos() succeeds, so accepting larger values leaves invalid traffic_class values in vcc->qos.
That bad state later reaches pvc_info(), which indexes class_name[] with vcc->qos.{rx,tp}.traffic_class. Values above ATM_ANYCLASS cause an out-of-bounds read when /proc/net/atm/pvc is read.
Tighten the existing QoS validation so invalid traffic_class values are rejected at the point where user supplied QoS is accepted.
--- net/atm/common.c | 2 ++ 1 file changed, 2 insertions(+)
net/atm/common.c +2 -0
@@ -720,6 +720,8 @@ static int atm_change_qos(struct atm_vccstatic int check_tp (const struct atm_trafprm *tp) {/* @@@ Should be merged with adjust_tp */ +if (tp->traffic_class >ATM_ANYCLASS ) +return -EINVAL ;if (!tp->traffic_class || tp->traffic_class ==ATM_ANYCLASS )return 0 ; if (tp->traffic_class != ATM_UBR && !tp->min_pcr && !tp->pcr &&
Greg Kroah-Hartman
maintainerPATCH 1528/2077 octeontx2-pf: clear stale mailbox IRQ state before request_irq()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit f918554fb7246e89b98ef90abe80801f038258b3 upstream.
otx2_register_mbox_intr() currently installs the PF mailbox IRQ handler before clearing stale mailbox interrupt state. The function itself then comments that the local interrupt bits must be cleared first to avoid spurious interrupts, but that clear happens only after request_irq() has already exposed the handler to irq delivery.
A running system can reach this during PF mailbox interrupt registration while stale or latched RVU_PF_INT state is still present. If delivery happens in the request_irq()-to-clear window, otx2_pfaf_mbox_intr_handler() can run before local quiesce and touch the same pf->mbox and pf->mbox_wq carrier that probe and teardown later reuse or destroy.
Move the stale mailbox interrupt clear ahead of request_irq(), but keep interrupt enabling after the handler is installed. This closes the pre-clear early-IRQ window without creating a new enable-before-handler window.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 20 ++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +9 -11
@@ -1119,9 +1119,16 @@ int otx2_register_mbox_intr(struct otx2_ {struct otx2_hw *hw = &pf->hw;struct msg_req *req; +u64 mbox_int_mask;char *irq_name;int err; + mbox_int_mask = !is_cn20k (pf->pdev) ?BIT_ULL (0 ) : +BIT_ULL (0 ) |BIT_ULL (1 ); + +/* Clear stale mailbox interrupt state before installing the handler. */ +otx2_write64 (pf,RVU_PF_INT , mbox_int_mask); +/* Register mailbox interrupt handler */ if (!is_cn20k (pf->pdev)) { irq_name = &hw->irq_name[RVU_PF_INT_VEC_AFPF_MBOX *NAME_SIZE ];
@@ -1147,17 +1154,8 @@ int otx2_register_mbox_intr(struct otx2_return err; } -/* Enable mailbox interrupt for msgs coming from AF. -* First clear to avoid spurious interrupts, if any. -*/ -if (!is_cn20k (pf->pdev)) { -otx2_write64 (pf,RVU_PF_INT ,BIT_ULL (0 )); -otx2_write64 (pf,RVU_PF_INT_ENA_W1S ,BIT_ULL (0 )); - }else { -otx2_write64 (pf,RVU_PF_INT ,BIT_ULL (0 ) |BIT_ULL (1 )); -otx2_write64 (pf,RVU_PF_INT_ENA_W1S ,BIT_ULL (0 ) | -BIT_ULL (1 )); - } +/* Enable mailbox interrupt for msgs coming from AF. */ +otx2_write64 (pf,RVU_PF_INT_ENA_W1S , mbox_int_mask);if (!probe_af)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 1529/2077 octeontx2-vf: clear stale mailbox IRQ state before request_irq()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 0b352f04b9be2c83c0240aa6dae7257fefa90464 upstream.
otx2vf_register_mbox_intr() currently installs the VF mailbox IRQ handler before clearing stale mailbox interrupt state. The code then says that local interrupt bits should be cleared first to avoid spurious interrupts, but that clear still happens only after request_irq() has already made the handler reachable.
A running system can reach this during VF mailbox interrupt registration while stale or latched RVU_VF_INT state is still present. If delivery happens in the request_irq()-to-clear window, otx2vf_vfaf_mbox_intr_handler() can run before local quiesce and touch the same vf->mbox and vf->mbox_wq carrier that probe and teardown later reuse or destroy.
Move the stale mailbox interrupt clear ahead of request_irq(), but keep interrupt enabling after the handler is installed. This closes the pre-clear early-IRQ window without creating a new enable-before-handler window.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 22 ++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +10 -12
@@ -251,9 +251,17 @@ static int otx2vf_register_mbox_intr(str {struct otx2_hw *hw = &vf->hw;struct msg_req *req; +u64 mbox_int_mask;char *irq_name;int err; + mbox_int_mask = !is_cn20k (vf->pdev) ?BIT_ULL (0 ) : +BIT_ULL (0 ) |BIT_ULL (1 ) | +BIT_ULL (2 ) |BIT_ULL (3 ); + +/* Clear stale mailbox interrupt state before installing the handler. */ +otx2_write64 (vf,RVU_VF_INT , mbox_int_mask); +/* Register mailbox interrupt handler */ irq_name = &hw->irq_name[RVU_VF_INT_VEC_MBOX *NAME_SIZE ]; snprintf(irq_name, NAME_SIZE, "RVUVF%d AFVF Mbox", ((vf->pcifunc &
@@ -274,18 +282,8 @@ static int otx2vf_register_mbox_intr(strreturn err; } -/* Enable mailbox interrupt for msgs coming from PF. -* First clear to avoid spurious interrupts, if any. -*/ -if (!is_cn20k (vf->pdev)) { -otx2_write64 (vf,RVU_VF_INT ,BIT_ULL (0 )); -otx2_write64 (vf,RVU_VF_INT_ENA_W1S ,BIT_ULL (0 )); - }else { -otx2_write64 (vf,RVU_VF_INT ,BIT_ULL (0 ) |BIT_ULL (1 ) | -BIT_ULL (2 ) |BIT_ULL (3 )); -otx2_write64 (vf,RVU_VF_INT_ENA_W1S ,BIT_ULL (0 ) | -BIT_ULL (1 ) |BIT_ULL (2 ) |BIT_ULL (3 )); - } +/* Enable mailbox interrupt for msgs coming from PF. */ +otx2_write64 (vf,RVU_VF_INT_ENA_W1S , mbox_int_mask);if (!probe_pf)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 1530/2077 net: ife: require ETH_HLEN to be pullable in ife_decode()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yong Wang <[email protected]>
commit 9406f6012b7343661efb516a11c62d4db2b62f75 upstream.
ife decode may return after making only the outer IFE header and metadata pullable. The caller then passes the decapsulated packet to eth_type_trans(), which expects the inner Ethernet header to be accessible from the linear data area.
With a malformed IFE frame, the inner Ethernet header may still be shorter than ETH_HLEN in the linear area, which can lead to a crash in the original code.
Fix this by extending the pull check in ife_decode() so that the inner Ethernet header is also guaranteed to be pullable before returning.
--- net/ife/ife.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ife/ife.c +1 -1
@@ -79,7 +79,7 @@ void *ife_decode(struct sk_buff *skb, u1if (unlikely (ifehdrln <2 ))return NULL ; -if (unlikely (!pskb_may_pull (skb, total_pull))) +if (unlikely (!pskb_may_pull (skb, total_pull +ETH_HLEN )))return NULL ; ifehdr = (struct ifeheadr *)(skb->data + skb->dev->hard_header_len);
Greg Kroah-Hartman
maintainerPATCH 1531/2077 arm64: fpsimd: Fix type mismatch in sve_{save,load}_state()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit ae24f6b06e90681ec36b9c21c3f5c09618350f5a upstream.
The sve_save_state() and sve_load_state() functions take a 32-bit int argument that describes whether to save/restore the FFR. Their assembly implementations consume the entire 64-bit register containing this 32-bit value, and will attempt to save/restore the FFR if any bit of that 64-bit register is non-zero.
Per the AAPCS64 parameter passing rules, the callee is responsible for any necessary widening, and the upper 32-bits are permitted to contain arbitrary values. If the upper 32 bits are non-zero, this could result in an unexpected attempt to save/restore the FFR, and consequently could lead to unexpected traps/undefs/faults.
In practice compilers are very unlikely to generate code where the upper 32-bits would be non-zero, but they are permitted to do so.
Fix this by only consuming the low 32 bits of the register, and update comments accordingly.
The hyp code __sve_save_state() and __sve_restore_state() functions don't have the same latent bug as they override the full 64-bit register containing the argument.
--- arch/arm64/kernel/entry-fpsimd.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/kernel/entry-fpsimd.S +4 -4
@@ -38,10 +38,10 @@ SYM_FUNC_END(fpsimd_load_state) * * x0 - pointer to buffer for state * x1 - pointer to storage for FPSR - * x2 - Save FFR if non-zero + * w2 - Save FFR if non-zero */ SYM_FUNC_START(sve_save_state) - sve_save 0, x1, x2, 3 + sve_save 0, x1, w2, 3 ret SYM_FUNC_END(sve_save_state)
@@ -50,10 +50,10 @@ SYM_FUNC_END(sve_save_state) * * x0 - pointer to buffer for state * x1 - pointer to storage for FPSR - * x2 - Restore FFR if non-zero + * w2 - Restore FFR if non-zero */ SYM_FUNC_START(sve_load_state) - sve_load 0, x1, x2, 4 + sve_load 0, x1, w2, 4 ret SYM_FUNC_END(sve_load_state)
Greg Kroah-Hartman
maintainerPATCH 1532/2077 arm64: dts: s32g3: Fix SWT8 watchdog address
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 65210e81f7837a871a17237d15e4b1191d5e8771 upstream.
Add missing hex annotation to fix the SWT8 watchdog address in 'reg' property, as reported by dtc W=1:
s32g3.dtsi:863.27-869.5: Warning (simple_bus_reg): /soc@0/watchdog@40500000: simple-bus unit address format error, expected "269fb20"
Lack of hex '0x' meant address would be interpreted as decimal thus completely different value used as this device MMIO. If device was enabled this could lead to corruption of other device address space and broken boot.
--- arch/arm64/boot/dts/freescale/s32g3.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/s32g3.dtsi +1 -1
@@ -862,7 +862,7 @@ swt8: watchdog@40500000 { compatible = "nxp,s32g3-swt", "nxp,s32g2-swt"; - reg = <40500000 0x1000>; + reg = <0x40500000 0x1000>; clocks = <&clks 0x3a>, <&clks 0x3b>, <&clks 0x3b>; clock-names = "counter", "module", "register"; status = "disabled";
Greg Kroah-Hartman
maintainerPATCH 1533/2077 arm64: dts: renesas: ironhide: Describe inline ECC carveouts
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
commit 6fa6ee724d8dadf392139e242ac936b5da730c4b upstream.
The DBSC5 DRAM controller protects DRAM content using inline ECC. The inline ECC utilizes areas of DRAM for its operation, which are in the DRAM address range, but must not be accessed or modified. Describe the inline ECC carveout areas used by the DBSC5 controller on this hardware as reserved-memory, which must not be accessed. Include DRAM areas which are unprotected by ECC as well, those are parts of the DRAM which directly precede the ECC carveout.
In case of high DRAM utilization, unless the inline ECC carveouts are properly reserved, Linux may use and corrupt the memory used by the DBSC5 DRAM controller for inline ECC, which would lead to the system becoming unstable.
--- arch/arm64/boot/dts/renesas/r8a78000-ironhide.dts | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+)
arch/arm64/boot/dts/renesas/r8a78000-ironhide.dts +41 -0
@@ -93,6 +93,47 @@ reg = <0x0 0x8c400000 0x0 0x02000000>; no-map; }; + + /* DRAM controller inline ECC areas */ + ecc@10cccc0000 { + reg = <0x10 0xcccc0000 0x0 0x33340000>; + no-map; + }; + + ecc@12cccc0000 { + reg = <0x12 0xcccc0000 0x0 0x33340000>; + no-map; + }; + + ecc@14cccc0000 { + reg = <0x14 0xcccc0000 0x0 0x33340000>; + no-map; + }; + + ecc@16cccc0000 { + reg = <0x16 0xcccc0000 0x0 0x33340000>; + no-map; + }; + + ecc@18cccc0000 { + reg = <0x18 0xcccc0000 0x0 0x33340000>; + no-map; + }; + + ecc@1a66660000 { + reg = <0x1a 0x66660000 0x0 0x999a0000>; + no-map; + }; + + ecc@1c66660000 { + reg = <0x1c 0x66660000 0x0 0x999a0000>; + no-map; + }; + + ecc@1e66660000 { + reg = <0x1e 0x66660000 0x0 0x999a0000>; + no-map; + }; }; };
Greg Kroah-Hartman
maintainerPATCH 1534/2077 ARM: dts: imx6ul-var-som: fix warning for non-existent dc-supply property
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
commit 0372cc5776e7fd5570884aed0c1e9a8a546cad66 upstream.
The dc-supply property is non-existent in Linux now, nor when this DTS file was created when importing it from Variscite own kernel.
Therefore remove it to fix this warning:
imx6ul-var-som-concerto.dtb: cpu@0 (arm,cortex-a7): Unevaluated properties are not allowed ('dc-supply' was unexpected)
from schema $id: http://devicetree.org/schemas/arm/cpus.yaml
--- arch/arm/boot/dts/nxp/imx/imx6ul-var-som.dtsi | 4 ---- 1 file changed, 4 deletions(-)
arch/arm/boot/dts/nxp/imx/imx6ul-var-som.dtsi +0 -4
@@ -45,10 +45,6 @@ assigned-clock-rates = <786432000>; }; -&cpu0 { - dc-supply = <®_gpio_dvfs>; -}; - &fec1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet1>, <&pinctrl_enet1_gpio>, <&pinctrl_enet1_mdio>;
Greg Kroah-Hartman
maintainerPATCH 1535/2077 arm64: dts: qcom: sdm630: describe adsp_mem region properly
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolay Goppen <[email protected]>
commit ce414263e9ebe5080381a50cbdf9065c29816202 upstream.
Downstream [1] this region is marked as shared, reusable and dynamic so describe it that way.
--- arch/arm64/boot/dts/qcom/sdm630.dtsi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/qcom/sdm630.dtsi +6 -3
@@ -494,9 +494,12 @@ no-map; }; - adsp_mem: adsp-region@f6000000 { - reg = <0x0 0xf6000000 0x0 0x800000>; - no-map; + adsp_mem: adsp-region { + compatible = "shared-dma-pool"; + alloc-ranges = <0x0 0x80000000 0x0 0x80000000>; + alignment = <0x0 0x400000>; + size = <0x0 0x800000>; + reusable; }; qseecom_mem: qseecom-region@f6800000 {
Greg Kroah-Hartman
maintainerPATCH 1536/2077 arm64: dts: rockchip: fix Ethernet PHY not found on PX30 Ringneck
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quentin Schulz <[email protected]>
commit ae653cb854f36d1555681ce70ca3d80d0ec73516 upstream.
When not passing the PHY ID with an ethernet-phy-idX.Y compatible property, the MDIO bus will attempt to auto-detect the PHY by reading its registers and then probing the appropriate driver. For this to work, the PHY needs to be in a working state.
Unfortunately, the net subsystem doesn't control the PHY reset GPIO when attempting to auto-detect the PHY. This means the PHY needs to be in a working state when entering the Linux kernel. This historically has been the case for this device, but only because the bootloader was taking care of initializing the Ethernet controller even when not using it. We're attempting to support the removal of the network stack in the bootloader, which means the Linux kernel will be entered with the PHY still in reset and now Ethernet doesn't work anymore.
The devices in the field only ever had a TI DP83825, so let's simply bypass the auto-detection mechanism entirely by passing the appropriate PHY IDs via the compatible.
Note that this is only an issue since commit e463625af7f9 ("arm64: dts:
rockchip: move reset to dedicated eth-phy node on ringneck") as before that commit the reset was done by the MAC controller before starting the MDIO auto-detection mechanism, via the snps,reset-* properties.
--- arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi +1 -1
@@ -344,7 +344,7 @@ &mdio { dp83825: ethernet-phy@0 { - compatible = "ethernet-phy-ieee802.3-c22"; + compatible = "ethernet-phy-id2000.a140"; reg = <0x0>; pinctrl-names = "default"; pinctrl-0 = <&phy_rst>;
Greg Kroah-Hartman
maintainerPATCH 1537/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Fix ADC sampling times
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit 8407e611faf80ce790a393addf7b44cc595742af upstream.
Increase the minimum ADC sample times for all configured channels on ADC1 and ADC2 to ensure measurement accuracy meets specifications.
The default 5us sample time is insufficient for the internal sampling capacitor to fully charge. Increase the default time to 20us to relax the input impedance requirements.
Additionally, the phint0_ain and phint1_ain channels require a much longer sampling period due to their specific circuit design. Increase their sample times to 200us. Remove stale comments regarding clock cycles that no longer match the updated timings.
--- arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 32 +++++++++++-------------- 1 file changed, 15 insertions(+), 17 deletions(-)
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +15 -17
@@ -104,80 +104,79 @@ channel@0 { reg = <0>; - /* 16.5 ck_cycles sampling time */ - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "p24v_stp"; }; channel@1 { reg = <1>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "p24v_hpdcm"; }; channel@2 { reg = <2>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "ain0"; }; channel@3 { reg = <3>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpdcm1_i2"; }; channel@5 { reg = <5>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpout1_i"; }; channel@6 { reg = <6>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "ain1"; }; channel@9 { reg = <9>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpout0_i"; }; channel@10 { reg = <10>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <200000>; label = "phint0_ain"; }; channel@13 { reg = <13>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <200000>; label = "phint1_ain"; }; channel@15 { reg = <15>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpdcm0_i1"; }; channel@16 { reg = <16>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "lsin"; }; channel@18 { reg = <18>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpdcm0_i2"; }; channel@19 { reg = <19>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "hpdcm1_i1"; }; };
@@ -187,14 +186,13 @@ channel@2 { reg = <2>; - /* 16.5 ck_cycles sampling time */ - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "ain2"; }; channel@6 { reg = <6>; - st,min-sample-time-ns = <5000>; + st,min-sample-time-ns = <20000>; label = "ain3"; }; };
Greg Kroah-Hartman
maintainerPATCH 1538/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Move divergent mecio1 ADC channels to board files
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit 70f1d8fcbd121a40f51b6c846d41e8cbb38ba210 upstream.
Move the divergent adc1 channel definitions out of the common mecio1-io.dtsi file and into the specific Revision 0 and Revision 1 board files.
The original common file contained incorrect schematic labels for the Revision 0 hardware (e.g., labeling ana0 as p24v_hpdcm instead of ain_aux0) and failed to account for physical signal routing changes between the board revisions.
Retain only the strictly shared channels in the common include file. Map the correct channels and schematic labels directly within stm32mp151c-mecio1r0.dts and stm32mp153c-mecio1r1.dts.
Crucially, ensure that the required 200us sample time follows the phint1_ain signal to its new physical location on channel 3 for the Revision 1 hardware.
--- arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts | 50 +++++++++++++++++++++++++ arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts | 50 +++++++++++++++++++++++++ arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 50 ------------------------- 3 files changed, 101 insertions(+), 49 deletions(-)
arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts +50 -0
@@ -36,6 +36,56 @@ }; }; +&adc1 { + channel@0 { + reg = <0>; + st,min-sample-time-ns = <20000>; + label = "ain_aux0"; + }; + + channel@1 { + reg = <1>; + st,min-sample-time-ns = <20000>; + label = "ain_aux1"; + }; + + channel@3 { + reg = <3>; + st,min-sample-time-ns = <20000>; + label = "hpdcm1_i2"; + }; + + channel@5 { + reg = <5>; + st,min-sample-time-ns = <20000>; + label = "pout1_i"; + }; + + channel@9 { + reg = <9>; + st,min-sample-time-ns = <20000>; + label = "pout0_i"; + }; + + channel@13 { + reg = <13>; + st,min-sample-time-ns = <200000>; + label = "phint1_ain"; + }; + + channel@15 { + reg = <15>; + st,min-sample-time-ns = <20000>; + label = "hpdcm0_i1"; + }; + + channel@18 { + reg = <18>; + st,min-sample-time-ns = <20000>; + label = "hpdcm0_i2"; + }; +}; + &clk_hse { clock-frequency = <25000000>; };
arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts +50 -0
56 lines not on this page · raw message
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +1 -49
86 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 1539/2077 arm64: dts: ti: k3-am62a7-sk: Add bootph-all tag to vqmmc
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
commit d8fe8442366ffd8306575028bda92389d0dfb674 upstream.
Add bootph-all property to vqmmc voltage regulator node and its corresponding pinmux node to make it available during all boot phases. This allows to run tuning early in SPL stages of boot.
--- arch/arm64/boot/dts/ti/k3-am62a7-sk.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-am62a7-sk.dts +2 -0
@@ -154,6 +154,7 @@ gpios = <&main_gpio0 31 GPIO_ACTIVE_HIGH>; states = <1800000 0x0>, <3300000 0x1>; + bootph-all; }; leds {
@@ -407,6 +408,7 @@ pinctrl-single,pins = < AM62AX_IOPAD(0x07c, PIN_OUTPUT, 7) /* (N22) GPMC0_CLK.GPIO0_31 */ >; + bootph-all; }; main_ecap0_pins_default: main-ecap0-default-pins {
Greg Kroah-Hartman
maintainerPATCH 1540/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Enable internal ADC reference
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit c84f22405085d91cd5f0c5b967318371c07904ba upstream.
Switch the ADC reference supply from the general 3.3V rail to the internal 2.5V VREFBUF regulator. The ADC circuits on this board are designed for the internal 2.5V reference. Without this change, all ADC measurement values are incorrect.
--- arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +8 -1
@@ -95,7 +95,7 @@ pinctrl-names = "default"; vdd-supply = <&v3v3>; vdda-supply = <&v3v3>; - vref-supply = <&v3v3>; + vref-supply = <&vrefbuf>; status = "okay"; };
@@ -362,6 +362,13 @@ phy-supply = <&v3v3>; }; +&vrefbuf { + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <2500000>; + vdda-supply = <&v3v3>; + status = "okay"; +}; + &pinctrl { adc12_pins_mecsbc: adc12-ain-mecsbc-0 { pins {
Greg Kroah-Hartman
maintainerPATCH 1541/2077 arm64: dts: imx8ulp-evk: Correct Type-C int GPIO flags
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit b4f5c46163b3fe3ec7ed8a76dff8b7e80a776a1f upstream.
IRQ_TYPE_xxx flags are not correct in the context of GPIO flags. These are simple defines so they could be used in DTS but they will not have the same meaning: IRQ_TYPE_EDGE_FALLING = 2 = GPIO_SINGLE_ENDED.
Correct the Type-C int-gpios to use proper flags, assuming the author of the code wanted similar logical behavior:
IRQ_TYPE_EDGE_FALLING => GPIO_ACTIVE_LOW
--- arch/arm64/boot/dts/freescale/imx8ulp-evk.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8ulp-evk.dts +2 -2
@@ -166,7 +166,7 @@ ptn5150_1: typec@1d { compatible = "nxp,ptn5150"; reg = <0x1d>; - int-gpios = <&gpiof 3 IRQ_TYPE_EDGE_FALLING>; + int-gpios = <&gpiof 3 GPIO_ACTIVE_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_typec1>; status = "disabled";
@@ -182,7 +182,7 @@ ptn5150_2: typec@3d { compatible = "nxp,ptn5150"; reg = <0x3d>; - int-gpios = <&gpiof 5 IRQ_TYPE_EDGE_FALLING>; + int-gpios = <&gpiof 5 GPIO_ACTIVE_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_typec2>; status = "disabled";
Greg Kroah-Hartman
maintainerPATCH 1542/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Fix GPIO names typo
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit b04ccecb714de913e360f0866c66f38e1606e89b upstream.
The reset pins for the LPOUT lines were incorrectly prefixed with "GPOUT" instead of "LPOUT" in the gpio-line-names array. Fix these typos so the pin names consistently match the LPOUT0-4 signals they belong to.
--- arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +5 -5
@@ -185,14 +185,14 @@ &gpioe { gpio-line-names = "HPOUT0_RESETN", "HPOUT1", "HPOUT1_ALERTN", "", "", "", "HPOUT1_RESETN", - "LPOUT0", "LPOUT0_ALERTN", "GPOUT0_RESETN", - "LPOUT1", "LPOUT1_ALERTN", "GPOUT1_RESETN", - "LPOUT2", "LPOUT2_ALERTN", "GPOUT2_RESETN"; + "LPOUT0", "LPOUT0_ALERTN", "LPOUT0_RESETN", + "LPOUT1", "LPOUT1_ALERTN", "LPOUT1_RESETN", + "LPOUT2", "LPOUT2_ALERTN", "LPOUT2_RESETN"; }; &gpiof { - gpio-line-names = "LPOUT3", "LPOUT3_ALERTN", "GPOUT3_RESETN", - "LPOUT4", "LPOUT4_ALERTN", "GPOUT4_RESETN", + gpio-line-names = "LPOUT3", "LPOUT3_ALERTN", "LPOUT3_RESETN", + "LPOUT4", "LPOUT4_ALERTN", "LPOUT4_RESETN", "", "", "", "", "", "", "", "", "", "";
Greg Kroah-Hartman
maintainerPATCH 1543/2077 arm64: dts: qcom: hamoa: Fix OPP tables for all DisplayPort controllers
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
commit c17e220946675232d383620ed9cff6685735ec48 upstream.
According to internal documentation, the corners specific for each rate from the DP link clock are:
- LOWSVS_D1 -> 19.2 MHz
- LOWSVS -> 270 MHz - SVS -> 540 MHz (594 MHz in case of DP3) - SVS_L1 -> 594 MHz - NOM -> 810 MHz - NOM_L1 -> 810 MHz - TURBO -> 810 MHz
So fix all tables for each of the four controllers according to the documentation, but since DP0 through DP2 have the same entries in their tables, lets drop the DP1 and DP2 and have all of them share the DP0 table instead. However keep a separate table for the DP3 as it is different for the SVS, compared to the rest of the controllers.
The 19.2 MHz @ LOWSVS_D1 isn't needed as it's not an actual working frequency and the controller will never select it. So remove it.
--- arch/arm64/boot/dts/qcom/hamoa.dtsi | 77 +++++------------------------------- 1 file changed, 12 insertions(+), 65 deletions(-)
arch/arm64/boot/dts/qcom/hamoa.dtsi +12 -65
@@ -5744,18 +5744,18 @@ mdss_dp0_opp_table: opp-table { compatible = "operating-points-v2"; - opp-162000000 { - opp-hz = /bits/ 64 <162000000>; - required-opps = <&rpmhpd_opp_low_svs>; - }; - opp-270000000 { opp-hz = /bits/ 64 <270000000>; - required-opps = <&rpmhpd_opp_svs>; + required-opps = <&rpmhpd_opp_low_svs>; }; opp-540000000 { opp-hz = /bits/ 64 <540000000>; + required-opps = <&rpmhpd_opp_svs>; + }; + + opp-594000000 { + opp-hz = /bits/ 64 <594000000>; required-opps = <&rpmhpd_opp_svs_l1>; };
@@ -5796,7 +5796,7 @@ <&usb_1_ss1_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>, <&usb_1_ss1_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>; - operating-points-v2 = <&mdss_dp1_opp_table>; + operating-points-v2 = <&mdss_dp0_opp_table>; power-domains = <&rpmhpd RPMHPD_MMCX>;
@@ -5829,30 +5829,6 @@ }; }; }; - - mdss_dp1_opp_table: opp-table { - compatible = "operating-points-v2"; - - opp-162000000 { - opp-hz = /bits/ 64 <162000000>; - required-opps = <&rpmhpd_opp_low_svs>; - }; - - opp-270000000 { - opp-hz = /bits/ 64 <270000000>; - required-opps = <&rpmhpd_opp_svs>; - }; - - opp-540000000 { - opp-hz = /bits/ 64 <540000000>; - required-opps = <&rpmhpd_opp_svs_l1>; - }; - - opp-810000000 { - opp-hz = /bits/ 64 <810000000>; - required-opps = <&rpmhpd_opp_nom>; - }; - }; }; mdss_dp2: displayport-controller@ae9a000 {
@@ -5885,7 +5861,7 @@ <&usb_1_ss2_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>, <&usb_1_ss2_qmpphy QMP_USB43DP_DP_VCO_DIV_CLK>; - operating-points-v2 = <&mdss_dp2_opp_table>; + operating-points-v2 = <&mdss_dp0_opp_table>; power-domains = <&rpmhpd RPMHPD_MMCX>;
@@ -5917,30 +5893,6 @@ }; }; }; - - mdss_dp2_opp_table: opp-table { - compatible = "operating-points-v2"; - - opp-162000000 { - opp-hz = /bits/ 64 <162000000>; - required-opps = <&rpmhpd_opp_low_svs>; - }; - - opp-270000000 { - opp-hz = /bits/ 64 <270000000>; - required-opps = <&rpmhpd_opp_svs>; - }; - - opp-540000000 { - opp-hz = /bits/ 64 <540000000>; - required-opps = <&rpmhpd_opp_svs_l1>; - }; - - opp-810000000 { - opp-hz = /bits/ 64 <810000000>; - required-opps = <&rpmhpd_opp_nom>; - }; - }; }; mdss_dp3: displayport-controller@aea0000 {
@@ -6004,19 +5956,14 @@ mdss_dp3_opp_table: opp-table { compatible = "operating-points-v2"; - opp-162000000 { - opp-hz = /bits/ 64 <162000000>; - required-opps = <&rpmhpd_opp_low_svs>; - }; - opp-270000000 { opp-hz = /bits/ 64 <270000000>; - required-opps = <&rpmhpd_opp_svs>; + required-opps = <&rpmhpd_opp_low_svs>; }; - opp-540000000 { - opp-hz = /bits/ 64 <540000000>; - required-opps = <&rpmhpd_opp_svs_l1>; + opp-594000000 { + opp-hz = /bits/ 64 <594000000>; + required-opps = <&rpmhpd_opp_svs>; }; opp-810000000 {
Greg Kroah-Hartman
maintainerPATCH 1544/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Move gpio-line-names to board files
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit 4f5069609ac99894c0632d8b8c4c016f85199de9 upstream.
Move the gpio-line-names properties out of the common mecio1-io.dtsi file and into the specific board dts files.
The pinout originally defined in the common include file belonged to the mecio1r0 (Revision 0) hardware. This is moved 1:1 into the stm32mp151c-mecio1r0.dts file without any modifications.
A large number of GPIO pins are swapped on the mecio1r1 (Revision 1) hardware, so a new, board-specific gpio-line-names mapping is added to stm32mp153c-mecio1r1.dts to reflect those hardware changes.
--- arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts | 64 ++++++++++++++++++++ arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts | 80 +++++++++++++++++++++++++ arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 63 ------------------- 3 files changed, 144 insertions(+), 63 deletions(-)
arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts +64 -0
@@ -96,3 +96,67 @@ assigned-clock-rates = <125000000>; /* Clock PLL3 to 625Mhz in tf-a. */ st,eth-clk-sel; }; + +&gpiod { + gpio-line-names = "", "", "", "", + "", "", "", "", + "", "", "", "", + "STP_RESETN", "STP_ENABLEN", "HPOUT0", "HPOUT0_ALERTN"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog_d_mecsbc>; +}; + +&gpioe { + gpio-line-names = "HPOUT0_RESETN", "HPOUT1", "HPOUT1_ALERTN", "", + "", "", "HPOUT1_RESETN", + "LPOUT0", "LPOUT0_ALERTN", "LPOUT0_RESETN", + "LPOUT1", "LPOUT1_ALERTN", "LPOUT1_RESETN", + "LPOUT2", "LPOUT2_ALERTN", "LPOUT2_RESETN"; +}; + +&gpiof { + gpio-line-names = "LPOUT3", "LPOUT3_ALERTN", "LPOUT3_RESETN", + "LPOUT4", "LPOUT4_ALERTN", "LPOUT4_RESETN", + "", "", + "", "", "", "", + "", "", "", ""; +}; + +&gpiog { + gpio-line-names = "LPOUT5", "LPOUT5_ALERTN", "", "LPOUT5_RESETN", + "", "", "", "", + "", "", "", "", + "", "", "", ""; +}; + +&gpioh { + gpio-line-names = "", "", "", "", + "", "", "", "", + "GPIO0_RESETN", "", "", "", + "", "", "", ""; +}; + +&gpioi { + gpio-line-names = "", "", "", "", + "", "", "", "", + "HPDCM0_SLEEPN", "HPDCM1_SLEEPN", "GPIO1_RESETN", "", + "", "", "", ""; +}; + +&gpioj { + gpio-line-names = "HSIN10", "HSIN11", "HSIN12", "HSIN13", + "HSIN14", "HSIN15", "", "", + "", "", "", "", + "", "RTD_RESETN", "", ""; +}; + +&gpiok { + gpio-line-names = "", "", "HSIN0", "HSIN1", + "HSIN2", "HSIN3", "HSIN4", "HSIN5"; +}; + +&gpioz { + gpio-line-names = "", "", "", "HSIN6", + "HSIN7", "HSIN8", "HSIN9", ""; +}; +
arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts +80 -0
86 lines not on this page · raw message
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +0 -63
69 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 1545/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Fix expander gpio line typo
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit dfb93c4acce8ad9c4f573128b2cf7ddb936e0de7 upstream.
Fix a copy-paste error in the GPIO line names for the TCA6416 expander (gpio@20).
The common mecio1-io include file was originally defined using the mecio1r1 (Revision 1) hardware layout, but incorrectly labeled pin 13 as "HSIN9_BIAS" instead of the actual "HSIN7_BIAS" present in the schematics.
--- arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +1 -1
@@ -186,7 +186,7 @@ #gpio-cells = <2>; gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS", "", "", "HSIN_VREF0_LVL", "HSIN_VREF1_LVL", - "HSIN4_BIAS", "HSIN5_BIAS", "HSIN6_BIAS", "HSIN9_BIAS", + "HSIN4_BIAS", "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS", "", "", "", ""; };
Greg Kroah-Hartman
maintainerPATCH 1546/2077 ARM: dts: stm32: stm32mp15x-mecio1-io: Move expander gpio-line-names to board files
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jander <[email protected]>
commit a0d6c2a06fffff47bcca4d5bfdab4cc428a315fc upstream.
Move the gpio-line-names properties for the I2C GPIO expanders (gpio0 and gpio1) out of the common mecio1-io.dtsi file and into the specific board dts files.
The layout originally defined in the common include file belonged to the mecio1r1 (Revision 1) hardware. This layout is moved 1:1 into the stm32mp153c-mecio1r1.dts file.
The mecio1r0 (Revision 0) hardware utilizes a completely different pinout for these expanders. A new, accurate mapping reflecting the Revision 0 schematics is added to stm32mp151c-mecio1r0.dts.
--- arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts | 14 ++++++++++++++ arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts | 14 ++++++++++++++ arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi | 8 -------- 3 files changed, 28 insertions(+), 8 deletions(-)
arch/arm/boot/dts/st/stm32mp151c-mecio1r0.dts +14 -0
@@ -97,6 +97,20 @@ st,eth-clk-sel; }; +&gpio0 { + gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS", + "HSIN4_BIAS", "", "STP_VREF0_LVL", "HSIN_VREF0_LVL", + "STP0_FB_BIAS", "STP1_FB_BIAS", "STP2_FB_BIAS", "STP3_FB_BIAS", + "", "", "", ""; +}; + +&gpio1 { + gpio-line-names = "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS", "HSIN8_BIAS", + "HSIN9_BIAS", "", "STP_VREF1_LVL", "HSIN_VREF1_LVL", + "STP4_FB_BIAS", "STP5_FB_BIAS", "STP6_FB_BIAS", "", + "", "", "LSIN8_BIAS", "LSIN9_BIAS"; +}; + &gpiod { gpio-line-names = "", "", "", "", "", "", "", "",
arch/arm/boot/dts/st/stm32mp153c-mecio1r1.dts +14 -0
@@ -90,6 +90,20 @@ clock-frequency = <24000000>; }; +&gpio0 { + gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS", + "", "", "HSIN_VREF0_LVL", "HSIN_VREF1_LVL", + "HSIN4_BIAS", "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS", + "", "", "", ""; +}; + +&gpio1 { + gpio-line-names = "HSIN8_BIAS", "HSIN9_BIAS", "HSIN10_BIAS", "HSIN11_BIAS", + "", "", "HSIN_VREF2_LVL", "HSIN_VREF3_LVL", + "HSIN12_BIAS", "HSIN13_BIAS", "HSIN14_BIAS", "HSIN15_BIAS", + "", "", "LSIN8_BIAS", "LSIN9_BIAS"; +}; + &gpioa { gpio-line-names = "", "", "", "", "", "", "", "",
arch/arm/boot/dts/st/stm32mp15x-mecio1-io.dtsi +0 -8
@@ -184,10 +184,6 @@ reg = <0x20>; gpio-controller; #gpio-cells = <2>; - gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS", - "", "", "HSIN_VREF0_LVL", "HSIN_VREF1_LVL", - "HSIN4_BIAS", "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS", - "", "", "", ""; }; gpio1: gpio@21 {
@@ -195,10 +191,6 @@ reg = <0x21>; gpio-controller; #gpio-cells = <2>; - gpio-line-names = "HSIN8_BIAS", "HSIN9_BIAS", "HSIN10_BIAS", "HSIN11_BIAS", - "", "", "HSIN_VREF2_LVL", "HSIN_VREF3_LVL", - "HSIN12_BIAS", "HSIN13_BIAS", "HSIN14_BIAS", "HSIN15_BIAS", - "", "", "LSIN8_BIAS", "LSIN9_BIAS"; }; };
Greg Kroah-Hartman
maintainerPATCH 1547/2077 LoongArch: KVM: Validate irqchip index in irqfd routing
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yanfei Xu <[email protected]>
commit 3474037904c20ff915e3ebab0ab5c1e41bbe549e upstream.
Sashiko reported that the irqchip index is not validated for LoongArch. Add validation and reject out-of-range irqchip indexes to avoid indexing past the routing table's chip array.
--- arch/loongarch/kvm/irqfd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/loongarch/kvm/irqfd.c +2 -1
@@ -51,7 +51,8 @@ int kvm_set_routing_entry(struct kvm *kv e->irqchip.irqchip = ue->u.irqchip.irqchip; e->irqchip.pin = ue->u.irqchip.pin; -if (e->irqchip.pin >=KVM_IRQCHIP_NUM_PINS ) +if (e->irqchip.pin >=KVM_IRQCHIP_NUM_PINS || + e->irqchip.irqchip >=KVM_NR_IRQCHIPS )return -EINVAL ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 1548/2077 LoongArch: KVM: Check irq validity in kvm_vcpu_ioctl_interrupt()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bibo Mao <[email protected]>
commit 09b318ab77b7a4fc9987fd98d1525fc55ddc2617 upstream.
Function kvm_vcpu_ioctl_interrupt() can be called from userspace, here add irq validility cheking in kvm_vcpu_ioctl_interrupt().
--- arch/loongarch/kvm/vcpu.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/loongarch/kvm/vcpu.c +4 -0
@@ -1487,6 +1487,10 @@ void kvm_lose_fpu(struct kvm_vcpu *vcpu)int kvm_vcpu_ioctl_interrupt (struct kvm_vcpu *vcpu,struct kvm_interrupt *irq) {int intr = (int )irq->irq; +unsigned int vector =abs (intr); + +if (vector >=EXCCODE_INT_NUM ) +return -EINVAL ;if (intr >0 )kvm_queue_irq (vcpu, intr);
Greg Kroah-Hartman
maintainerPATCH 1549/2077 LoongArch: KVM: Check the return values for put_user()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Ma <[email protected]>
commit fb89e0fe2dc4246c86ad0eb0fa2b7cb2f8ba9728 upstream.
put_user() may return -EFAULT, so, when the user space address is invalid, the caller should return -EFAULT.
--- arch/loongarch/kvm/vcpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/loongarch/kvm/vcpu.c +2 -1
@@ -1108,7 +1108,8 @@ static int kvm_loongarch_cpucfg_get_attrreturn -ENXIO ; } -put_user (val, uaddr); +if (put_user (val, uaddr)) +return -EFAULT ;return ret; }
Greg Kroah-Hartman
maintainerPATCH 1550/2077 LoongArch: KVM: Fix FPU register width with user access API
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bibo Mao <[email protected]>
commit f4caaac76379daf4a617d9134b6087fb2636fb31 upstream.
At the beginning, only 64 bit FPU is supported. With FPU register get interface, 64 bit FPU data is copied to user space, the same with FPU register set API. However with LSX and LASX supported in later, there should be FPU data copied with bigger width. So here fixes this issue, copy the whole 256 bit FPU data from/to user space.
--- arch/loongarch/kvm/vcpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/loongarch/kvm/vcpu.c +2 -2
@@ -1313,7 +1313,7 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct k fpu->fcc = vcpu->arch.fpu.fcc; fpu->fcsr = vcpu->arch.fpu.fcsr;for (i =0 ; i <NUM_FPU_REGS ; i++) -memcpy (&fpu->fpr[i], &vcpu->arch.fpu.fpr[i],FPU_REG_WIDTH /64 ); +memcpy (&fpu->fpr[i], &vcpu->arch.fpu.fpr[i],sizeof (union fpureg ));return 0 ; }
@@ -1325,7 +1325,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct k vcpu->arch.fpu.fcc = fpu->fcc; vcpu->arch.fpu.fcsr = fpu->fcsr;for (i =0 ; i <NUM_FPU_REGS ; i++) -memcpy (&vcpu->arch.fpu.fpr[i], &fpu->fpr[i],FPU_REG_WIDTH /64 ); +memcpy (&vcpu->arch.fpu.fpr[i], &fpu->fpr[i],sizeof (union fpureg ));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 1551/2077 LoongArch: KVM: Return full old CSR value from kvm_emu_xchg_csr()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Ma <[email protected]>
commit ebd50de14f1a06b7e0206083904bcc62b9ba65be upstream.
The LoongArch CSRXCHG instruction returns the full old CSR value in rd after applying the masked update. kvm_emu_xchg_csr() currently masks the saved value before returning it to the guest, so rd receives only the bits selected by the write mask.
That breaks the architectural behavior and makes a zero mask return 0 instead of the previous CSR value. So, keep the masked CSR update, but return the unmodified old CSR value.
--- arch/loongarch/kvm/exit.c | 1 - 1 file changed, 1 deletion(-)
arch/loongarch/kvm/exit.c +0 -1
@@ -103,7 +103,6 @@ static unsigned long kvm_emu_xchg_csr(st old =kvm_read_sw_gcsr (csr, csrid); val = (old & ~csr_mask) | (val & csr_mask);kvm_write_sw_gcsr (csr, csrid, val); - old = old & csr_mask; }else pr_warn_once ("Unsupported csrxchg 0x%x with pc %lx\n" , csrid, vcpu->arch.pc);
Greg Kroah-Hartman
maintainerPATCH 1552/2077 KVM: s390: vsie: Fix allocation of struct vsie_rmap
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
commit 505fcce0c64957f475f9b11fb1403821b7f33e7e upstream.
The allocation size for struct vsie_rmap in kvm_s390_mmu_cache_topup() was wrong due to a copy-paste error.
Fix it by using the type name.
Message-ID: <[email protected]>
--- arch/s390/kvm/dat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/dat.c +1 -1
@@ -45,7 +45,7 @@ int kvm_s390_mmu_cache_topup(struct kvm_s390_mmu_cache *mc) mc->pts[mc->n_pts] = o; }for ( ; mc->n_rmaps <KVM_S390_MMU_CACHE_N_RMAPS ; mc->n_rmaps++) { - o =kzalloc_obj (*mc->rmaps[0 ],GFP_KERNEL_ACCOUNT ); + o = kzalloc_obj(struct vsie_rmap, GFP_KERNEL_ACCOUNT);if (!o)return -ENOMEM ; mc->rmaps[mc->n_rmaps] = o;
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1553/2077 KVM: s390: vsie: Add missing radix_tree_preload() in _gaccess_shadow_fault()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
commit 668e70cc545e2659f3c4adad20a0883533042473 upstream.
Add missing radix_tree_preload() in _gaccess_shadow_fault() to guarantee forward progress. The core of _gaccess_shadow_fault() has been split into ___gaccess_shadow_fault() in order to simplify locking.
Message-ID: <[email protected]>
--- arch/s390/kvm/gaccess.c | 59 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 23 deletions(-)
arch/s390/kvm/gaccess.c +36 -23
@@ -1582,35 +1582,48 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,return _do_shadow_crste (sg, saddr, host, table, entries +LEVEL_MEM , w->p); } -static inline int _gaccess_shadow_fault (struct kvm_vcpu *vcpu,struct gmap *sg,gpa_t saddr, -unsigned long seq,struct pgtwalk *walk) +static inline int ___gaccess_shadow_fault (struct kvm_vcpu *vcpu,struct gmap *sg,gpa_t saddr, +unsigned long seq,struct pgtwalk *walk) {struct gmap *parent;int rc; +if (kvm_s390_array_needs_retry_safe (vcpu->kvm, seq, walk->raw_entries)) +return -EAGAIN ; + parent =READ_ONCE (sg->parent); +if (!parent) +return -EAGAIN ; + scoped_guard(spinlock, &parent->children_lock) { +if (READ_ONCE (sg->parent) != parent) +return -EAGAIN ; + sg->invalidated = false; + rc =_gaccess_do_shadow (vcpu->arch.mc, sg, saddr, walk); + } +if (!rc) +kvm_s390_release_faultin_array (vcpu->kvm, walk->raw_entries, false); +return rc; +} + +static inline int _gaccess_shadow_fault (struct kvm_vcpu *vcpu,struct gmap *sg,gpa_t saddr, +unsigned long seq,struct pgtwalk *walk) +{ +int rc; +if (kvm_s390_array_needs_retry_unsafe (vcpu->kvm, seq, walk->raw_entries))return -EAGAIN ; -again: - rc =kvm_s390_mmu_cache_topup (vcpu->arch.mc); -if (rc) -return rc; - scoped_guard(read_lock, &vcpu->kvm->mmu_lock) { -if (kvm_s390_array_needs_retry_safe (vcpu->kvm, seq, walk->raw_entries)) -return -EAGAIN ; - parent =READ_ONCE (sg->parent); -if (!parent) -return -EAGAIN ; - scoped_guard(spinlock, &parent->children_lock) { -if (READ_ONCE (sg->parent) != parent) -return -EAGAIN ; - sg->invalidated = false; - rc =_gaccess_do_shadow (vcpu->arch.mc, sg, saddr, walk); - } -if (rc == -ENOMEM ) - goto again; -if (!rc) -kvm_s390_release_faultin_array (vcpu->kvm, walk->raw_entries, false); - } + +do { + rc =kvm_s390_mmu_cache_topup (vcpu->arch.mc); +if (rc) +return rc; + rc =radix_tree_preload (GFP_KERNEL ); +if (rc) +return rc; +scoped_guard (read_lock, &vcpu->kvm->mmu_lock) + rc = ___gaccess_shadow_fault(vcpu, sg, saddr, seq, walk); +radix_tree_preload_end (); + }while (rc == -ENOMEM ); +return rc; }
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1554/2077 KVM: s390: Silence potential warnings in _gmap_crstep_xchg_atomic()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
commit f79413b2dde10829a1b526543e725dd5c1847e9a upstream.
While dat_crstep_xchg_atomic() is marked as __must_check, in this particular case the return value should be ignored.
Silence potential compiler warnings with a pointless check, and add a comment to explain the situation.
Message-ID: <[email protected]>
--- arch/s390/kvm/gmap.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.h +10 -1
@@ -279,7 +279,16 @@ static inline bool __must_check _gmap_crstep_xchg_atomic(struct gmap *gmap, uniogmap_handle_vsie_unshadow_event (gmap, gfn); else_gmap_handle_vsie_unshadow_event (gmap ,gfn ); -dat_crstep_xchg_atomic (crstep, oldcrste, newcrste, gfn, gmap->asce); +if (!dat_crstep_xchg_atomic (crstep, oldcrste, newcrste, gfn, gmap->asce)) +return false; +/* +* Return false even if the swap was successful, as it only +* indicates that the best effort clearing of the vsie_notif +* bit was successful. The caller will have to try again +* regardless, since the desired value has not been set. +* This pointless check is needed to silence a potential +* __must_check warning. +*/ return false; }if (!oldcrste.s.fc1.d && newcrste.s.fc1.d && !newcrste.s.fc1.s)
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1555/2077 KVM: s390: vsie: Use mmu cache to allocate rmap
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
commit abeb7eb57f1671d9185ddf11236c784f07bdb928 upstream.
Use kvm_s390_mmu_cache_alloc_rmap() to allocate the rmap in gmap_insert_rmap(), instead of a normal kzalloc_obj() with GFP_ATOMIC.
This guarantees forward progress.
Message-ID: <[email protected]>
--- arch/s390/kvm/gaccess.c | 16 ++++++++-------- arch/s390/kvm/gmap.c | 7 ++++--- arch/s390/kvm/gmap.h | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-)
arch/s390/kvm/gaccess.c +8 -8
@@ -1419,8 +1419,8 @@ static int walk_guest_tables(struct gmap *sg, unsigned long saddr, struct pgtwalreturn kvm_s390_get_guest_page (kvm, entries +LEVEL_MEM , table.pte.pfra, wr); } -static int _do_shadow_pte (struct gmap *sg,gpa_t raddr,union pte *ptep_h,union pte *ptep, -struct guest_fault *f,bool p) +static int _do_shadow_pte (struct kvm_s390_mmu_cache *mc,struct gmap *sg,gpa_t raddr, +union pte *ptep_h,union pte *ptep,struct guest_fault *f,bool p) {union pgste pgste;union pte newpte;
@@ -1430,7 +1430,7 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, unionlockdep_assert_held (&sg->parent->children_lock);scoped_guard (spinlock, &sg->host_to_rmap_lock) - rc = gmap_insert_rmap(sg, f->gfn, gpa_to_gfn(raddr), TABLE_TYPE_PAGE_TABLE); + rc = gmap_insert_rmap(mc, sg, f->gfn, gpa_to_gfn(raddr), TABLE_TYPE_PAGE_TABLE);if (rc)return rc;
@@ -1462,8 +1462,8 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, unionreturn 0 ; } -static int _do_shadow_crste (struct gmap *sg,gpa_t raddr,union crste *host,union crste *table, -struct guest_fault *f,bool p) +static int _do_shadow_crste (struct kvm_s390_mmu_cache *mc,struct gmap *sg,gpa_t raddr, +union crste *host,union crste *table,struct guest_fault *f,bool p) {union crste newcrste, oldcrste;unsigned long mask;
@@ -1476,7 +1476,7 @@ static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, uni mask =is_pmd (*table) ? _SEGMENT_FR_MASK : _REGION3_FR_MASK; r_gfn =gpa_to_gfn (raddr) & mask;scoped_guard (spinlock, &sg->host_to_rmap_lock) - rc = gmap_insert_rmap(sg, f->gfn & mask, r_gfn, host->h.tt); + rc = gmap_insert_rmap(mc, sg, f->gfn & mask, r_gfn, host->h.tt);if (rc)return rc;
@@ -1578,8 +1578,8 @@ static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,if (KVM_BUG_ON (l >TABLE_TYPE_REGION3 , sg->kvm))return -EFAULT ;if (l ==TABLE_TYPE_PAGE_TABLE ) -return _do_shadow_pte (sg, saddr, ptep_h, ptep, entries +LEVEL_MEM , w->p); -return _do_shadow_crste (sg, saddr, host, table, entries +LEVEL_MEM , w->p); +return _do_shadow_pte (mc, sg, saddr, ptep_h, ptep, entries +LEVEL_MEM , w->p); +return _do_shadow_crste (mc, sg, saddr, host, table, entries +LEVEL_MEM , w->p); } static inline int ___gaccess_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg, gpa_t saddr,
arch/s390/kvm/gmap.c +4 -3
@@ -1000,7 +1000,8 @@ int gmap_pv_destroy_range(struct gmap *gmap, gfn_t start, gfn_t end, bool interrreturn 0 ; } -int gmap_insert_rmap (struct gmap *sg,gfn_t p_gfn,gfn_t r_gfn,int level) +int gmap_insert_rmap (struct kvm_s390_mmu_cache *mc,struct gmap *sg,gfn_t p_gfn, +gfn_t r_gfn,int level) { struct vsie_rmap *rmap __free(kvfree) = NULL;struct vsie_rmap *temp;
@@ -1010,7 +1011,7 @@ int gmap_insert_rmap(struct gmap *sg, gfn_t p_gfn, gfn_t r_gfn, int level)KVM_BUG_ON (!is_shadow (sg), sg->kvm);lockdep_assert_held (&sg->host_to_rmap_lock); - rmap =kzalloc_obj (*rmap,GFP_ATOMIC ); + rmap =kvm_s390_mmu_cache_alloc_rmap (mc);if (!rmap)return -ENOMEM ;
@@ -1057,7 +1058,7 @@ int gmap_protect_rmap(struct kvm_s390_mmu_cache *mc, struct gmap *sg, gfn_t p_gfif (level <=TABLE_TYPE_REGION1 ) { bitmask =-1UL << (8 +11 * level);scoped_guard (spinlock, &sg->host_to_rmap_lock) - rc = gmap_insert_rmap(sg, p_gfn, r_gfn & bitmask, level); + rc = gmap_insert_rmap(mc, sg, p_gfn, r_gfn & bitmask, level); }if (rc)return rc;
arch/s390/kvm/gmap.h +2 -1
@@ -100,7 +100,8 @@ int gmap_ucas_map(struct gmap *gmap, gfn_t p_gfn, gfn_t c_gfn, unsigned long couvoid gmap_ucas_unmap (struct gmap *gmap,gfn_t c_gfn,unsigned long count);int gmap_enable_skeys (struct gmap *gmap);int gmap_pv_destroy_range (struct gmap *gmap,gfn_t start,gfn_t end,bool interruptible); -int gmap_insert_rmap (struct gmap *sg,gfn_t p_gfn,gfn_t r_gfn,int level); +int gmap_insert_rmap (struct kvm_s390_mmu_cache *mc,struct gmap *sg,gfn_t p_gfn, +gfn_t r_gfn,int level);int gmap_protect_rmap (struct kvm_s390_mmu_cache *mc,struct gmap *sg,gfn_t p_gfn,gfn_t r_gfn,kvm_pfn_t pfn,int level,bool wr);void gmap_set_cmma_all_dirty (struct gmap *gmap);
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1556/2077 KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit c7dda3d0f869dc97223448a06c9a2e5235928e48 upstream.
kvm_s390_get_cmma_bits() allocates its output buffer with vmalloc(), which does not zero the returned pages:
values = vmalloc(args->count);
In the non-peek (migration) path, dat_get_cmma() reports a byte count spanning from the first to the last dirty page, but __dat_get_cmma_pte() writes values[gfn - start] only for pages whose CMMA dirty bit is set. The walk uses DAT_WALK_IGN_HOLES, so clean and unmapped pages that lie between two dirty pages within the reported span are visited but never store their byte. Those gaps (up to KVM_S390_MAX_BIT_DISTANCE pages each) stay uninitialized yet fall inside [0, count) and are copied out by copy_to_user(), disclosing stale kernel memory to user space.
Before the switch to the new gmap implementation the buffer was fully populated for every gfn in the span, so no uninitialized bytes were exposed; the dirty-only walk introduced the leak.
Use vzalloc() so the gaps read back as zero.
Message-ID: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +1 -1
@@ -2252,7 +2252,7 @@ static int kvm_s390_get_cmma_bits(structreturn 0 ; } - values =vmalloc (args->count); + values =vzalloc (args->count);if (!values)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 1557/2077 KVM: s390: Fix unlikely race in try_get_locked_pte()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudio Imbrenda <[email protected]>
commit 5670b7f927f8d98685f3f5873dbf9f8d7a5a63f3 upstream.
Fix an unlikely race in try_get_locked_pte(), which could have happened if puds or pmds get unmapped between the p?dp_get() and p?d_offset() functions.
Message-ID: <[email protected]>
--- arch/s390/mm/gmap_helpers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/mm/gmap_helpers.c +3 -3
@@ -51,15 +51,15 @@ pte_t *try_get_locked_pte(struct mm_struct *mm, unsigned long vmaddr, spinlock_t pgd =pgdp_get (pgdp);if (pgd_none (pgd) || !pgd_present (pgd))return NULL ; - p4dp =p4d_offset (pgdp, vmaddr); + p4dp =p4d_offset_lockless (pgdp, pgd, vmaddr); p4d =p4dp_get (p4dp);if (p4d_none (p4d) || !p4d_present (p4d))return NULL ; - pudp =pud_offset (p4dp, vmaddr); + pudp =pud_offset_lockless (p4dp, p4d, vmaddr); pud =pudp_get (pudp);if (pud_none (pud) ||pud_leaf (pud) || !pud_present (pud))return NULL ; - pmdp =pmd_offset (pudp, vmaddr); + pmdp =pmd_offset_lockless (pudp, pud, vmaddr); pmd =pmdp_get_lockless (pmdp);if (pmd_none (pmd) ||pmd_leaf (pmd) || !pmd_present (pmd))return NULL ;
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1558/2077 powerpc/pseries/Kconfig: Enable CONFIG_VPA_PMU to be used with KVM
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <[email protected]>
commit fe179677b6dcb4b658586038a811f87265e97777 upstream.
Currently, CONFIG_VPA_PMU is not enabled by default, and consequently cannot be used for KVM guests at all, unless explicitly enabled on host kernel.
Mark CONFIG_VPA_PMU as "default m" to ensure it is available when KVM is being used.
--- arch/powerpc/platforms/pseries/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/pseries/Kconfig +1 -0
@@ -154,6 +154,7 @@ config HV_PERF_CTRS config VPA_PMU tristate "VPA PMU events" depends on KVM_BOOK3S_64_HV && HV_PERF_CTRS + default m help Enable access to the VPA PMU counters via perf. This enables code that support measurement for KVM on PowerVM(KoP) feature.
Greg Kroah-Hartman
maintainerPATCH 1559/2077 KVM: s390: pci: Fix GISC refcount leak on AIF enable failure
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 7b69729046a4c58f4cb457184e5ac4aaa179bff4 upstream.
kvm_s390_gisc_register() registers the guest ISC before pinning the guest interrupt forwarding pages and allocating the AISB bit. If any of the later setup steps fails, the function unwinds the pinned pages and other local state, but does not unregister the GISC reference. Add the missing kvm_s390_gisc_unregister() to the error unwind path.
Message-ID: <[email protected]>
--- arch/s390/kvm/pci.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/kvm/pci.c +1 -0
@@ -328,6 +328,7 @@ unpin2: unpin1:unpin_user_page (aibv_page); out: +kvm_s390_gisc_unregister (kvm, fib->fmt0.isc);return rc; }
Greg Kroah-Hartman
maintainerPATCH 1560/2077 KVM: arm64: vgic: Check the interrupt is still ours before migrating it
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
commit 0074b82cdfcb5fd13710a0ac308ade68ac6f6fbe upstream.
vgic_prune_ap_list() drops both ap_list_lock and irq_lock while migrating an interrupt to another vCPU. After reacquiring the locks it only checks that the affinity is unchanged (target_vcpu == vgic_target_oracle(irq)) before moving the interrupt, which assumes that an interrupt whose affinity is preserved is still queued on this vCPU's ap_list.
That assumption no longer holds if the interrupt is taken off the ap_list while the locks are dropped. vgic_flush_pending_lpis() removes the interrupt from the list and sets irq->vcpu to NULL, but leaves enabled/pending/target_vcpu untouched. As the interrupt is still enabled and pending, vgic_target_oracle() returns the same target_vcpu, so the affinity check passes and list_del() is run a second time on an entry that has already been removed.
Also check that the interrupt is still assigned to this vCPU (irq->vcpu == vcpu) before moving it.
--- arch/arm64/kvm/vgic/vgic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm64/kvm/vgic/vgic.c +6 -5
@@ -818,15 +818,16 @@ retry:raw_spin_lock (&irq->irq_lock);/* -* If the affinity has been preserved, move the -* interrupt around. Otherwise, it means things have -* changed while the interrupt was unlocked, and we -* need to replay this. +* If the interrupt is still ours and its affinity has +* been preserved, move it around. Otherwise, it means +* things have changed while the interrupt was unlocked +* (it may even have been taken off the list with its +* affinity left untouched), and we need to replay this. * * In all cases, we cannot trust the list not to have * changed, so we restart from the beginning. */ -if (target_vcpu ==vgic_target_oracle (irq)) { +if (irq->vcpu == vcpu && target_vcpu ==vgic_target_oracle (irq)) {struct vgic_cpu *new_cpu = &target_vcpu->arch.vgic_cpu;list_del (&irq->ap_list);
Greg Kroah-Hartman
maintainerPATCH 1561/2077 KVM: arm64: vgic: Handle race between interrupt affinity change and LPI disabling
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 7258770e5814f15e8308ebda82ac9acf6964ba8e upstream.
Hyunwoo Kim reports some really bad races should the following situation occur:
- LPI-I is pending in vcpu-B's AP list
- vcpu-A writes to vcpu-B's RD to disable its LPIs
- vcpu-C moves I from B to C
If the last two race nicely enough, vgic_prune_ap_list() can drop the irq and AP list locks, reacquire them, and in the interval the irq has been freed. UAF follows.
The fix is two-fold:
- Before dropping the irq and ap_list locks, take a reference on the irq
- Do not try to handle migration of the pending bit: there is no expectation that this state is retained, as per the architecture
With that, we're sure that the interrupt is still around, and we safely remove it from the AP list as it has no target at this stage (unless another interrupt fires, but that's another story).
--- arch/arm64/kvm/vgic/vgic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic.c +8 -1
@@ -204,6 +204,7 @@ void vgic_flush_pending_lpis(struct kvm_list_for_each_entry_safe (irq, tmp, &vgic_cpu->ap_list_head, ap_list) {if (irq_is_lpi (vcpu->kvm, irq->intid)) {raw_spin_lock (&irq->irq_lock); + irq->pending_latch = false;list_del (&irq->ap_list); irq->vcpu =NULL ;raw_spin_unlock (&irq->irq_lock);
@@ -795,7 +796,11 @@ retry:continue ; } -/* This interrupt looks like it has to be migrated. */ +/* +* This interrupt looks like it has to be migrated, +* make sure it is kept alive while locks are dropped. +*/ +vgic_get_irq_ref (irq);raw_spin_unlock (&irq->irq_lock);raw_spin_unlock (&vgic_cpu->ap_list_lock);
@@ -840,6 +845,8 @@ retry:raw_spin_unlock (&vcpuB->arch.vgic_cpu.ap_list_lock);raw_spin_unlock (&vcpuA->arch.vgic_cpu.ap_list_lock); + deleted_lpis |=vgic_put_irq_norelease (vcpu->kvm, irq); +if (target_vcpu_needs_kick) {kvm_make_request (KVM_REQ_IRQ_PENDING , target_vcpu);kvm_vcpu_kick (target_vcpu);
Greg Kroah-Hartman
maintainerPATCH 1562/2077 KVM: nVMX: Move vTPR vs. TPR Threshold consistency check into "normal" checks
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit ebdac7554abb347ca4197be241116842161acd9b upstream.
Move the off-by-default consistency check for vmcs12.tpr_threshold vs. the virtual APIC vTPR into the "normal" controls checks, as waiting until KVM has loaded some amount of state is unnecessary and actively dangerous. Specifically, failure to unwind vmcs01.GUEST_CR3 to KVM's value when EPT is disabled results in KVM running L1 with an L1-controlled CR3, not with KVM's CR3!
Alternatively, KVM could simply reset the MMU to force a reload of vmcs01.GUEST_CR3, but the _only_ reason the check was shoved into a "late" flow was to wait until the vmcs12 pages were retrieved. Rather than build up more crusty code, simply access vTPR using a regular guest memory access (performance isn't a concern). To circumvent the restrictions that led to KVM deferring nested_get_vmcs12_pages(), (a) use a VM-scoped API to read guest memory so that it always hits non-SMM memslots (for RSM), and (b) skip the check (since its off-by-default anyways) when the vCPU doesn't want to run, i.e. when userspace is restoring/stuffing state.
If reading guest memory fails, simply skip the consistency check, as KVM's de facto ABI is that VMX instruction accesses to non-existent memory get PCI Bus Error semantics, where reads return 0xFFs. And if vTPR=0xFF, then the vTPR is guaranteed to be greater than or equal to TPR_THRESHOLD.
--- arch/x86/kvm/vmx/nested.c | 66 ++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 37 deletions(-)
arch/x86/kvm/vmx/nested.c +29 -37
@@ -553,6 +553,9 @@ static int nested_vmx_check_msr_bitmap_cstatic int nested_vmx_check_tpr_shadow_controls (struct kvm_vcpu *vcpu,struct vmcs12 *vmcs12) { +gpa_t vtpr_gpa = vmcs12->virtual_apic_page_addr +APIC_TASKPRI ; +u32 vtpr; +if (!nested_cpu_has (vmcs12,CPU_BASED_TPR_SHADOW ))return 0 ;
@@ -562,6 +565,32 @@ static int nested_vmx_check_tpr_shadow_cif (CC (!nested_cpu_has_vid (vmcs12) && vmcs12->tpr_threshold >>4 ))return -EINVAL ; +/* +* Do the illegal vTPR vs. TPR Threshold consistency check if and only +* if KVM is configured to WARN on missed consistency checks, otherwise +* it's a waste of time. KVM needs to rely on hardware to fully detect +* an illegal combination due to the vTPR being writable by L1 at all +* times (it's an in-memory value, not a VMCS field). I.e. even if the +* check passes now, it might fail at the actual VM-Enter. +* +* If reading guest memory fails, skip the check as KVM's de facto ABI +* for VMX instruction accesses to non-existent memory is to provide +* PCI Bus Error semantics (reads return 0xFFs), in which case the vTPR +* is guaranteed to greater than or equal to the threshold. +* +* Note! Deliberately use the VM-scoped API when reading guest memory, +* to ensure the read doesn't hit SMRAM when restoring L2 state on RSM, +* and only perform the check when in KVM_RUN, to avoid a false failure +* if userspace hasn't yet configured memslots during state restore. +*/ +if (warn_on_missed_cc && vcpu->wants_to_run && +nested_cpu_has (vmcs12,CPU_BASED_TPR_SHADOW ) && + !nested_cpu_has_vid (vmcs12) && + !nested_cpu_has2 (vmcs12,SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ) && + !kvm_read_guest (vcpu->kvm, vtpr_gpa, &vtpr,sizeof (vtpr)) && +CC ((vmcs12->tpr_threshold &GENMASK (3 ,0 )) > ((vtpr >>4 ) &GENMASK (3 ,0 )))) +return -EINVAL ; +return 0 ; }
@@ -3085,38 +3114,6 @@ static int nested_vmx_check_controls(strreturn 0 ; } -static int nested_vmx_check_controls_late (struct kvm_vcpu *vcpu, -struct vmcs12 *vmcs12) -{ -void *vapic =to_vmx (vcpu)->nested.virtual_apic_map.hva; -u32 vtpr = vapic ? (*(u32 *)(vapic +APIC_TASKPRI )) >>4 :0 ; - -/* -* Don't bother with the consistency checks if KVM isn't configured to -* WARN on missed consistency checks, as KVM needs to rely on hardware -* to fully detect an illegal vTPR vs. TRP Threshold combination due to -* the vTPR being writable by L1 at all times (it's an in-memory value, -* not a VMCS field). I.e. even if the check passes now, it might fail -* at the actual VM-Enter. -* -* Keying off the module param also allows treating an invalid vAPIC -* mapping as a consistency check failure without increasing the risk -* of breaking a "real" VM. -*/ -if (!warn_on_missed_cc) -return 0 ; - -if ((exec_controls_get (to_vmx (vcpu)) &CPU_BASED_TPR_SHADOW ) && -nested_cpu_has (vmcs12,CPU_BASED_TPR_SHADOW ) && - !nested_cpu_has_vid (vmcs12) && - !nested_cpu_has2 (vmcs12,SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ) && - (CC (!vapic) || -CC ((vmcs12->tpr_threshold &GENMASK (3 ,0 )) > (vtpr &GENMASK (3 ,0 ))))) -return -EINVAL ; - -return 0 ; -} -static int nested_vmx_check_address_space_size (struct kvm_vcpu *vcpu,struct vmcs12 *vmcs12) {
@@ -3666,11 +3663,6 @@ enum nvmx_vmentry_status nested_vmx_entereturn NVMX_VMENTRY_KVM_INTERNAL_ERROR ; } -if (nested_vmx_check_controls_late (vcpu, vmcs12)) { -vmx_switch_vmcs (vcpu, &vmx->vmcs01); -return NVMX_VMENTRY_VMFAIL ; - } -if (nested_vmx_check_guest_state (vcpu, vmcs12, &entry_failure_code)) { exit_reason.basic =EXIT_REASON_INVALID_STATE ;
Greg Kroah-Hartman
maintainerPATCH 1563/2077 KVM: s390: pci: Fix handling of AIF enable without AISB
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Rosato <[email protected]>
commit 3e3aa6da87d30a0064a17b836685cd43c90a3572 upstream.
When a guest seeks to register IRQs without a summary bit specified, ensure that the associated GAITE then stores 0 for the guest AISB location instead of virt_to_phys(page_address(NULL)).
--- arch/s390/kvm/pci.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/s390/kvm/pci.c +8 -3
@@ -300,9 +300,14 @@ static int kvm_s390_pci_aif_enable(struc gaite->gisc = fib->fmt0.isc; gaite->count++; - gaite->aisbo = fib->fmt0.aisbo; - gaite->aisb =virt_to_phys (page_address (aisb_page) + (fib->fmt0.aisb & - ~PAGE_MASK )); +if (fib->fmt0.sum ==1 ) { + gaite->aisbo = fib->fmt0.aisbo; + gaite->aisb =virt_to_phys (page_address (aisb_page) + + (fib->fmt0.aisb & ~PAGE_MASK )); + }else { + gaite->aisbo =0 ; + gaite->aisb =0 ; + } aift->kzdev[zdev->aisb] = zdev->kzdev;spin_unlock_irq (&aift->gait_lock);
Greg Kroah-Hartman
maintainerPATCH 1564/2077 KVM: SEV: Do not allow intra-host migration/mirroring of SNP VMs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atish Patra <[email protected]>
commit 6ee4140788234a6fabf59e6a50e38cdb936008cd upstream.
The intra-host migration/mirroring feature is not fully implemented for SEV-SNP VMs. The proper migration requires additional SNP-specific state such as guest_req_mutex, guest_req_buf, and guest_resp_buf to be transferred or initialized on the destination.
The SNP VM mirroring requires vmsa features to be copied as well otherwise ASID would be bound to SNP range while VM is detected as a SEV VM.
Reject SNP source VMs in migration/mirroring until proper SNP state transfer is implemented.
--- arch/x86/kvm/svm/sev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/sev.c +4 -2
@@ -2142,8 +2142,9 @@ int sev_vm_move_enc_context_from(structif (ret)return ret; +/* Do not allow SNP VM migration until additional state transfer is implemented */ if (kvm->arch.vm_type != source_kvm->arch.vm_type || -sev_guest (kvm) || !sev_guest (source_kvm)) { +sev_guest (kvm) || !sev_guest (source_kvm) ||sev_snp_guest (source_kvm)) { ret = -EINVAL ; goto out_unlock; }
@@ -2865,8 +2866,9 @@ int sev_vm_copy_enc_context_from(struct* disallow out-of-band SEV/SEV-ES init if the target is already an * SEV guest, or if vCPUs have been created. KVM relies on vCPUs being * created after SEV/SEV-ES initialization, e.g. to init intercepts. +* Also do not allow SNP VM mirroring until additional state transfer is implemented. */ -if (sev_guest (kvm) || !sev_guest (source_kvm) || +if (sev_guest (kvm) || !sev_guest (source_kvm) ||sev_snp_guest (source_kvm) ||is_mirroring_enc_context (source_kvm) || kvm->created_vcpus) { ret = -EINVAL ; goto e_unlock;
Greg Kroah-Hartman
maintainerPATCH 1565/2077 KVM: TDX: Reject concurrent change to CPUID entry count
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Wu <[email protected]>
commit cfbebb55e5127dc162e73fa8956000055a78606c upstream.
Reject KVM_TDX_INIT_VM if userspace changes cpuid.nent between the initial read and the subsequent copy of the initialization data.
tdx_td_init() first reads user_data->cpuid.nent to size the flexible kvm_tdx_init_vm copy. The copied structure also contains cpuid.nent, and that field can differ from the value used to size the allocation if userspace modifies the input concurrently. setup_tdparams_cpuids() later passes init_vm->cpuid.nent to kvm_find_cpuid_entry2(), which uses it as the array bound for the copied entries.
Require the copied count to match the value used to size the allocation so that CPUID parsing cannot access beyond the entries actually copied.
--- arch/x86/kvm/vmx/tdx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/tdx.c +5 -1
@@ -2725,7 +2725,11 @@ static int tdx_td_init(struct kvm *kvm, goto out; } -if (init_vm->cpuid.padding) { +/* +* Reject the request if userspace changes cpuid.nent between the +* initial read and the subsequent copy. +*/ +if (init_vm->cpuid.padding || init_vm->cpuid.nent != nr_user_entries) { ret = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 1566/2077 KVM: x86: Ignore pending PV EOI if the vCPU has since disabled PV EOIs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 9285e4070df2c40585c3d7ec9571faa7a2b97e17 upstream.
Ignore KVM's internal "service pending PV EOI" request if the vCPU has disabled PV EOIs since the request was made. Asserting that PV EOIs are enabled can fail if reading guest memory in pv_eoi_get_user() fails, i.e. if pv_eoi_test_and_clr_pending() bails early, *and* the vCPU also disables PV EOIs.
kernel BUG at arch/x86/kvm/lapic.c:3338!
Oops: invalid opcode: 0000 [#1] SMP CPU: 4 UID: 1000 PID: 890 Comm: pv_eoi_test Not tainted 7.0.0-d585aa5894d8-vm #337 PREEMPT Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:kvm_lapic_sync_from_vapic+0x12b/0x140 [kvm] Call Trace: <TASK> kvm_arch_vcpu_ioctl_run+0x1075/0x1c30 [kvm] kvm_vcpu_ioctl+0x2d5/0x980 [kvm] __x64_sys_ioctl+0x8a/0xd0 do_syscall_64+0xb5/0xb40 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK> Modules linked in: kvm_intel kvm irqbypass ---[ end trace 0000000000000000 ]---
--- arch/x86/kvm/lapic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kvm/lapic.c +6 -2
@@ -3371,6 +3371,12 @@ static void apic_sync_pv_eoi_from_guest( struct kvm_lapic *apic) {int vector; + +if (unlikely (!pv_eoi_enabled (vcpu))) { +__clear_bit (KVM_APIC_PV_EOI_PENDING , &vcpu->arch.apic_attention); +return ; + } +/* * PV EOI state is derived from KVM_APIC_PV_EOI_PENDING in host * and KVM_PV_EOI_ENABLED in guest memory as follows:
@@ -3382,8 +3388,6 @@ static void apic_sync_pv_eoi_from_guest(* KVM_APIC_PV_EOI_PENDING is set, KVM_PV_EOI_ENABLED is unset: * -> host enabled PV EOI, guest executed EOI. */ -BUG_ON (!pv_eoi_enabled (vcpu)); -if (pv_eoi_test_and_clr_pending (vcpu))return ; vector =apic_set_eoi (apic);
Greg Kroah-Hartman
maintainerPATCH 1567/2077 KVM: x86: Nullify irqfd->producer if updating IRTE for bypass fails
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: leixiang <[email protected]>
commit ed446e8aa894883c08892cfee69782fdf8f6c3ca upstream.
Nullify irqfd->producer if updating the IRTE for bypass fails, as leaving a dangling pointer will result in a use-after-free if the irqfd is reachable through KVM's routing, but the producer is freed separately. E.g. for VFIO PCI, the producer is embedded in struct "vfio_pci_irq_ctx" and freed when the vector is disabled, which can happen independent of routing updates.
--- arch/x86/kvm/irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/irq.c +3 -1
@@ -488,8 +488,10 @@ int kvm_arch_irq_bypass_add_producer(strif (irqfd->irq_entry.type ==KVM_IRQ_ROUTING_MSI ) { ret =kvm_pi_update_irte (irqfd, &irqfd->irq_entry); -if (ret) +if (ret) { kvm->arch.nr_possible_bypass_irqs--; + irqfd->producer =NULL ; + } }spin_unlock_irq (&kvm->irqfds.lock);
Greg Kroah-Hartman
maintainerPATCH 1568/2077 KVM: nVMX: Put vmcs12 pages if nested VM-Enter fails due to invalid guest state
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 2f2312c422fd2695da772cecb30c69994b795964 upstream.
Put all vmcs12 pages if KVM synthesizes a nested VM-Exit due to invalid guest while emulating VMLAUNCH or VMRESUME. The invalid guest state path doesn't use nested_vmx_vmexit() as that API is intended to be used if and only if L2 is active, and the open coded equivalent neglects to put the vmcs12 pages. Failure to put the vmcs12 pages leaks any pinned pages (and/or mappings) if L1 retries VMLAUNCH/VMRESUME.
Note, the !from_vmenter scenario doesn't suffer the same problem, as vmx_get_nested_state_pages() only gets/pins/maps the vmcs12 pages if L2 is active, i.e. if a "full" VM-Exit is guaranteed before KVM will retry getting vmcs12 pages.
--- arch/x86/kvm/vmx/nested.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/nested.c +2 -0
@@ -3747,6 +3747,8 @@ vmentry_fail_vmexit:if (!from_vmentry)return NVMX_VMENTRY_VMEXIT ; +nested_put_vmcs12_pages (vcpu); +load_vmcs12_host_state (vcpu, vmcs12); vmcs12->vm_exit_reason = exit_reason.full;if (enable_shadow_vmcs ||nested_vmx_is_evmptr12_valid (vmx))
Greg Kroah-Hartman
maintainerPATCH 1569/2077 KVM: Move kvm_io_bus_get_dev() locking responsibilities to callers
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
commit 3a07249981629ace483ebbef81ef6b34c2d2afec upstream.
kvm_io_bus_get_dev() returns a device that is only matched by the address, and nothing else. This can cause a lifetime issue if the matched device is not the expected type, as by the time the caller can introspect the object, it might be gone (the srcu lock having been dropped).
Given that there is only a single user of this helper, the simplest option is to move the locking responsibility to the caller, which can keep the srcu lock held for as long as it wants.
Note that this aligns with other kvm_io_bus*() helpers, which already require the srcu lock to be held by the callers.
--- arch/arm64/kvm/vgic/vgic-its.c | 2 ++ virt/kvm/kvm_main.c | 16 +++++----------- 2 files changed, 7 insertions(+), 11 deletions(-)
arch/arm64/kvm/vgic/vgic-its.c +2 -0
@@ -507,6 +507,8 @@ static struct vgic_its *__vgic_doorbell_struct kvm_io_device *kvm_io_dev;struct vgic_io_device *iodev; +guard (srcu)(&kvm->srcu); + kvm_io_dev =kvm_io_bus_get_dev (kvm,KVM_MMIO_BUS , db);if (!kvm_io_dev)return ERR_PTR (-EINVAL );
virt/kvm/kvm_main.c +5 -11
@@ -6069,25 +6069,19 @@ struct kvm_io_device *kvm_io_bus_get_dev gpa_t addr) {struct kvm_io_bus *bus; -int dev_idx, srcu_idx; -struct kvm_io_device *iodev =NULL ; +int dev_idx; - srcu_idx =srcu_read_lock (&kvm->srcu); +lockdep_assert_held (&kvm->srcu); bus =kvm_get_bus_srcu (kvm, bus_idx);if (!bus) - goto out_unlock; +return NULL ; dev_idx =kvm_io_bus_get_first_dev (bus, addr,1 );if (dev_idx <0 ) - goto out_unlock; +return NULL ; - iodev = bus->range[dev_idx].dev; - -out_unlock: -srcu_read_unlock (&kvm->srcu, srcu_idx); - -return iodev; +return bus->range[dev_idx].dev; }EXPORT_SYMBOL_FOR_KVM_INTERNAL (kvm_io_bus_get_dev);
Greg Kroah-Hartman
maintainerPATCH 1570/2077 KVM: arm64: account pKVM reclaim against the VM mm
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
commit d098bb75d14fde2f12155f1a95ec0168160867ce upstream.
Protected guest faults charge long term pins to the VM's mm. Teardown can run later from file release, where current->mm may be unrelated.
Drop the charge from kvm->mm instead.
--- arch/arm64/kvm/pkvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/pkvm.c +1 -1
@@ -352,7 +352,7 @@ static int __pkvm_pgtable_stage2_reclaim(struct kvm_pgtable *pgt, u64 start, u64 page =pfn_to_page (mapping->pfn);WARN_ON_ONCE (mapping->nr_pages !=1 );unpin_user_pages_dirty_lock (&page,1 , true); -account_locked_vm (current->mm,1 , false); +account_locked_vm (kvm->mm,1 , false);pkvm_mapping_remove (mapping, &pgt->pkvm_mappings);kfree (mapping); }
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1571/2077 KVM: arm64: Ensure level is always initialized when relaxing perms
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 100baf0184896f859290a684f864b8200d8ac872 upstream.
stage2_update_leaf_attrs() returns early before writing to @level if the table walker returned an error. At the same time, kvm_pgtable_stage2_relax_perms() uses the level as a TLBI TTL hint when the error was EAGAIN, indicating the vCPU raced with a table update and the TLB entry it hit is now stale.
Fall back to an unknown TTL if none was provided by the walk.
--- arch/arm64/kvm/hyp/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/pgtable.c +1 -1
@@ -1358,7 +1358,7 @@ int kvm_pgtable_stage2_relax_perms(struc enum kvm_pgtable_prot prot, enum kvm_pgtable_walk_flags flags) { kvm_pte_t xn = 0, set = 0, clr = 0; -s8 level; +s8 level =TLBI_TTL_UNKNOWN ;int ret;if (prot &KVM_PTE_LEAF_ATTR_HI_SW )
Greg Kroah-Hartman
maintainerPATCH 1572/2077 KVM: arm64: nv: Drop bogus WARN for write to ZCR_EL2
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 9f1667098c6ae7ec81a9a56859cfdacb822aa0d0 upstream.
It is entirely possible for a guest to write to the ZCR_EL2 sysreg alias while in a nested context, as it is expected if FEAT_NV2 is advertised to the L1 hypervisor.
Get rid of the bogus WARN which, since the hyp vectors were installed at this point, has the effect of a hyp_panic...
--- arch/arm64/kvm/hyp/include/hyp/switch.h | 2 -- 1 file changed, 2 deletions(-)
arch/arm64/kvm/hyp/include/hyp/switch.h +0 -2
@@ -601,8 +601,6 @@ static inline bool kvm_hyp_handle_fpsimdreturn false;break ;case ESR_ELx_EC_SYS64: -if (WARN_ON_ONCE (!is_hyp_ctxt (vcpu))) -return false; fallthrough;case ESR_ELx_EC_SVE:if (!sve_guest)
Greg Kroah-Hartman
maintainerPATCH 1573/2077 KVM: arm64: nv: Write ESR_EL2 for injected nested SError exceptions
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
commit e2cb1f4578625e71f461d5c1ce70984193389cbb upstream.
kvm_inject_el2_exception() writes ESR_EL2 for synchronous exceptions but not for SError. enter_exception64() does not write ESR_ELx for any exception type, so the constructed syndrome is dropped. A guest L2 hypervisor taking a nested SError observes stale ESR_EL2.
This affects both kvm_inject_nested_serror() and the EASE path in kvm_inject_nested_sea().
Write ESR_EL2 for except_type_serror, matching except_type_sync.
--- arch/arm64/kvm/emulate-nested.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kvm/emulate-nested.c +1 -0
@@ -2818,6 +2818,7 @@ static void kvm_inject_el2_exception(strbreak ;case except_type_serror:kvm_pend_exception (vcpu,EXCEPT_AA64_EL2_SERR ); +vcpu_write_sys_reg (vcpu, esr_el2,ESR_EL2 );break ;default :WARN_ONCE (1 ,"Unsupported EL2 exception injection %d\n" , type);
Greg Kroah-Hartman
maintainerPATCH 1574/2077 KVM: arm64: nv: Fix SPSR_EL2 restore in kvm_hyp_handle_mops()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit ff1022c3de46753eb7eba2f6efd990569e66ff95 upstream.
kvm_hyp_handle_mops() resets the single-step state machine as part of rewinding state for a MOPS exception by modifying vcpu_cpsr() and writing the result directly into hardware.
In the case of nested virtualization, vcpu_cpsr() is a synthetic value such that the rest of KVM can deal with vEL2 cleanly. That means the value requires translation before being written into hardware, which is unfortunately missing from the MOPS handler.
Fix it by directly modifying SPSR_EL2 and avoiding the synthetic state altogether, which will be resynchronized on the next 'full' exit back to KVM.
--- arch/arm64/kvm/hyp/include/hyp/switch.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm64/kvm/hyp/include/hyp/switch.h +6 -3
@@ -448,16 +448,19 @@ static inline bool __populate_fault_infostatic inline bool kvm_hyp_handle_mops (struct kvm_vcpu *vcpu,u64 *exit_code) { +u64 spsr; + *vcpu_pc (vcpu) =read_sysreg_el2 (SYS_ELR );arm64_mops_reset_regs (vcpu_gp_regs (vcpu), vcpu->arch.fault.esr_el2);write_sysreg_el2 (*vcpu_pc (vcpu),SYS_ELR );/* * Finish potential single step before executing the prologue -* instruction. +* instruction. Modify the hardware SPSR_EL2 directly, as vcpu_cpsr() +* may hold a synthetic (vEL2) value for a guest hypervisor. */ - *vcpu_cpsr (vcpu) &= ~DBG_SPSR_SS ; -write_sysreg_el2 (*vcpu_cpsr (vcpu),SYS_SPSR ); + spsr =read_sysreg_el2 (SYS_SPSR ); +write_sysreg_el2 (spsr & ~DBG_SPSR_SS ,SYS_SPSR );return true; }
Greg Kroah-Hartman
maintainerPATCH 1575/2077 KVM: arm64: nv: Respect read-only PFN when mapping L1 VNCR
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 2684e02bac41c5220f6c1ab2bdcc957b71812977 upstream.
KVM currently maps the L1 VNCR into the host stage-1 by relying entirely on the permissions of the guest stage-1. At the same time, it is entirely possible that the backing PFN is read-only (e.g. RO memslot), meaning that the L1 VNCR should use at most a read-only mapping.
Cache the writability of the PFN in the VNCR TLB and use it to constrain the resulting fixmap permissions. Promote VNCR permission faults to an SEA in the case where the guest attempts to write to a read-only endpoint. Conveniently, this also plugs a page leak found by Sashiko [*] resulting from the early return for a read-only PFN.
--- arch/arm64/kvm/nested.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
arch/arm64/kvm/nested.c +26 -10
@@ -24,6 +24,7 @@ struct vncr_tlb {struct s1_walk_result wr;u64 hpa; +bool hpa_writable;/* -1 when not mapped on a CPU */ int cpu;
@@ -1315,7 +1316,7 @@ static int kvm_translate_vncr(struct kvmif (!*is_gmem) { pfn =__kvm_faultin_pfn (memslot, gfn, write_fault ?FOLL_WRITE :0 , &writable, &page); -if (is_error_noslot_pfn (pfn) || (write_fault && !writable)) +if (is_error_noslot_pfn (pfn))return -EFAULT ; }else { ret =kvm_gmem_get_pfn (vcpu->kvm, memslot, gfn, &pfn, &page,NULL );
@@ -1324,6 +1325,8 @@ static int kvm_translate_vncr(struct kvm write_fault, false, false);return ret; } + + writable = !(memslot->flags &KVM_MEM_READONLY ); } scoped_guard(write_lock, &vcpu->kvm->mmu_lock) {
@@ -1334,28 +1337,41 @@ static int kvm_translate_vncr(struct kvm vt->gva = va; vt->hpa = pfn <<PAGE_SHIFT ; + vt->hpa_writable = writable; vt->valid = true; vt->cpu =-1 ;kvm_make_request (KVM_REQ_MAP_L1_VNCR_EL2 , vcpu); -kvm_release_faultin_page (vcpu->kvm, page, false, vt->wr.pw); +kvm_release_faultin_page (vcpu->kvm, page, false, vt->wr.pw && vt->hpa_writable); } -if (vt->wr.pw) +if (vt->wr.pw && vt->hpa_writable)mark_page_dirty (vcpu->kvm, gfn);return 0 ; } -static void inject_vncr_perm (struct kvm_vcpu *vcpu) +static void handle_vncr_perm (struct kvm_vcpu *vcpu) {struct vncr_tlb *vt = vcpu->arch.vncr_tlb;u64 esr =kvm_vcpu_get_esr (vcpu); +u64 fsc; + +/* +* Promote to an external abort if the stage-1 permits writes but the +* HPA is read-only (e.g. RO memslot). +*/ +if (kvm_is_write_fault (vcpu) && vt->wr.pw && !vt->hpa_writable) + fsc = ESR_ELx_FSC_EXTABT; +/* +* Otherwise, inject a permission fault using the guest's translation +* level rather than the host's. +*/ +else + fsc =ESR_ELx_FSC_PERM_L (vt->wr.level); -/* Adjust the fault level to reflect that of the guest's */ esr &= ~ESR_ELx_FSC; - esr |=FIELD_PREP (ESR_ELx_FSC, -ESR_ELx_FSC_PERM_L (vt->wr.level)); + esr |=FIELD_PREP (ESR_ELx_FSC, fsc);kvm_inject_nested_sync (vcpu, esr); }
@@ -1389,7 +1405,7 @@ int kvm_handle_vncr_abort(struct kvm_vcpreturn kvm_handle_guest_sea (vcpu);if (esr_fsc_is_permission_fault (esr)) { -inject_vncr_perm (vcpu); +handle_vncr_perm (vcpu); }else if (esr_fsc_is_translation_fault (esr)) {bool valid, is_gmem = false;int ret;
@@ -1437,7 +1453,7 @@ int kvm_handle_vncr_abort(struct kvm_vcpbreak ;case -EPERM :/* Hack to deal with POE until we get kernel support */ -inject_vncr_perm (vcpu); +handle_vncr_perm (vcpu);break ;case 0 :break ;
@@ -1481,7 +1497,7 @@ static void kvm_map_l1_vncr(struct kvm_v vt->cpu =smp_processor_id (); -if (vt->wr.pw && vt->wr.pr) +if (vt->hpa_writable && vt->wr.pw && vt->wr.pr) prot =PAGE_KERNEL ;else if (vt->wr.pr) prot =PAGE_KERNEL_RO ;
Greg Kroah-Hartman
maintainerPATCH 1576/2077 KVM: arm64: nv: Inject SEA if kvm_translate_vncr() cant resolve PFN
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 9f3e83345a56280efffe235c65593c7e544c0fcc upstream.
kvm_handle_vncr_abort() assumes that s1_walk_result conveys an abort when kvm_translate_vncr() returns -EFAULT. This is not always the case as it's possible to encounter 'late' failures on the output of S1 translation, e.g. a GFN outside of the memslots.
Fix it by preparing an external abort before returning from kvm_translate_vncr(). Get rid of the BUG_ON() in the fault injection path while at it.
--- arch/arm64/include/asm/kvm_nested.h | 8 ++++++++ arch/arm64/kvm/at.c | 8 -------- arch/arm64/kvm/nested.c | 10 ++++++---- 3 files changed, 14 insertions(+), 12 deletions(-)
arch/arm64/include/asm/kvm_nested.h +8 -0
@@ -388,6 +388,14 @@ struct s1_walk_result {bool failed; }; +static inline void fail_s1_walk (struct s1_walk_result *wr,u8 fst,bool s1ptw) +{ + wr->fst = fst; + wr->ptw = s1ptw; + wr->s2 = s1ptw; + wr->failed = true; +} +int __kvm_translate_va (struct kvm_vcpu *vcpu,struct s1_walk_info *wi,struct s1_walk_result *wr,u64 va); int __kvm_find_s1_desc_level(struct kvm_vcpu *vcpu, u64 va, u64 ipa,
arch/arm64/kvm/at.c +0 -8
@@ -11,14 +11,6 @@#include <asm/kvm_mmu.h> #include <asm/lsui.h> -static void fail_s1_walk (struct s1_walk_result *wr,u8 fst,bool s1ptw) -{ - wr->fst = fst; - wr->ptw = s1ptw; - wr->s2 = s1ptw; - wr->failed = true; -} -#define S1_MMU_DISABLED (-127)static int get_ia_size (struct s1_walk_info *wi)
arch/arm64/kvm/nested.c +6 -4
@@ -1309,15 +1309,19 @@ static int kvm_translate_vncr(struct kvm gfn = vt->wr.pa >>PAGE_SHIFT ; memslot =gfn_to_memslot (vcpu->kvm, gfn); -if (!memslot) +if (!memslot) { +fail_s1_walk (&vt->wr, ESR_ELx_FSC_EXTABT, false);return -EFAULT ; + } *is_gmem =kvm_slot_has_gmem (memslot);if (!*is_gmem) { pfn =__kvm_faultin_pfn (memslot, gfn, write_fault ?FOLL_WRITE :0 , &writable, &page); -if (is_error_noslot_pfn (pfn)) +if (is_error_noslot_pfn (pfn)) { +fail_s1_walk (&vt->wr, ESR_ELx_FSC_EXTABT, false);return -EFAULT ; + } }else { ret =kvm_gmem_get_pfn (vcpu->kvm, memslot, gfn, &pfn, &page,NULL );if (ret) {
@@ -1444,8 +1448,6 @@ int kvm_handle_vncr_abort(struct kvm_vcp* Translation failed, inject the corresponding * exception back to EL2. */ -BUG_ON (!vt->wr.failed); - esr &= ~ESR_ELx_FSC; esr |=FIELD_PREP (ESR_ELx_FSC, vt->wr.fst);
Greg Kroah-Hartman
maintainerPATCH 1577/2077 KVM: arm64: nv: Re-translate VNCR before injecting abort
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit bb645aa0a4caeaf7f9cd32e9a948594d434c1a8f upstream.
KVM faults in the VNCR page with FOLL_WRITE whenever the guest aborts for a write, similar to how a regular stage-2 mapping is handled. It is entirely possible that the guest reads from the VNCR before writing to it, in which case the PFN could only be read-only.
Invalidate the VNCR TLB and re-fetch the translation upon taking a VNCR abort, allowing the host mapping to be faulted in for write the second time around. Interestingly enough, this also satisfies the ordering requirements of FEAT_ETS2/3 between descriptor updates and MMU faults.
--- arch/arm64/kvm/nested.c | 115 ++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 71 deletions(-)
arch/arm64/kvm/nested.c +44 -71
@@ -1380,88 +1380,61 @@ static void handle_vncr_perm(struct kvm_kvm_inject_nested_sync (vcpu, esr); } -static bool kvm_vncr_tlb_lookup (struct kvm_vcpu *vcpu) -{ -struct vncr_tlb *vt = vcpu->arch.vncr_tlb; - -lockdep_assert_held_read (&vcpu->kvm->mmu_lock); - -if (!vt->valid) -return false; - -if (read_vncr_el2 (vcpu) != vt->gva) -return false; - -if (vt->wr.nG) -return get_asid_by_regime (vcpu,TR_EL20 ) == vt->wr.asid; - -return true; -} -int kvm_handle_vncr_abort (struct kvm_vcpu *vcpu) {struct vncr_tlb *vt = vcpu->arch.vncr_tlb;u64 esr =kvm_vcpu_get_esr (vcpu); +bool is_gmem = false; +bool perm; +int ret;WARN_ON_ONCE (!(esr & ESR_ELx_VNCR));if (kvm_vcpu_abt_issea (vcpu))return kvm_handle_guest_sea (vcpu); -if (esr_fsc_is_permission_fault (esr)) { -handle_vncr_perm (vcpu); - }else if (esr_fsc_is_translation_fault (esr)) { -bool valid, is_gmem = false; -int ret; - -scoped_guard (read_lock, &vcpu->kvm->mmu_lock) - valid = kvm_vncr_tlb_lookup(vcpu); - -if (!valid) - ret =kvm_translate_vncr (vcpu, &is_gmem); -else - ret = -EPERM ; - -switch (ret) { -case -EAGAIN : -/* Let's try again... */ -break ; -case -ENOMEM : -/* -* For guest_memfd, this indicates that it failed to -* create a folio to back the memory. Inform userspace. -*/ -if (is_gmem) -return 0 ; -/* Otherwise, let's try again... */ -break ; -case -EFAULT : -case -EIO : -case -EHWPOISON : -if (is_gmem) -return 0 ; - fallthrough; -case -EINVAL : -case -ENOENT : -case -EACCES : -/* -* Translation failed, inject the corresponding -* exception back to EL2. -*/ - esr &= ~ESR_ELx_FSC; - esr |=FIELD_PREP (ESR_ELx_FSC, vt->wr.fst); - -kvm_inject_nested_sync (vcpu, esr); -break ; -case -EPERM : -/* Hack to deal with POE until we get kernel support */ -handle_vncr_perm (vcpu); -break ; -case 0 : -break ; - } - }else { +if (!esr_fsc_is_translation_fault (esr) && !esr_fsc_is_permission_fault (esr)) {WARN_ONCE (1 ,"Unhandled VNCR abort, ESR=%llx\n" , esr); +return 1 ; + } + + ret =kvm_translate_vncr (vcpu, &is_gmem); +switch (ret) { +case -EAGAIN : +/* Let's try again... */ +return 1 ; +case -ENOMEM : +/* +* For guest_memfd, this indicates that it failed to +* create a folio to back the memory. Inform userspace. +*/ +if (is_gmem) +return 0 ; +/* Otherwise, let's try again... */ +break ; +case -EFAULT : +case -EIO : +case -EHWPOISON : +if (is_gmem) +return 0 ; + fallthrough; +case -EINVAL : +case -ENOENT : +case -EACCES : +/* +* Translation failed, inject the corresponding +* exception back to EL2. +*/ + esr &= ~ESR_ELx_FSC; + esr |=FIELD_PREP (ESR_ELx_FSC, vt->wr.fst); + +kvm_inject_nested_sync (vcpu, esr); +break ; +case 0 : + perm =kvm_is_write_fault (vcpu) ? vt->wr.pw && vt->hpa_writable : vt->wr.pr; +if (!perm) +handle_vncr_perm (vcpu); +break ; }return 1 ;
Greg Kroah-Hartman
maintainerPATCH 1578/2077 KVM: arm64: nv: Inject SEA if guest VNCR isnt normal memory
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Upton <[email protected]>
commit 4bd7dbe0b2243e6aa735cae4d5e1ff988b30b2a6 upstream.
When constructing an L1 VNCR mapping, KVM unconditionally uses cacheable memory attributes, even if the underlying PFN isn't memory. This gets particularly hairy if the endpoint doesn't support cacheable memory attributes, potentially throwing an SError on writeback...
While KVM does permit cacheable memory attributes on certain PFNMAP VMAs, kvm_translate_vncr() isn't currently grabbing the VMA. So do the simpler thing for now and just reject everything that isn't memory.
--- arch/arm64/kvm/nested.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm64/kvm/nested.c +11 -0
@@ -1333,6 +1333,17 @@ static int kvm_translate_vncr(struct kvm writable = !(memslot->flags &KVM_MEM_READONLY ); } +/* +* FIXME: This check is too restrictive as KVM allows cacheable memory +* attributes for PFNMAP VMAs that have cacheable attributes in host +* stage-1. +*/ +if (!pfn_is_map_memory (pfn)) { +kvm_release_faultin_page (vcpu->kvm, page, true, false); +fail_s1_walk (&vt->wr, ESR_ELx_FSC_EXTABT, false); +return -EINVAL ; + } + scoped_guard(write_lock, &vcpu->kvm->mmu_lock) {if (mmu_invalidate_retry (vcpu->kvm, mmu_seq)) {kvm_release_faultin_page (vcpu->kvm, page, true, false);
Greg Kroah-Hartman
maintainerPATCH 1579/2077 fbdev: metronomefb: fix potential memory leak in metronomefb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 894632b862a39b3fe1cb5de06fbae86225ea64de upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/metronomefb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/metronomefb.c +6 -2
@@ -645,12 +645,14 @@ static int metronomefb_probe(struct plat info->flags =FBINFO_VIRTFB ; info->fbdefio = &metronomefb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_free_irq; retval =fb_alloc_cmap (&info->cmap,8 ,0 );if (retval <0 ) {dev_err (&dev->dev,"Failed to allocate colormap\n" ); - goto err_free_irq; + goto err_fbdefio; }/* set cmap */
@@ -673,6 +675,8 @@ static int metronomefb_probe(struct plat err_cmap:fb_dealloc_cmap (&info->cmap); +err_fbdefio: +fb_deferred_io_cleanup (info); err_free_irq: board->cleanup (par); err_csum_table:
Greg Kroah-Hartman
maintainerPATCH 1580/2077 fbdev: broadsheetfb: fix potential memory leak in broadsheetfb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 9d18a4e4234fd3ee0d0eed8ccbbb50cb76b2232c upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/broadsheetfb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/broadsheetfb.c +6 -2
@@ -1072,12 +1072,14 @@ static int broadsheetfb_probe(struct pla info->flags =FBINFO_VIRTFB ; info->fbdefio = &broadsheetfb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_vfree; retval =fb_alloc_cmap (&info->cmap,16 ,0 );if (retval <0 ) {dev_err (&dev->dev,"Failed to allocate colormap\n" ); - goto err_vfree; + goto err_fbdefio; }/* set cmap */
@@ -1121,6 +1123,8 @@ err_free_irq: board->cleanup (par); err_cmap:fb_dealloc_cmap (&info->cmap); +err_fbdefio: +fb_deferred_io_cleanup (info); err_vfree:vfree (videomemory); err_fb_rel:
Greg Kroah-Hartman
maintainerPATCH 1581/2077 fbdev: hecubafb: fix potential memory leak in hecubafb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit cbef2a305a8a72969b86f96b7c07b86edde61aff upstream.
The memory allocated for pagerefs in fb_deferred_io_init() is not freed on the error path. Fix it by calling fb_deferred_io_cleanup().
--- drivers/video/fbdev/hecubafb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/video/fbdev/hecubafb.c +5 -1
@@ -192,7 +192,9 @@ static int hecubafb_probe(struct platfor info->flags =FBINFO_VIRTFB ; info->fbdefio = &hecubafb_defio; -fb_deferred_io_init (info); + retval =fb_deferred_io_init (info); +if (retval) + goto err_fbdefio; retval =register_framebuffer (info);if (retval <0 )
@@ -209,6 +211,8 @@ static int hecubafb_probe(struct platforreturn 0 ; err_fbreg: +fb_deferred_io_cleanup (info); +err_fbdefio:framebuffer_release (info); err_fballoc:vfree (videomemory);
Greg Kroah-Hartman
maintainerPATCH 1582/2077 fbdev: sm712: Fix operator precedence in big_swap macro
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
commit 5dbe5b65df0b0c0ec77492427c274b7b5011890e upstream.
The big_swap(p) macro was intended to swap bytes within 16-bit halves of a 32-bit value. However, because the bitwise shift operators (<<, >>) have higher precedence than the bitwise AND operator (&), the original code failed to perform any shifting on the masked bits.
For example, 'p & 0xff00ff00 >> 8' was evaluated as 'p & (0xff00ff00 >> 8)', effectively neutralizing the intended swap.
Fix this by adding parentheses to ensure the bitwise AND is performed before the shift, correctly implementing the byte swap logic.
--- drivers/video/fbdev/sm712.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/sm712.h +1 -1
@@ -101,7 +101,7 @@ struct modeinit {#define mmio_addr 0x00800000#define seqw17 () smtc_seqw(0x17, 0x30)#define big_pixel_depth (p, d) {if (p == 24) {p = 32; d = 32; } } -#define big_swap (p) ((p & 0xff00ff00 >> 8) | (p & 0x00ff00ff << 8)) +#define big_swap (p) (((p & 0xff00ff00) >> 8) | ((p & 0x00ff00ff) << 8))#else #define pal_rgb (r, g, b, val) val#define big_addr 0
Greg Kroah-Hartman
maintainerPATCH 1583/2077 fbdev: efifb: fix memory leak in efifb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 9b6eaf101656958397a6012bf43f6e2e42c9e5cb upstream.
Since commit 73ce73c30ba9 ("fbdev: Transfer video= option strings to caller; clarify ownership") the string returned from fb_get_options() is expected to be freed by the caller, but the string is not freed in efifb_probe(). Fix that by freeing the option string after setup.
--- drivers/video/fbdev/efifb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/efifb.c +1 -0
@@ -377,6 +377,7 @@ static int efifb_probe(struct platform_dif (fb_get_options ("efifb" , &option))return -ENODEV ;efifb_setup (si, option); +kfree (option);/* We don't get linelength from UGA Draw Protocol, only from * EFI Graphics Protocol. So if it's not in DMI, and it's not
Greg Kroah-Hartman
maintainerPATCH 1584/2077 fbdev: radeon: fix potential memory leak in radeonfb_pci_register()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit df8c1101c9a08859da612b5d0a08d55d475522c6 upstream.
The function radeonfb_pci_register() allocates memory for modelist (by calling radeon_check_modes() which calls fb_add_videomode()). The memory is appended to info->modelist, but is not freed in subsequent error paths. Fix this by calling fb_destroy_modelist().
--- drivers/video/fbdev/aty/radeon_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/aty/radeon_base.c +1 -0
@@ -2476,6 +2476,7 @@ static int radeonfb_pci_register(structreturn 0 ; err_unmap_fb:iounmap (rinfo->fb_base); +fb_destroy_modelist (&info->modelist); err_unmap_rom:kfree (rinfo->mon1_EDID);kfree (rinfo->mon2_EDID);
Greg Kroah-Hartman
maintainerPATCH 1585/2077 fbdev: i740fb: fix potential memory leak in i740fb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 5936063409af230a2c88b8700c47b89a19fd70b5 upstream.
In i740fb_probe(), the memory allocated in fb_videomode_to_modelist() for modelist is not freed in the error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/i740fb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/i740fb.c +1 -0
@@ -1152,6 +1152,7 @@ err_reg_framebuffer:fb_dealloc_cmap (&info->cmap); err_alloc_cmap: err_find_mode: +fb_destroy_modelist (&info->modelist);if (par->ddc_registered)i2c_del_adapter (&par->ddc_adapter);pci_iounmap (dev, par->regs);
Greg Kroah-Hartman
maintainerPATCH 1586/2077 fbdev: s3fb: fix potential memory leak in s3_pci_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 3b0ed04bc852887a9164e1bbf521652e8ef3eb92 upstream.
In s3_pci_probe(), the memory allocated for modelist using fb_videomode_to_modelist() is not freed in subsequent error paths. Fix that by calling fb_destroy_modelist()
--- drivers/video/fbdev/s3fb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/s3fb.c +1 -0
@@ -1446,6 +1446,7 @@ err_reg_fb: err_alloc_cmap: err_find_mode:#ifdef CONFIG_FB_S3_DDC +fb_destroy_modelist (&info->modelist);if (par->ddc_registered)i2c_del_adapter (&par->ddc_adapter);if (par->mmio)
Greg Kroah-Hartman
maintainerPATCH 1587/2077 fbdev: uvesafb: fix potential memory leak in uvesafb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 033e56fed09047ee63072e9f58789f40c1c7079d upstream.
Due to an incorrect goto label, memory allocated for modedb and modelist in uvesafb_vbe_init() is not freed in some error paths. Fix this by updating the goto label.
--- drivers/video/fbdev/uvesafb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/uvesafb.c +2 -2
@@ -1694,14 +1694,14 @@ static int uvesafb_probe(struct platform i =uvesafb_vbe_init_mode (info);if (i <0 ) { err = -EINVAL ; - goto out; + goto out_mode; }else { mode = &par->vbe_modes[i]; }if (fb_alloc_cmap (&info->cmap,256 ,0 ) <0 ) { err = -ENXIO ; - goto out; + goto out_mode; }uvesafb_init_info (info, mode);
Greg Kroah-Hartman
maintainerPATCH 1588/2077 fbdev: tdfxfb: fix potential memory leak in tdfxfb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit bb019d755366cc3e777a12d4bf457ff289837370 upstream.
In tdfxfb_probe(), the memory allocated for modelist using fb_videomode_to_modelist() when CONFIG_FB_3DFX_I2C is defined, is not freed in the subsequent error paths.
Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/tdfxfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/tdfxfb.c +1 -0
@@ -1551,6 +1551,7 @@ static int tdfxfb_probe(struct pci_dev * out_err_iobase:#ifdef CONFIG_FB_3DFX_I2C +fb_destroy_modelist (&info->modelist);tdfxfb_delete_i2c_busses (default_par);#endif arch_phys_wc_del (default_par->wc_cookie);
Greg Kroah-Hartman
maintainerPATCH 1589/2077 fbdev: carminefb: fix potential memory leak in alloc_carmine_fb()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 6fcca16a2b19c37f60693c56cbc0c923364ff3ef upstream.
The memory allocated for modelist in fb_videomode_to_modelist() is not freed in the subsequent error path.
Fix that by calling fb_destroy_modelist()
--- drivers/video/fbdev/carminefb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/carminefb.c +1 -0
@@ -589,6 +589,7 @@ static int alloc_carmine_fb(void __iomemreturn 0 ; err_dealloc_cmap: +fb_destroy_modelist (&info->modelist);fb_dealloc_cmap (&info->cmap); err_free_fb:framebuffer_release (info);
Greg Kroah-Hartman
maintainerPATCH 1590/2077 fbdev: vesafb: fix memory leak in vesafb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit b15d708995c01bbffe7dcd634a31959f6805bed3 upstream.
Since commit 73ce73c30ba9 ("fbdev: Transfer video= option strings to caller; clarify ownership") the string returned from fb_get_options() is expected to be freed by the caller. But the string is not freed in vesafb_probe(). Fix that by freeing the option string after setup.
--- drivers/video/fbdev/vesafb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/vesafb.c +1 -0
@@ -269,6 +269,7 @@ static int vesafb_probe(struct platform_/* ignore error return of fb_get_options */ fb_get_options ("vesafb" , &option);vesafb_setup (option); +kfree (option);if (si->orig_video_isVGA !=VIDEO_TYPE_VLFB )return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 1591/2077 fbdev: nvidia: fix potential memory leak in nvidiafb_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 85f5e38c162bdf9dbbe197275d416402712f3707 upstream.
In nvidiafb_probe(), the memory allocated for modelist in nvidia_set_fbinfo() is not freed in the subsequent error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/nvidia/nvidia.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/nvidia/nvidia.c +1 -0
@@ -1421,6 +1421,7 @@ static int nvidiafb_probe(struct pci_dev err_out_iounmap_fb:iounmap (info->screen_base); +fb_destroy_modelist (&info->modelist); err_out_free_base1:fb_destroy_modedb (info->monspecs.modedb);nvidia_delete_i2c_busses (par);
Greg Kroah-Hartman
maintainerPATCH 1592/2077 fbdev: tridentfb: fix potential memory leak in trident_pci_probe()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 7a35ec619d9af8ee128320975c1252b8ad65f1e8 upstream.
In trident_pci_probe(), the memory allocated for modelist using fb_videomode_to_modelist() is not freed in subsequent error paths. Fix that by calling fb_destroy_modelist().
--- drivers/video/fbdev/tridentfb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/tridentfb.c +1 -0
@@ -1706,6 +1706,7 @@ static int trident_pci_probe(struct pci_return 0 ; out_unmap2: +fb_destroy_modelist (&info->modelist);if (default_par->ddc_registered)i2c_del_adapter (&default_par->ddc_adapter);kfree (info->pixmap.addr);
Greg Kroah-Hartman
maintainerPATCH 1593/2077 ASoC: SOF: topology: fix memory leak in snd_sof_load_topology
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
commit d46f9f23897261da53ffbeb89d48a13982ba7d28 upstream.
When the topology filename contains "dummy" and tplg_cnt is 0, the function returns -EINVAL directly without freeing the tplg_files allocated by kcalloc() at line 2497. This leaks memory on every such topology load attempt.
Fix this by setting ret = -EINVAL and jumping to the out: label, which already handles the kfree(tplg_files) cleanup.
--- sound/soc/sof/topology.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/topology.c +2 -0
@@ -2537,6 +2537,8 @@ int snd_sof_load_topology(struct snd_socif (strstr (file,"dummy" )) {dev_err (scomp->dev,"Function topology is required, please upgrade sof-firmware\n" ); + +kfree (tplg_files);return -EINVAL ; } tplg_files[0 ] = file;
Greg Kroah-Hartman
maintainerPATCH 1594/2077 ASoC: SOF: ipc3-control: Fix heap overflow in bytes_ext put/get
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit fd46668d538993218eea19c6925c868ac0f2630c upstream.
The ipc_control_data buffer is allocated as kzalloc(max_size), where max_size covers the entire struct sof_ipc_ctrl_data including its flexible array payload. However, the bounds checks in bytes_ext_put and _bytes_ext_get compared user data lengths against max_size directly, ignoring that cdata->data sits at an offset of sizeof(struct sof_ipc_ctrl_data) bytes into the allocation.
This allowed writing up to sizeof(struct sof_ipc_ctrl_data) bytes past the end of the heap buffer from unprivileged userspace via the ALSA TLV kcontrol interface, and similarly allowed over-reading adjacent heap data on the get path.
Fix all bounds checks to subtract sizeof(*cdata) from max_size so they reflect the actual space available at the cdata->data offset. Also fix the error-path restore in bytes_ext_put which wrote to cdata->data instead of cdata, causing the same overflow.
--- sound/soc/sof/ipc3-control.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
sound/soc/sof/ipc3-control.c +19 -8
@@ -398,9 +398,17 @@ static int sof_ipc3_bytes_ext_put(struct }/* be->max is coming from topology */ -if (header.length > scontrol->max_size) { -dev_err_ratelimited (scomp->dev,"Bytes data size %d exceeds max %zu\n" , - header.length, scontrol->max_size); +if (header.length > scontrol->max_size -sizeof (*cdata)) { +dev_err_ratelimited (scomp->dev,"Bytes data size %u exceeds max %zu\n" , + header.length, scontrol->max_size -sizeof (*cdata)); +return -EINVAL ; + } + +/* Ensure the data is large enough to contain the ABI header */ +if (header.length <sizeof (struct sof_abi_hdr )) { +dev_err_ratelimited (scomp->dev, +"Bytes data size %u less than ABI header %zu\n" , + header.length,sizeof (struct sof_abi_hdr ));return -EINVAL ; }
@@ -436,7 +444,7 @@ static int sof_ipc3_bytes_ext_put(struct }/* be->max has been verified to be >= sizeof(struct sof_abi_hdr) */ -if (cdata->data->size > scontrol->max_size -sizeof (struct sof_abi_hdr )) { +if (cdata->data->size > scontrol->max_size -sizeof (*cdata) -sizeof (struct sof_abi_hdr )) {dev_err_ratelimited (scomp->dev,"Mismatch in ABI data size (truncated?)\n" ); goto err_restore; }
@@ -452,7 +460,7 @@ static int sof_ipc3_bytes_ext_put(struct err_restore:/* If we have an issue, we restore the old, valid bytes control data */ if (scontrol->old_ipc_control_data) { -memcpy (cdata->data, scontrol->old_ipc_control_data, scontrol->max_size); +memcpy (cdata, scontrol->old_ipc_control_data, scontrol->max_size);kfree (scontrol->old_ipc_control_data); scontrol->old_ipc_control_data =NULL ; }
@@ -491,10 +499,13 @@ static int _sof_ipc3_bytes_ext_get(struc }/* check data size doesn't exceed max coming from topology */ -if (cdata->data->size > scontrol->max_size -sizeof (struct sof_abi_hdr )) { -dev_err_ratelimited (scomp->dev,"User data size %d exceeds max size %zu\n" , +if (cdata->data->size > scontrol->max_size -sizeof (*cdata) - +sizeof (struct sof_abi_hdr )) { +dev_err_ratelimited (scomp->dev, +"User data size %u exceeds max size %zu\n" , cdata->data->size, - scontrol->max_size -sizeof (struct sof_abi_hdr )); + scontrol->max_size -sizeof (*cdata) - +sizeof (struct sof_abi_hdr ));return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 1595/2077 ASoC: SOF: ipc3-control: Validate size in snd_sof_update_control
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 390aa4c9339bb0ec0bc8d554e830faf93ca9d49e upstream.
In snd_sof_update_control(), firmware-provided cdata->num_elems is checked against local_cdata->data->size but never against the actual allocation size. If local_cdata->data->size was previously set to an inconsistent value, the memcpy could write past the allocated buffer.
Add a bounds check to ensure num_elems fits within the available space in the ipc_control_data allocation before copying.
--- sound/soc/sof/ipc3-control.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/sof/ipc3-control.c +9 -0
@@ -555,6 +555,15 @@ static void snd_sof_update_control(strucreturn ; } +/* Verify the size fits within the allocation */ +if (cdata->num_elems > scontrol->max_size -sizeof (*local_cdata) - +sizeof (*local_cdata->data)) { +dev_err (scomp->dev, +"cdata binary size %u exceeds buffer\n" , + cdata->num_elems); +return ; + } +/* copy the new binary data */ memcpy (local_cdata->data, cdata->data, cdata->num_elems); }else if (cdata->num_elems != scontrol->num_channels) {
Greg Kroah-Hartman
maintainerPATCH 1596/2077 ASoC: mediatek: mt8192: Check runtime resume during probe
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit e24d5dde56a50946020b134fa8448869093db76a upstream.
The MT8192 AFE probe enables runtime PM temporarily while reinitializing the regmap cache from hardware, but it uses pm_runtime_get_sync() without checking the return value. If runtime resume fails, probe keeps going without the device necessarily being accessible, and pm_runtime_get_sync() may leave the PM usage count incremented.
The regmap_reinit_cache() failure path also returns before dropping the temporary PM reference and before clearing pm_runtime_bypass_reg_ctl.
Use pm_runtime_resume_and_get() so resume failures do not leak a usage count, and clear the temporary bypass flag after dropping the probe PM reference on all regmap_reinit_cache() outcomes.
--- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +8 -4
@@ -2218,15 +2218,19 @@ static int mt8192_afe_pcm_dev_probe(stru/* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; -pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret) { + afe_priv->pm_runtime_bypass_reg_ctl = false; +return dev_err_probe (dev, ret,"failed to resume device\n" ); + } ret =regmap_reinit_cache (afe->regmap, &mt8192_afe_regmap_config); -if (ret) -return dev_err_probe (dev, ret,"regmap_reinit_cache fail\n" ); -pm_runtime_put_sync (dev); afe_priv->pm_runtime_bypass_reg_ctl = false; +if (ret) +return dev_err_probe (dev, ret,"regmap_reinit_cache fail\n" ); +regcache_cache_only (afe->regmap, true);regcache_mark_dirty (afe->regmap);
Greg Kroah-Hartman
maintainerPATCH 1597/2077 ASoC: mediatek: mt8192: Release reserved memory on cleanup
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 965e17ae6751c5d3302430c8ebd650e72d45a85f upstream.
The MT8192 AFE probe calls of_reserved_mem_device_init() and falls back to preallocated buffers when no reserved memory region is available. When the reserved memory assignment succeeds, however, the driver never releases it.
Register a devm cleanup action after a successful reserved-memory assignment so the assignment is released on probe failure and driver unbind.
--- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +9 -0
@@ -2155,6 +2155,11 @@ static const dai_register_cb dai_registe mt8192_dai_memif_register, }; +static void mt8192_afe_release_reserved_mem (void *data) +{ +of_reserved_mem_device_release (data); +} +static int mt8192_afe_pcm_dev_probe (struct platform_device *pdev) {struct mtk_base_afe *afe;
@@ -2184,6 +2189,10 @@ static int mt8192_afe_pcm_dev_probe(struif (ret) {dev_info (dev,"no reserved memory found, pre-allocating buffers instead\n" ); afe->preallocate_buffers = true; + }else { + ret =devm_add_action_or_reset (dev, mt8192_afe_release_reserved_mem, dev); +if (ret) +return ret; }/* init audio related clock */
Greg Kroah-Hartman
maintainerPATCH 1598/2077 ASoC: mediatek: mt8183: Check runtime resume during probe
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit f0334fbfd107682d0c95f3f71e25f6127038e2b9 upstream.
The MT8183 AFE probe uses pm_runtime_get_sync() before reading hardware defaults into the regmap cache, but does not check whether runtime resume failed. If regmap_reinit_cache() then fails, the temporary runtime PM usage count is also not released.
Use pm_runtime_resume_and_get() so resume failures abort probe without leaking a usage count, and release the temporary reference before handling the regmap cache result.
--- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +8 -4
@@ -833,17 +833,21 @@ static int mt8183_afe_pcm_dev_probe(stru/* enable clock for regcache get default value from hw */ afe_priv->pm_runtime_bypass_reg_ctl = true; -pm_runtime_get_sync (dev); - - ret =regmap_reinit_cache (afe->regmap, &mt8183_afe_regmap_config); + ret =pm_runtime_resume_and_get (dev);if (ret) { -dev_err (dev,"regmap_reinit_cache fail, ret %d\n" , ret); + afe_priv->pm_runtime_bypass_reg_ctl = false; goto err_pm_disable; } + ret =regmap_reinit_cache (afe->regmap, &mt8183_afe_regmap_config);pm_runtime_put_sync (dev); afe_priv->pm_runtime_bypass_reg_ctl = false; +if (ret) { +dev_err (dev,"regmap_reinit_cache fail, ret %d\n" , ret); + goto err_pm_disable; + } +regcache_cache_only (afe->regmap, true);regcache_mark_dirty (afe->regmap);
Greg Kroah-Hartman
maintainerPATCH 1599/2077 ASoC: mediatek: mt8183: Release reserved memory on cleanup
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit bee65e00c0924ebecf97718d95dcf4a05ee36471 upstream.
The MT8183 AFE probe can assign reserved memory with of_reserved_mem_device_init(), but the assignment is never released on driver removal or later probe failures.
Register a devm cleanup action so the reserved memory assignment is released consistently, matching newer Mediatek AFE drivers.
--- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +11 -0
@@ -766,6 +766,11 @@ static const dai_register_cb dai_registe mt8183_dai_memif_register, }; +static void mt8183_afe_release_reserved_mem (void *data) +{ +of_reserved_mem_device_release (data); +} +static int mt8183_afe_pcm_dev_probe (struct platform_device *pdev) {struct mtk_base_afe *afe;
@@ -794,6 +799,12 @@ static int mt8183_afe_pcm_dev_probe(struif (ret) {dev_info (dev,"no reserved memory found, pre-allocating buffers instead\n" ); afe->preallocate_buffers = true; + }else { + ret =devm_add_action_or_reset (dev, + mt8183_afe_release_reserved_mem, + dev); +if (ret) +return ret; }/* initial audio related clock */
Greg Kroah-Hartman
maintainerPATCH 1600/2077 ASoC: qcom: q6apm: fix NULL pointer dereference in graph_callback
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 2e9261761b35f0b67b7487688cd1365f535be0b3 upstream.
When q6apm_free_fragments() is called it frees rx_data.buf/tx_data.buf and sets them to NULL under graph->lock. A late DSP buffer-done response can race with this: graph_callback() passes the !graph->ar_graph guard (not yet NULL), acquires the lock, but then dereferences a now-NULL buf pointer to read buf[token].phys, crashing at virtual address 0x10.
Add a NULL check for buf inside the mutex-protected section in both the write-done (DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2) and read-done (DATA_CMD_RSP_RD_SH_MEM_EP_DATA_BUFFER_V2) handlers and bail out cleanly if buffers have already been freed.
This problem is only shown up recently while apr bus was updated to process the commands per service rather from single global queue.
--- sound/soc/qcom/qdsp6/q6apm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/qcom/qdsp6/q6apm.c +8 -0
@@ -549,6 +549,10 @@ static int graph_callback(const struct g token = hdr->token &APM_WRITE_TOKEN_MASK ; done = data->payload; +if (!graph->rx_data.buf) { +mutex_unlock (&graph->lock); +break ; + } phys = graph->rx_data.buf[token].phys;mutex_unlock (&graph->lock);/* token numbering starts at 0 */
@@ -571,6 +575,10 @@ static int graph_callback(const struct g client_event =APM_CLIENT_EVENT_DATA_READ_DONE ;mutex_lock (&graph->lock); rd_done = data->payload; +if (!graph->tx_data.buf) { +mutex_unlock (&graph->lock); +break ; + } phys = graph->tx_data.buf[hdr->token].phys;mutex_unlock (&graph->lock);/* token numbering starts at 0 */
Greg Kroah-Hartman
maintainerPATCH 1601/2077 netfilter: nf_conntrack_irc: fix parse_dcc() off-by-one OOB read
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
commit ef6400ca25a13fd6dedbe8ef4a1d0979bbbfe88a upstream.
parse_dcc() treats data_end as an inclusive end pointer, but its only caller passes data_limit = ib_ptr + datalen, which points one past the last valid byte.
The newline search loop iterates while tmp <= data_end, so when no newline is present, *tmp is read at tmp == data_end, one byte beyond the region filled by skb_header_pointer().
irc_buffer is kmalloc'd as MAX_SEARCH_SIZE + 1 bytes and datalen is capped at MAX_SEARCH_SIZE, so the stray read does not fault. The byte is uninitialized or stale; if it contains an ASCII digit, simple_strtoul will consume it and produce a wrong DCC IP or port in the conntrack expectation. The extra allocation byte is also a fragile guard: if the cap or allocation size changes, this becomes a real out-of-bounds read.
Change the loop and its post-loop check to use strict less-than, consistent with the caller's exclusive-end convention. Update the function comment accordingly.
--- net/netfilter/nf_conntrack_irc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_irc.c +3 -3
@@ -59,7 +59,7 @@ static const char *const dccprotos[] = {/* tries to get the ip_addr and port out of a dcc command * return value: -1 on failure, 0 on success * data pointer to first byte of DCC command data -* data_end pointer to last byte of dcc command data +* data_end one past end of data * ip returns parsed ip of dcc command * port returns parsed port of dcc command * ad_beg_p returns pointer to first byte of addr data
@@ -77,10 +77,10 @@ static int parse_dcc(char *data, const c/* Make sure we have a newline character within the packet boundaries * because simple_strtoul parses until the first invalid character. */ -for (tmp = data; tmp <= data_end; tmp++) +for (tmp = data; tmp < data_end; tmp++)if (*tmp =='\n' )break ; -if (tmp > data_end || *tmp !='\n' ) +if (tmp >= data_end || *tmp !='\n' )return -1 ; *ad_beg_p = data;
Greg Kroah-Hartman
maintainerPATCH 1602/2077 netfilter: nfnl_cthelper: apply per-class values when updating policies
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
commit d738feccb98cb224ebabecb703e98f5008276bff upstream.
When a userspace conntrack helper with multiple expectation classes is updated via nfnetlink, every class ends up with the first class's max_expected and timeout values.
nfnl_cthelper_update_policy_all() validates each new policy into the corresponding slot of the temporary new_policy array, but the second loop that commits the values into the live helper dereferences new_policy as a pointer instead of indexing it, so every iteration reads new_policy[0] regardless of i. An update that changes per-class values is silently collapsed onto class 0's values with no error returned to userspace.
Index the temporary array by i in the commit loop so each class gets its own validated values.
--- net/netfilter/nfnetlink_cthelper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nfnetlink_cthelper.c +2 -2
@@ -354,8 +354,8 @@ static int nfnl_cthelper_update_policy_afor (i =0 ; i < helper->expect_class_max +1 ; i++) { policy = (struct nf_conntrack_expect_policy *) &helper->expect_policy[i]; - policy->max_expected = new_policy->max_expected; - policy->timeout = new_policy->timeout; + policy->max_expected = new_policy[i].max_expected; + policy->timeout = new_policy[i].timeout; } err:
Greg Kroah-Hartman
maintainerPATCH 1603/2077 netfilter: xt_cluster: reject template conntracks in hash match
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
commit 5feba91006ec92da57acc1cc2e34df623b98541e upstream.
xt_cluster_mt() treats any non-NULL nf_ct_get() result as a fully initialized conntrack and passes it to xt_cluster_hash().
This causes a state confusion bug when the raw table CT target attaches a template conntrack to skb->_nfct before normal conntrack processing. Templates carry IPS_TEMPLATE status but do not have a valid tuple for hashing yet, so xt_cluster_hash() can hit its WARN_ON() path on the zeroed l3num field.
Reject template conntracks before hashing them. This matches existing netfilter handling for template objects and avoids hashing incomplete conntrack state.
--- net/netfilter/xt_cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_cluster.c +1 -1
@@ -107,7 +107,7 @@ xt_cluster_mt(const struct sk_buff *skb, } ct =nf_ct_get (skb, &ctinfo); -if (ct ==NULL ) +if (!ct ||nf_ct_is_template (ct))return false;if (ct->master)
Greg Kroah-Hartman
maintainerPATCH 1604/2077 netfilter: nf_queue: pin bridge device while NFQUEUE holds fake dst
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoze Xie <[email protected]>
commit c9c9b37f8c5505224e8d206184df3bb668ee00cf upstream.
The br_netfilter fake rtable is embedded in struct net_bridge and is attached to bridged packets with skb_dst_set_noref(). If such a packet is queued to NFQUEUE, __nf_queue() upgrades that fake dst with skb_dst_force().
At that point the queued skb can hold a real dst reference after bridge teardown has started. The problem is not that every bridged packet needs its own dst reference. The problem is that NFQUEUE can keep the bridge private fake dst alive after unregister begins.
Fix this by keeping the bridge fake dst model unchanged and pinning the bridge master device only while the packet sits in NFQUEUE. Record the bridge device in nf_queue_entry when the queued skb carries a bridge fake dst, take a device reference for the queue lifetime, and drop it when the queue entry is freed.
Also make sure queued entries are reaped when that bridge device goes down, and drop the redundant nf_bridge_info_exists() test from the fake dst detection.
This keeps netdev_priv(br->dev) alive until verdict completion, so the embedded fake rtable and its metrics backing storage cannot be freed out from under dst_release(). It also avoids the constant refcount bump and avoids using ipv4-specific dst helpers for IPv6 bridge traffic.
--- include/net/netfilter/nf_queue.h | 1 + net/netfilter/nf_queue.c | 14 ++++++++++++++ net/netfilter/nfnetlink_queue.c | 3 +++ 3 files changed, 18 insertions(+)
include/net/netfilter/nf_queue.h +1 -0
@@ -18,6 +18,7 @@ struct nf_queue_entry {unsigned int id;unsigned int hook_index;/* index in hook_entries->hook[] */ #if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) +struct net_device *bridge_dev;struct net_device *physin;struct net_device *physout;#endif
net/netfilter/nf_queue.c +14 -0
@@ -68,6 +68,7 @@ static void nf_queue_entry_release_refs(nf_queue_sock_put (state->sk);#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) +dev_put (entry->bridge_dev);dev_put (entry->physin);dev_put (entry->physout);#endif
@@ -84,6 +85,8 @@ static void __nf_queue_entry_init_physde {#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )const struct sk_buff *skb = entry->skb; +struct dst_entry *dst =skb_dst (skb); +struct net_device *dev =NULL ;if (nf_bridge_info_exists (skb)) { entry->physin =nf_bridge_get_physindev (skb, entry->state.net);
@@ -92,6 +95,16 @@ static void __nf_queue_entry_init_physde entry->physin =NULL ; entry->physout = NULL; } + +if (entry->state.pf ==NFPROTO_BRIDGE && + dst && (dst->flags &DST_FAKE_RTABLE )) + dev =dst_dev_rcu (dst); + +/* Must hold a reference on the bridge device: dst_hold() protects +* the dst itself, but the fake rtable is embedded in bridge-private +* storage that netdevice teardown can free independently. +*/ + entry->bridge_dev = dev;#endif }
@@ -108,6 +121,7 @@ bool nf_queue_entry_get_refs(struct nf_qdev_hold (state->out);#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) +dev_hold (entry->bridge_dev);dev_hold (entry->physin);dev_hold (entry->physout);#endif
net/netfilter/nfnetlink_queue.c +3 -0
@@ -1270,6 +1270,9 @@ dev_cmp(struct nf_queue_entry *entry, unif (physinif == ifindex || physoutif == ifindex)return 1 ; + +if (entry->bridge_dev && entry->bridge_dev->ifindex == ifindex) +return 1 ;#endif if (entry->skb_dev && entry->skb_dev->ifindex == ifindex)return 1 ;
Greg Kroah-Hartman
maintainerPATCH 1605/2077 netfilter: nft_fib: reject fib expression on the netdev egress hook
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodor Arsenij Larionov-Trichkine <[email protected]>
commit d07955dd34ecae17d35d8c7d0a273a3fba653a8c upstream.
A fib expression in a netdev egress base chain dereferences nft_in(pkt), NULL on the transmit path, causing a NULL pointer dereference at eval. nft_fib_validate() masks the hook with NF_INET_* values, but netdev hook numbers are a separate enum that aliases them (NF_NETDEV_EGRESS == NF_INET_LOCAL_IN), so an egress chain passes validation and then faults.
Add nft_fib_netdev_validate() that limits each result/flag to the netdev hook where the device it reads exists: the input-device cases (OIF, OIFNAME, ADDRTYPE with F_IIF) to ingress, the output-device case (ADDRTYPE with F_OIF) to egress, ADDRTYPE with no device flag to both. Also restrict nft_fib_validate() to NFPROTO_IPV4/IPV6/INET so its NF_INET_* masks are not applied to another family's hooks.
--- net/netfilter/nft_fib.c | 9 +++++++++ net/netfilter/nft_fib_netdev.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-)
net/netfilter/nft_fib.c +9 -0
@@ -31,6 +31,15 @@ int nft_fib_validate(const struct nft_ctconst struct nft_fib *priv =nft_expr_priv (expr);unsigned int hooks; +switch (ctx->family) { +case NFPROTO_IPV4 : +case NFPROTO_IPV6 : +case NFPROTO_INET : +break ; +default : +return -EOPNOTSUPP ; + } +switch (priv->result) {case NFT_FIB_RESULT_OIF :case NFT_FIB_RESULT_OIFNAME :
net/netfilter/nft_fib_netdev.c +28 -1
@@ -50,6 +50,33 @@ static void nft_fib_netdev_eval(const st regs->verdict.code =NFT_BREAK ; } +static int nft_fib_netdev_validate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +const struct nft_fib *priv =nft_expr_priv (expr); +unsigned int hooks; + +switch (priv->result) { +case NFT_FIB_RESULT_OIF : +case NFT_FIB_RESULT_OIFNAME : + hooks = (1 <<NF_NETDEV_INGRESS ); +break ; +case NFT_FIB_RESULT_ADDRTYPE : +if (priv->flags &NFTA_FIB_F_IIF ) + hooks = (1 <<NF_NETDEV_INGRESS ); +else if (priv->flags &NFTA_FIB_F_OIF ) + hooks = (1 <<NF_NETDEV_EGRESS ); +else + hooks = (1 <<NF_NETDEV_INGRESS ) | + (1 <<NF_NETDEV_EGRESS ); +break ; +default : +return -EINVAL ; + } + +return nft_chain_validate_hooks (ctx->chain, hooks); +} +static struct nft_expr_type nft_fib_netdev_type;static const struct nft_expr_ops nft_fib_netdev_ops = { .type = &nft_fib_netdev_type,
@@ -57,7 +84,7 @@ static const struct nft_expr_ops nft_fib .eval = nft_fib_netdev_eval, .init = nft_fib_init, .dump = nft_fib_dump, - .validate = nft_fib_validate, + .validate = nft_fib_netdev_validate, };static struct nft_expr_type nft_fib_netdev_type__read_mostly = {
Greg Kroah-Hartman
maintainerPATCH 1606/2077 netfilter: nf_conntrack_sip: validate skb_dst() before accessing it
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit e5e24a365a5e024efef63cc49abb345fbd4852c5 upstream.
tc ingress and openvswitch do not guarantee routing information to be available. These subsystems use the conntrack helper infrastructure, and the SIP helper relies on the skb_dst() to be present if sip_external_media is set to 1 (which is disabled by default as a module parameter).
This effectively disables the sip_external_media toggle for these subsystems without resulting in a crash.
--- net/netfilter/nf_conntrack_sip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_sip.c +5 -2
@@ -956,7 +956,6 @@ static int set_expected_rtp_rtcp(structreturn NF_ACCEPT ; saddr = &ct->tuplehash[!dir].tuple.src.u3; }else if (sip_external_media) { -struct net_device *dev =skb_dst (skb)->dev;struct dst_entry *dst =NULL ;struct flowi fl;
@@ -978,7 +977,11 @@ static int set_expected_rtp_rtcp(struct* through the same interface as the signalling peer. */ if (dst) { -bool external_media = (dst->dev == dev); +const struct dst_entry *this_dst =skb_dst (skb); +bool external_media = false; + +if (this_dst && dst->dev == this_dst->dev) + external_media = true;dst_release (dst);if (external_media)
Greg Kroah-Hartman
maintainerPATCH 1607/2077 netfilter: nft_set_pipapo: dont leak bad clone into future transaction
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 47e65eff50691f0a5b79d325e28d83ec1da43bcf upstream.
On memory allocation failure the cloned nft_pipapo_match can enter a bad state:
- some fields can have their lookup tables resized while others did not
- bits might have been toggled
- scratch map can be undersized which also means m->bsize_max can be lower than what is required
This means that the next insertion in the same batch can trigger out-of-bounds writes.
Furthermore, a failure in the first can result in the bad clone to leak into the next transaction because the abort callback is never executed in this case (the upper layer saw an error and no attempt to allocate a transactional request was made).
Record a state for the nft_pipapo_match structure:
- NEW (pristine clone)
- MOD (modified clone with good state)
- ERR (potentially bogus content)
Then make it so that deletes and insertions fail when the clone entered ERR state.
In case the very first insert attempt results in an error, free the clone right away.
--- net/netfilter/nft_set_pipapo.c | 34 +++++++++++++++++++++++++++++----- net/netfilter/nft_set_pipapo.h | 8 ++++++++ 2 files changed, 37 insertions(+), 5 deletions(-)
net/netfilter/nft_set_pipapo.c +29 -5
@@ -342,6 +342,8 @@#include "nft_set_pipapo_avx2.h" #include "nft_set_pipapo.h" +static void nft_pipapo_abort (const struct nft_set *set); +/** * pipapo_refill() - For each set bit, set bits from selected mapping table item * @map: Bitmap to be scanned for set bits
@@ -1296,7 +1298,7 @@ static int nft_pipapo_insert(const strucconst u8 *start_p, *end_p;int i, bsize_max, err =0 ; -if (!m) +if (!m || m->state ==NFT_PIPAPO_CLONE_ERR )return -ENOMEM ;if (nft_set_ext_exists (ext,NFT_SET_EXT_KEY_END ))
@@ -1367,8 +1369,10 @@ static int nft_pipapo_insert(const strucelse ret =pipapo_expand (f, start, end, f->groups * f->bb); -if (ret <0 ) -return ret; +if (ret <0 ) { + err = ret; + goto abort; + }if (f->bsize > bsize_max) bsize_max = f->bsize;
@@ -1384,7 +1388,7 @@ static int nft_pipapo_insert(const struc err =pipapo_realloc_scratch (m, bsize_max);if (err) -return err; + goto abort; m->bsize_max = bsize_max; }else {
@@ -1396,7 +1400,26 @@ static int nft_pipapo_insert(const strucpipapo_map (m, rulemap, e); + m->state =NFT_PIPAPO_CLONE_MOD ;return 0 ; +abort: +DEBUG_NET_WARN_ON_ONCE (m->state ==NFT_PIPAPO_CLONE_ERR ); + +/* Two rollback cases: +* 1) no previous changes. nft_pipapo_abort is not +* guaranteed to be invoked (there might be no further +* add/delete requests coming after this). +* +* 2) we had previous changes: there are transaction +* records pointing to this set. Leave the rollback to +* the transaction handling. +*/ +if (m->state ==NFT_PIPAPO_CLONE_NEW ) +nft_pipapo_abort (set);/* releases m */ +else + m->state =NFT_PIPAPO_CLONE_ERR ; + +return err; }/**
@@ -1473,6 +1496,7 @@ static struct nft_pipapo_match *pipapo_c dst++; } + new->state =NFT_PIPAPO_CLONE_NEW ;return new; out_mt:
@@ -1896,7 +1920,7 @@ nft_pipapo_deactivate(const struct net */* removal must occur on priv->clone, if we are low on memory * we have no choice and must fail the removal request. */ -if (!m) +if (!m || m->state ==NFT_PIPAPO_CLONE_ERR )return NULL ; e = pipapo_get(m, (const u8 *)elem->key.val.data,
net/netfilter/nft_set_pipapo.h +8 -0
@@ -131,9 +131,16 @@ struct nft_pipapo_scratch {unsigned long __map[]; }; +enum nft_pipapo_clone_state { +NFT_PIPAPO_CLONE_NEW , +NFT_PIPAPO_CLONE_MOD , +NFT_PIPAPO_CLONE_ERR , +}; +/** * struct nft_pipapo_match - Data used for lookup and matching * @field_count: Amount of fields in set +* @state: add/delete state; used from control plane * @bsize_max: Maximum lookup table bucket size of all fields, in longs * @scratch: Preallocated per-CPU maps for partial matching results * @rcu: Matching data is swapped on commits
@@ -141,6 +148,7 @@ struct nft_pipapo_scratch {*/ struct nft_pipapo_match {u8 field_count; +enum nft_pipapo_clone_state state:8 ;unsigned int bsize_max;struct nft_pipapo_scratch *__percpu *scratch;struct rcu_head rcu;
Greg Kroah-Hartman
maintainerPATCH 1608/2077 netfilter: nf_nat_sip: reload possible stale data pointer
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit 77e43bcb7ec177e293a5c3f1b91a2c5aebfb6c68 upstream.
quoting sashiko:
------------------------------------------------------------------------
[..] noticed a potential memory bug and header corruption involving the SIP NAT helper.
In net/netfilter/nf_nat_sip.c:nf_nat_sip():
if (skb_ensure_writable(skb, skb->len)) {
nf_ct_helper_log(skb, ct, "cannot mangle packet");
return NF_DROP;
}
uh = (void *)skb->data + protoff;
uh->dest = ct_sip_info->forced_dport;
if (!nf_nat_mangle_udp_packet(skb, ct, ctinfo, protoff,
0, 0, NULL, 0)) { If a cloned or fragmented SKB is reallocated by skb_ensure_writable(), the old data buffer is freed. However, nf_nat_sip() fails to update *dptr to point to the new buffer.
It also appears to use nf_nat_mangle_udp_packet() on what could be a TCP packet, which would overwrite the sequence number with a checksum update.
------------------------------------------------------------------------
nf_conntrack_sip linerizes skbs, hence no fragmented skb can be seen. But clones are possible, so rebuild dptr.
Disable nf_nat_mangle_udp_packet() branch for TCP streams. It doesn't look like this can ever happen, else we should have received bug reports about this, so just check the conntrack is UDP and drop otherwise.
The calling conntrack_sip set ->forced_dport for SIP_HDR_VIA_UDP messages, so I don't think this is ever expected to be true for a TCP stream.
--- net/netfilter/nf_nat_sip.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/netfilter/nf_nat_sip.c +11 -0
@@ -289,13 +289,24 @@ next:/* Mangle destination port for Cisco phones, then fix up checksums */ if (dir ==IP_CT_DIR_REPLY && ct_sip_info->forced_dport) { +int doff = *dptr - (const char *)skb->data;struct udphdr *uh; +if (doff <=0 ) { +DEBUG_NET_WARN_ON_ONCE (1 ); +return NF_DROP ; + } + +/* ct_sip_info->forced_dport only expected with UDP */ +if (nf_ct_protonum (ct) !=IPPROTO_UDP ) +return NF_DROP ; +if (skb_ensure_writable (skb, skb->len)) {nf_ct_helper_log (skb, ct,"cannot mangle packet" );return NF_DROP ; } + *dptr = skb->data + doff; uh = (void *)skb->data + protoff; uh->dest = ct_sip_info->forced_dport;
Greg Kroah-Hartman
maintainerPATCH 1609/2077 netfilter: nf_conntrack_reasm: guard mac_header adjustment after IPv6 defrag
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 3b08fed5b7e0d5e3a25d73ef3ba09cd33ade16c9 upstream.
nf_ct_frag6_reasm() slides the packet head forward to drop the IPv6 fragment header and then unconditionally advances skb->mac_header:
skb->mac_header += sizeof(struct frag_hdr);
On the NF_INET_LOCAL_OUT defrag path the skb has no link-layer header yet, so skb->mac_header is still the "not set" sentinel (u16)~0U. Adding sizeof(struct frag_hdr) wraps it to a small value (0xffff + 8 == 7), after which skb_mac_header_was_set() wrongly reports a MAC header is present and skb_mac_header() points into the headroom.
The reassembler has done this unconditional add since it was introduced; it was harmless while mac_header was a bare pointer, but wrong once mac_header became a u16 offset whose unset state is the ~0U sentinel tested by skb_mac_header_was_set(). The sibling net/ipv6/reassembly.c does the same relocation and does guard the adjustment; mirror the guard here.
--- net/ipv6/netfilter/nf_conntrack_reasm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +2 -1
@@ -348,7 +348,8 @@ static int nf_ct_frag6_reasm(struct fragskb_network_header (skb)[fq->nhoffset] =skb_transport_header (skb)[0 ];memmove (skb->head +sizeof (struct frag_hdr ), skb->head, (skb->data - skb->head) -sizeof (struct frag_hdr )); - skb->mac_header +=sizeof (struct frag_hdr ); +if (skb_mac_header_was_set (skb)) + skb->mac_header +=sizeof (struct frag_hdr ); skb->network_header +=sizeof (struct frag_hdr );skb_reset_transport_header (skb);
Greg Kroah-Hartman
maintainerPATCH 1610/2077 netfilter: flowtable: use dst in this direction when pushing IPIP header
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit c328b90c17fc5fa7786503695152880b2afb9326 upstream.
When pushing the IPIP header, the route of the other direction is used to calculate the headroom, use the route in this direction. Accessing the other tuple to set the IP source and destination is fine because this tuple does not provide such information to avoid storing redundant information. However, this tuple already provides the dst for this direction, this went unnoticed because this bug affects headroom and iph->frag_off only at this stage.
--- net/netfilter/nf_flow_table_ip.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
net/netfilter/nf_flow_table_ip.c +11 -7
@@ -590,10 +590,10 @@ static int nf_flow_pppoe_push(struct sk_buff *skb, u16 id,static int nf_flow_tunnel_ipip_push (struct net *net,struct sk_buff *skb,struct flow_offload_tuple *tuple, -__be32 *ip_daddr) +struct dst_entry *dst,__be32 *ip_daddr) {struct iphdr *iph = (struct iphdr *)skb_network_header (skb); -struct rtable *rt =dst_rtable (tuple->dst_cache); +struct rtable *rt =dst_rtable (dst);u8 tos = iph->tos, ttl = iph->ttl;__be16 frag_off = iph->frag_off;u32 headroom =sizeof (*iph);
@@ -636,21 +636,22 @@ static int nf_flow_tunnel_ipip_push(struct net *net, struct sk_buff *skb,static int nf_flow_tunnel_v4_push (struct net *net,struct sk_buff *skb,struct flow_offload_tuple *tuple, -__be32 *ip_daddr) +struct dst_entry *dst,__be32 *ip_daddr) {if (tuple->tun_num) -return nf_flow_tunnel_ipip_push (net, skb, tuple, ip_daddr); +return nf_flow_tunnel_ipip_push (net, skb, tuple, dst, ip_daddr);return 0 ; }static int nf_flow_tunnel_ip6ip6_push (struct net *net,struct sk_buff *skb,struct flow_offload_tuple *tuple, +struct dst_entry *dst,struct in6_addr **ip6_daddr) {struct ipv6hdr *ip6h = (struct ipv6hdr *)skb_network_header (skb); -struct rtable *rt =dst_rtable (tuple->dst_cache);__u8 dsfield =ipv6_get_dsfield (ip6h); +struct rtable *rt =dst_rtable (dst);struct flowi6 fl6 = { .daddr = tuple->tun.src_v6, .saddr = tuple->tun.dst_v6,
@@ -696,10 +697,11 @@ static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb,static int nf_flow_tunnel_v6_push (struct net *net,struct sk_buff *skb,struct flow_offload_tuple *tuple, +struct dst_entry *dst,struct in6_addr **ip6_daddr) {if (tuple->tun_num) -return nf_flow_tunnel_ip6ip6_push (net, skb, tuple, ip6_daddr); +return nf_flow_tunnel_ip6ip6_push (net, skb, tuple, dst, ip6_daddr);return 0 ; }
@@ -842,7 +844,8 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, other_tuple = &flow->tuplehash[!dir].tuple; ip_daddr = other_tuple->src_v4.s_addr; -if (nf_flow_tunnel_v4_push (state->net, skb, other_tuple, &ip_daddr) <0 ) +if (nf_flow_tunnel_v4_push (state->net, skb, other_tuple, + tuplehash->tuple.dst_cache, &ip_daddr) <0 )return NF_DROP ;switch (tuplehash->tuple.xmit_type) {
@@ -1158,6 +1161,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, ip6_daddr = &other_tuple->src_v6;if (nf_flow_tunnel_v6_push (state->net, skb, other_tuple, + tuplehash->tuple.dst_cache, &ip6_daddr) <0 )return NF_DROP ;
Signature · 1 line
2.55.0
Greg Kroah-Hartman
maintainerPATCH 1611/2077 netfilter: flowtable: support IPIP tunnel with direct xmit
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit fa7395c02d95e51bad2952325d2d6503bfbad437 upstream.
The combination of IPIP tunnel with direct xmit, eg. bridge device, breaks because no dst_entry is provided to check the skb headroom and to set the iph->frag_off field. This leads to invalid dst usage and can trigger a crash in the tunnel transmit path.
Fix this by moving dst_cache and dst_cookie out of the runtime union so that they can be shared by neighbour, xfrm, and direct tunnel flows. For FLOW_OFFLOAD_XMIT_DIRECT tuples carrying tunnel metadata, preserve route state in these shared fields and release it through the common dst release path.
Since dst_entry is now available to the three supported xmit modes and dst_release() already deals with NULL dst, remove the xmit type check in nft_flow_dst_release(). Moreover, skip the check if the dst entry is NULL in nf_flow_dst_check() which is now the case for the direct xmit case.
Based on patch from Rein Wei <[email protected]>.
--- include/net/netfilter/nf_flow_table.h | 5 +++-- net/netfilter/nf_flow_table_core.c | 12 ++++++++---- net/netfilter/nf_flow_table_ip.c | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-)
include/net/netfilter/nf_flow_table.h +3 -2
@@ -155,11 +155,12 @@ struct flow_offload_tuple { tun_num:2 , in_vlan_ingress:2;u16 mtu; +u32 dst_cookie; +struct dst_entry *dst_cache; +union {struct { -struct dst_entry *dst_cache;u32 ifidx; -u32 dst_cookie; };struct {u32 ifidx;
net/netfilter/nf_flow_table_core.c +8 -4
@@ -127,12 +127,18 @@ static int flow_offload_fill_route(strucswitch (route->tuple[dir].xmit_type) {case FLOW_OFFLOAD_XMIT_DIRECT : +if (flow_tuple->tun_num) { + flow_tuple->dst_cache = dst; + flow_tuple->dst_cookie = +flow_offload_dst_cookie (flow_tuple); + }memcpy (flow_tuple->out.h_dest, route->tuple[dir].out.h_dest,ETH_ALEN );memcpy (flow_tuple->out.h_source, route->tuple[dir].out.h_source,ETH_ALEN ); flow_tuple->out.ifidx = route->tuple[dir].out.ifindex; -dst_release (dst); +if (!flow_tuple->tun_num) +dst_release (dst);break ;case FLOW_OFFLOAD_XMIT_XFRM :case FLOW_OFFLOAD_XMIT_NEIGH :
@@ -152,9 +158,7 @@ static int flow_offload_fill_route(strucstatic void nft_flow_dst_release (struct flow_offload *flow,enum flow_offload_tuple_dir dir) { -if (flow->tuplehash[dir].tuple.xmit_type ==FLOW_OFFLOAD_XMIT_NEIGH || - flow->tuplehash[dir].tuple.xmit_type ==FLOW_OFFLOAD_XMIT_XFRM ) -dst_release (flow->tuplehash[dir].tuple.dst_cache); +dst_release (flow->tuplehash[dir].tuple.dst_cache); } void flow_offload_route_init(struct flow_offload *flow,
net/netfilter/nf_flow_table_ip.c +1 -2
@@ -299,8 +299,7 @@ static bool nf_flow_exceeds_mtu(const ststatic inline bool nf_flow_dst_check (struct flow_offload_tuple *tuple) { -if (tuple->xmit_type !=FLOW_OFFLOAD_XMIT_NEIGH && - tuple->xmit_type !=FLOW_OFFLOAD_XMIT_XFRM ) +if (!tuple->dst_cache)return true;return dst_check (tuple->dst_cache, tuple->dst_cookie);
Greg Kroah-Hartman
maintainerPATCH 1612/2077 netfilter: nf_conncount: fix zone comparison in tuple dedup
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
commit f62c41b4910e65da396ec9a8c40c1fe7fe82e449 upstream.
The "already exists" dedup logic in __nf_conncount_add() decides whether a connection has already been counted and can be skipped instead of incrementing the connlimit count. It compares the conntrack zone of a list entry with the zone of the connection being added using nf_ct_zone_id() and nf_ct_zone_equal(), passing conn->zone.dir or zone->dir as the direction argument.
Those helpers take enum ip_conntrack_dir values: IP_CT_DIR_ORIGINAL is 0 and IP_CT_DIR_REPLY is 1. However, zone->dir is a u8 bitmask:NF_CT_ZONE_DIR_ORIG is 1, NF_CT_ZONE_DIR_REPL is 2 and NF_CT_DEFAULT_ZONE_DIR is 3. Passing that bitmask as the enum direction shifts the meaning of every non-zero value. An ORIG-only zone passes 1 and is tested as REPLY, while REPL-only and default zones pass 2 or 3 and test bits beyond the valid direction range. In those cases nf_ct_zone_id() can fall back to NF_CT_DEFAULT_ZONE_ID instead of using the real zone id, so different zones can be treated as equal and dedup collapses to tuple equality alone.
nf_conncount stores and compares the original-direction tuple for a connection. If an skb already has an attached conntrack entry, get_ct_or_tuple_from_skb() explicitly copies ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, regardless of the packet's ctinfo. Therefore the zone comparison in the tuple dedup path must use IP_CT_DIR_ORIGINAL as well; the zone direction bitmask describes where a zone id applies, not which direction this conncount tuple represents.
Fix the two dedup comparisons by passing IP_CT_DIR_ORIGINAL directly. Do not special-case NF_CT_DEFAULT_ZONE_DIR and do not compare raw zone
ids: using the existing helpers with IP_CT_DIR_ORIGINAL preserves the direction-aware NF_CT_DEFAULT_ZONE_ID fallback. A default bidirectional zone contains the ORIG bit, so it naturally returns the real zone id; reply-only zones continue to fall back for original-direction tuple comparisons.
--- net/netfilter/nf_conncount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conncount.c +3 -3
@@ -207,8 +207,8 @@ check_connections:/* Not found, but might be about to be confirmed */ if (PTR_ERR (found) == -EAGAIN ) {if (nf_ct_tuple_equal (&conn->tuple, &tuple) && -nf_ct_zone_id (&conn->zone, conn->zone.dir) == -nf_ct_zone_id (zone, zone->dir)) +nf_ct_zone_id (&conn->zone,IP_CT_DIR_ORIGINAL ) == +nf_ct_zone_id (zone,IP_CT_DIR_ORIGINAL )) goto out_put;/* already exists */ }else { collect++;
@@ -219,7 +219,7 @@ check_connections: found_ct =nf_ct_tuplehash_to_ctrack (found);if (nf_ct_tuple_equal (&conn->tuple, &tuple) && -nf_ct_zone_equal (found_ct, zone, zone->dir)) { +nf_ct_zone_equal (found_ct, zone,IP_CT_DIR_ORIGINAL )) {/* * We should not see tuples twice unless someone hooks * this into a table without "-p tcp --syn".
Greg Kroah-Hartman
maintainerPATCH 1613/2077 netfilter: xt_physdev: masks are not c-strings
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit f468c48d488d0ea2df3422b3e1dfafae1611e853 upstream.
... and must not be subjected to the 'nul terminated' constraint. If the interface name is 15 characters long, the mask is 16-bytes '0xff' (to cover for \0) and the valid device name is rejected.
--- net/netfilter/xt_physdev.c | 5 ----- 1 file changed, 5 deletions(-)
net/netfilter/xt_physdev.c +0 -5
@@ -130,11 +130,6 @@ static int physdev_mt_check(const structif (X (physoutdev))return -ENAMETOOLONG ; } - -if (X (in_mask)) -return -ENAMETOOLONG ; -if (X (out_mask)) -return -ENAMETOOLONG ;#undef Xif (!brnf_probed) {
Greg Kroah-Hartman
maintainerPATCH 1614/2077 netfilter: ecache: fix inverted time_after() check
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yizhou Zhao <[email protected]>
commit b06163ce52ec0561f202fbfb9b08090cb61f512e upstream.
ecache_work_evict_list() redelivers DESTROY events for conntracks that were moved to the per-netns dying_list after event delivery failed. It sets a 10ms deadline:
stop = jiffies + ECACHE_MAX_JIFFIES
but then tests:
time_after(stop, jiffies)
This condition is true while the deadline is still in the future, so the worker returns STATE_RESTART after the first successful redelivery in the usual case. ecache_work() maps STATE_RESTART to delay 0, which turns the redelivery path into one dying conntrack per workqueue dispatch and makes the sent > 16 batching/cond_resched() path effectively unreachable.
A conntrack netlink listener whose receive queue is congested can make DESTROY event delivery fail with -ENOBUFS. With sustained conntrack churn, entries then accumulate on the dying_list and are only drained at the degraded one-entry-per-dispatch rate once delivery succeeds again, wasting CPU on back-to-back workqueue reschedules and prolonging conntrack memory/resource pressure.
In a KASAN QEMU test with CONFIG_NF_CONNTRACK_EVENTS=y and nf_conntrack.enable_hooks=1, a congested DESTROY listener caused 8192 nf_ct_delete() calls to return false and move entries to the dying_list. After closing the listener, the unfixed kernel needed 7670 ecache_work() entries to destroy 7669 conntracks. With this change, the same 8192 entries were destroyed by 2 ecache_work() entries.
Swap the comparison so the worker restarts only after the deadline has expired.
--- net/netfilter/nf_conntrack_ecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_ecache.c +1 -1
@@ -77,7 +77,7 @@ next:hlist_nulls_del_rcu (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].hnnode);hlist_nulls_add_head (&ct->tuplehash[IP_CT_DIR_REPLY ].hnnode, &evicted_list); -if (time_after (stop, jiffies)) { +if (time_after (jiffies, stop)) { ret =STATE_RESTART ;break ; }
Greg Kroah-Hartman
maintainerPATCH 1615/2077 netfilter: xt_nat: reject unsupported target families
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wyatt Feng <[email protected]>
commit 5d1a2240935ea47e2673d0ea17fdb058e4dc91dd upstream.
xt_nat SNAT and DNAT target handlers assume IP-family conntrack state is present and can dereference a NULL pointer when instantiated from an unsupported family through nft_compat. A bridge-family compat rule can therefore trigger a NULL-dereference in nf_nat_setup_info().
Reject non-IP families in xt_nat_checkentry() so unsupported targets cannot be installed. Keep NFPROTO_INET allowed for valid inet NAT compat users and leave the runtime fast path unchanged.
[ The crash was fixed via
9dbba7e694ec ("netfilter: nft_compat: ebtables emulation must reject non-bridge targets"), so this patch is no longer critical.
Nevertheless, NAT is only relevant for ipv4/ipv6, so this extra
family check is a good idea in any case. ]
--- net/netfilter/xt_nat.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/netfilter/xt_nat.c +9 -0
@@ -26,6 +26,15 @@ static int xt_nat_checkentry_v0(const ststatic int xt_nat_checkentry (const struct xt_tgchk_param *par) { +switch (par->family) { +case NFPROTO_IPV4 : +case NFPROTO_IPV6 : +case NFPROTO_INET : +break ; +default : +return -EINVAL ; + } +return nf_ct_netns_get (par->net, par->family); }
Greg Kroah-Hartman
maintainerPATCH 1616/2077 netfilter: bridge: fix stale prevhdr pointer in br_ip6_fragment()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei (Microsoft) <[email protected]>
commit 86f3ce81dd2b4b0aa2c3016c989a943e4b1b643d upstream.
br_ip6_fragment() gets prevhdr, a pointer into the skb head, from ip6_find_1stfragopt(), then calls skb_checksum_help(). For a cloned skb skb_checksum_help() reallocates the head via pskb_expand_head(), leaving prevhdr dangling. It is later dereferenced in ip6_frag_next(), causing a use-after-free write.
Save prevhdr's offset before skb_checksum_help() and recompute it after, like commit ef0efcd3bd3f ("ipv6: Fix dangling pointer when ipv6 fragment").
BUG: KASAN: slab-use-after-free in ip6_frag_next (net/ipv6/ip6_output.c:857) Write of size 1 at addr ffff888013ff5016 by task exploit/141 Call Trace: ... kasan_report (mm/kasan/report.c:595) ip6_frag_next (net/ipv6/ip6_output.c:857) br_ip6_fragment (net/ipv6/netfilter.c:212) nf_ct_bridge_post (net/bridge/netfilter/nf_conntrack_bridge.c:407) nf_hook_slow (net/netfilter/core.c:619) br_forward_finish (net/bridge/br_forward.c:66) __br_forward (net/bridge/br_forward.c:115) maybe_deliver (net/bridge/br_forward.c:191) br_flood (net/bridge/br_forward.c:245) br_handle_frame_finish (net/bridge/br_input.c:229) br_handle_frame (net/bridge/br_input.c:442) ... packet_sendmsg (net/packet/af_packet.c:3114) ... do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception in interrupt
--- net/ipv6/netfilter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/netfilter.c +3 -1
@@ -120,7 +120,7 @@ int br_ip6_fragment(struct net *net, strktime_t tstamp = skb->tstamp;struct ip6_frag_state state;u8 *prevhdr, nexthdr =0 ; -unsigned int mtu, hlen; +unsigned int mtu, hlen, nexthdr_offset;int hroom, err =0 ;__be32 frag_id;
@@ -129,6 +129,7 @@ int br_ip6_fragment(struct net *net, str goto blackhole; hlen = err; nexthdr = *prevhdr; + nexthdr_offset = prevhdr -skb_network_header (skb); mtu = skb->dev->mtu; if (frag_max_size > mtu ||
@@ -147,6 +148,7 @@ int br_ip6_fragment(struct net *net, str (err = skb_checksum_help(skb))) goto blackhole; + prevhdr =skb_network_header (skb) + nexthdr_offset; hroom =LL_RESERVED_SPACE (skb->dev);if (skb_has_frag_list (skb)) {unsigned int first_len =skb_pagelen (skb);
Greg Kroah-Hartman
maintainerPATCH 1617/2077 netfilter: flowtable: use correct direction to set up tunnel route
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 90941d9c925d66a482c9121919ec3546a6988c16 upstream.
The layer 2 encapsulation and layer 3 tunnel information in the xmit path is taken from the other tuple, because the tunnel information that is included in the tuple for hashtable lookups is also used to perform the egress encapsulation in the transmit path.
This patch uses the correct direction when setting up the tunnel, the original proposed patch to address this fix uses the reversed direction.
While at it, remove the redundant check to call dst_release() to drop the reference on the dst that was obtained from the forward path, which is not useful in the direct xmit path unless tunneling is performed.
--- net/netfilter/nf_flow_table_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_core.c +3 -3
@@ -127,18 +127,18 @@ static int flow_offload_fill_route(strucswitch (route->tuple[dir].xmit_type) {case FLOW_OFFLOAD_XMIT_DIRECT : -if (flow_tuple->tun_num) { +if (route->tuple[!dir].in.num_tuns) { flow_tuple->dst_cache = dst; flow_tuple->dst_cookie =flow_offload_dst_cookie (flow_tuple); + }else { +dst_release (dst); }memcpy (flow_tuple->out.h_dest, route->tuple[dir].out.h_dest,ETH_ALEN );memcpy (flow_tuple->out.h_source, route->tuple[dir].out.h_source,ETH_ALEN ); flow_tuple->out.ifidx = route->tuple[dir].out.ifindex; -if (!flow_tuple->tun_num) -dst_release (dst);break ;case FLOW_OFFLOAD_XMIT_XFRM :case FLOW_OFFLOAD_XMIT_NEIGH :
Greg Kroah-Hartman
maintainerPATCH 1618/2077 gpu: nova-core: simplify and_then with condition to filter
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eliot Courtney <[email protected]>
commit 16df3873c80388a71c4695909a51be0c809b889c upstream.
This code is more simply expressed using Option::filter instead of the and_then with conditional.
This fixes the following warning with latest nightly Rust clippy build:
warning: manual implementation of Option::filter
--> drivers/gpu/nova-core/firmware.rs:391:14
|
391 | .and_then(|hdr| {
| ______________^
392 | | if hdr.bin_magic == BIN_MAGIC {
393 | | Some(hdr)
394 | | } else {
... |
397 | | })
| |______________^ help: try: `filter(|hdr| hdr.bin_magic == BIN_MAGIC)` |
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter
= note: -D clippy::manual-filter implied by -D warnings
= help: to override -D warnings add #[allow(clippy::manual_filter)]
--- drivers/gpu/nova-core/firmware.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/nova-core/firmware.rs +1 -7
@@ -388,13 +388,7 @@ impl<'a> BinFirmware<'a> {// Extract header. .and_then(BinHdr::from_bytes_copy)// Validate header. - .and_then (|hdr| { -if hdr.bin_magic ==BIN_MAGIC { -Some (hdr) - }else { -None - } - }) + .filter (|hdr| hdr.bin_magic ==BIN_MAGIC ) .map (|hdr|Self { hdr, fw }) .ok_or (EINVAL ) }
Greg Kroah-Hartman
maintainerPATCH 1619/2077 gpu: host1x: Fix device reference leak in host1x_device_parse_dt() error path
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit e75717f9aec04355777be41070890c6a815c76df upstream.
After device_initialize(), the embedded struct device in struct host1x_device should be released through the device core with put_device().
In host1x_device_add(), if host1x_device_parse_dt() fails, the current error path frees the object directly with kfree(device). That bypasses the normal device lifetime handling and leaks the reference held on the embedded struct device.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
Fix this by using put_device() in the host1x_device_parse_dt() failure path.
--- drivers/gpu/host1x/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/host1x/bus.c +1 -1
@@ -485,7 +485,7 @@ static int host1x_device_add(struct host err =host1x_device_parse_dt (device, driver);if (err <0 ) { -kfree (device); +put_device (&device->dev);return err; }
Greg Kroah-Hartman
maintainerPATCH 1620/2077 gpu/buddy: bail out of try_harder when alignment cannot be honoured
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arunpravin Paneer Selvam <[email protected]>
commit 56bc6384314fb9ae98975fb2af8b143097ede3dc upstream.
The try_harder contiguous fallback could return a range whose start offset did not match the caller's min_block_size. When a candidate's start is misaligned, realign it: free the misaligned run and reallocate exactly @size at the next lower min_block_size boundary. This keeps the returned size unchanged with no surplus to trim, and rejects the request only when no aligned candidate fits.
v2: align misaligned candidates down to min_block_size instead of
bailing out, for both the RHS and LHS paths (Matthew).
--- drivers/gpu/buddy.c | 65 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 20 deletions(-)
drivers/gpu/buddy.c +45 -20
@@ -1078,22 +1078,30 @@ static int __gpu_buddy_alloc_range(struc blocks, total_allocated_on_err); } +static int __alloc_contig_aligned_retry (struct gpu_buddy *mm, +u64 unaligned_offset, +u64 size, +u64 min_block_size, +struct list_head *blocks) +{ +u64 aligned_offset =round_down (unaligned_offset, min_block_size); + +return __gpu_buddy_alloc_range (mm, aligned_offset, size,NULL , blocks); +} +static int __alloc_contig_try_harder (struct gpu_buddy *mm,u64 size,u64 min_block_size,struct list_head *blocks) { -u64 rhs_offset, lhs_offset, lhs_size, filled; +u64 rhs_offset, lhs_offset, filled;struct gpu_buddy_block *block;unsigned int tree, order; -LIST_HEAD (blocks_lhs); -unsigned long pages;u64 modify_size;int err; modify_size =rounddown_pow_of_two (size); - pages = modify_size >>ilog2 (mm->chunk_size); - order =fls (pages) -1 ; + order =ilog2 (modify_size) -ilog2 (mm->chunk_size);if (order ==0 )return -ENOSPC ;
@@ -1109,31 +1117,48 @@ static int __alloc_contig_try_harder(strwhile (iter) { block =rbtree_get_free_block (iter); -/* Allocate blocks traversing RHS */ rhs_offset =gpu_buddy_block_offset (block); + +/* Allocate blocks traversing RHS */ err =__gpu_buddy_alloc_range (mm, rhs_offset, size, &filled, blocks); -if (!err || err != -ENOSPC ) +if (err && err != -ENOSPC )return err; - - lhs_size =max ((size - filled), min_block_size); -if (!IS_ALIGNED (lhs_size, min_block_size)) - lhs_size =round_up (lhs_size, min_block_size); - -/* Allocate blocks traversing LHS */ - lhs_offset =gpu_buddy_block_offset (block) - lhs_size; - err =__gpu_buddy_alloc_range (mm, lhs_offset, lhs_size, -NULL , &blocks_lhs); +if (!err &&IS_ALIGNED (rhs_offset, min_block_size)) +return 0 ;if (!err) { -list_splice (&blocks_lhs, blocks); +/* Allocate the unaligned RHS offset using round_down */ +gpu_buddy_free_list_internal (mm, blocks); + err =__alloc_contig_aligned_retry (mm, rhs_offset, + size, + min_block_size, + blocks); +if (!err) +return 0 ; +if (err != -ENOSPC ) { +gpu_buddy_free_list_internal (mm, blocks); +return err; + } + goto next; + } + +if (size - filled > rhs_offset) + goto next; + + lhs_offset = rhs_offset - (size - filled); + +/* Allocate the unaligned LHS offset using round_down */ +gpu_buddy_free_list_internal (mm, blocks); + err =__alloc_contig_aligned_retry (mm, lhs_offset, size, + min_block_size, blocks); +if (!err)return 0 ; - }else if (err != -ENOSPC ) { +if (err != -ENOSPC ) {gpu_buddy_free_list_internal (mm, blocks);return err; } -/* Free blocks for the next iteration */ +next:gpu_buddy_free_list_internal (mm, blocks); - iter =rb_prev (iter); } }
Greg Kroah-Hartman
maintainerPATCH 1621/2077 soc: ti: k3-ringacc: Fix access mode for k3_ringacc_ring_pop_tail_io/proxy
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Vadapalli <[email protected]>
commit b920352cfd2b0fcd1249ff006618c939b64fc8f7 upstream.
k3_ringacc_ring_pop_tail_io() and k3_ringacc_ring_pop_tail_proxy() incorrectly use K3_RINGACC_ACCESS_MODE_POP_HEAD instead of K3_RINGACC_ACCESS_MODE_POP_TAIL. This will result in ring elements being popped in the reverse order of that which the caller expects. Fix this.
--- drivers/soc/ti/k3-ringacc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/ti/k3-ringacc.c +2 -2
@@ -1012,7 +1012,7 @@ static int k3_ringacc_ring_pop_head_proxstatic int k3_ringacc_ring_pop_tail_proxy (struct k3_ring *ring,void *elem) {return k3_ringacc_ring_access_proxy (ring, elem, -K3_RINGACC_ACCESS_MODE_POP_HEAD ); +K3_RINGACC_ACCESS_MODE_POP_TAIL ); } static int k3_ringacc_ring_access_io(struct k3_ring *ring, void *elem,
@@ -1083,7 +1083,7 @@ static int k3_ringacc_ring_pop_io(structstatic int k3_ringacc_ring_pop_tail_io (struct k3_ring *ring,void *elem) {return k3_ringacc_ring_access_io (ring, elem, -K3_RINGACC_ACCESS_MODE_POP_HEAD ); +K3_RINGACC_ACCESS_MODE_POP_TAIL ); }/*
Greg Kroah-Hartman
maintainerPATCH 1622/2077 soc: fsl: qe: panic on ioremap() failure in qe_reset()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jun <[email protected]>
commit a0fe29d20e7822182e12324905af5115c1b3aed3 upstream.
When ioremap() fails in qe_reset(), the global pointer qe_immr remains NULL, leading to a subsequent NULL pointer dereference when the pointer is accessed. Since this happens early in the boot process, a failure to map a few bytes of I/O memory indicates a fatal error from which the system cannot recover.
Follow the same pattern as qe_sdma_init() and panic immediately when ioremap() fails. This avoids a silent NULL pointer dereference later and makes the error explicit.
--- drivers/soc/fsl/qe/qe.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/soc/fsl/qe/qe.c +3 -0
@@ -89,6 +89,9 @@ void qe_reset(void)if (qe_immr ==NULL ) qe_immr =ioremap (get_qe_base (),QE_IMMAP_SIZE ); +if (!qe_immr) +panic ("QE:ioremap failed!" ); +qe_snums_init (); qe_issue_cmd(QE_RESET, QE_CR_SUBBLOCK_INVALID,
Greg Kroah-Hartman
maintainerPATCH 1623/2077 selinux: check connect-related permissions on TCP Fast Open
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Smalley <[email protected]>
commit 44c74d27d1b9aaa99fa8a83640c1223575262b80 upstream.
Similar to Landlock, SELinux was not updated when TCP Fast Open support was introduced to ensure connect-related permissions are checked when using TCP Fast Open. Update its socket_sendmsg() hook to call selinux_socket_connect() when MSG_FASTOPEN is passed.
--- security/selinux/hooks.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
security/selinux/hooks.c +18 -1
@@ -5266,7 +5266,24 @@ static int selinux_socket_accept(structstatic int selinux_socket_sendmsg (struct socket *sock,struct msghdr *msg,int size) { -return sock_has_perm (sock->sk,SOCKET__WRITE ); +int rc; +struct sockaddr *const addr = msg->msg_name; +const int addrlen = msg->msg_namelen; + + rc =sock_has_perm (sock->sk,SOCKET__WRITE ); +if (rc) +return rc; + +if (addr && (msg->msg_flags &MSG_FASTOPEN ) && + (sk_is_tcp (sock->sk) || + (sk_is_inet (sock->sk) && sock->sk->sk_type ==SOCK_STREAM && + sock->sk->sk_protocol ==IPPROTO_MPTCP ))) { + rc =selinux_socket_connect (sock, addr, addrlen); +if (rc) +return rc; + } + +return 0 ; } static int selinux_socket_recvmsg(struct socket *sock, struct msghdr *msg,
Greg Kroah-Hartman
maintainerPATCH 1624/2077 selinux: avoid sk_socket dereference in selinux_sctp_bind_connect()
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 56acfeb10019e200ab6787d01f8d7cbe0f01526f upstream.
selinux_sctp_bind_connect() dereferences sk->sk_socket to pass a struct socket * to selinux_socket_bind() and selinux_socket_connect_helper(). However, when the hook is invoked from the ASCONF softirq path (sctp_process_asconf), there is no file reference guaranteeing that sk->sk_socket is non-NULL. The setsockopt callers (bindx, connectx, set_primary, sendmsg connect) hold a file reference and are not affected.
Both selinux_socket_bind() and selinux_socket_connect_helper() immediately resolve sock->sk, never using the struct socket * for anything else. Refactor the inner logic into helpers that take a struct sock * directly so that selinux_sctp_bind_connect() never needs to touch sk->sk_socket at all.
--- security/selinux/hooks.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
security/selinux/hooks.c +10 -9
@@ -4998,9 +4998,8 @@ static int selinux_socket_socketpair(strNeed to determine whether we should perform a name_bind permission check between the socket and the port number. */ -static int selinux_socket_bind (struct socket *sock,struct sockaddr *address,int addrlen) +static int __selinux_socket_bind (struct sock *sk,struct sockaddr *address,int addrlen) { -struct sock *sk = sock->sk;struct sk_security_struct *sksec =selinux_sock (sk);u16 family;int err;
@@ -5130,13 +5129,17 @@ err_af:return -EAFNOSUPPORT ; } +static int selinux_socket_bind (struct socket *sock,struct sockaddr *address,int addrlen) +{ +return __selinux_socket_bind (sock->sk, address, addrlen); +} +/* This supports connect(2) and SCTP connect services such as sctp_connectx(3) * and sctp_sendmsg(3) as described in Documentation/security/SCTP.rst */ -static int selinux_socket_connect_helper (struct socket *sock, +static int selinux_socket_connect_helper (struct sock *sk,struct sockaddr *address,int addrlen) { -struct sock *sk = sock->sk;struct sk_security_struct *sksec =selinux_sock (sk);int err;
@@ -5225,7 +5228,7 @@ static int selinux_socket_connect(structint err;struct sock *sk = sock->sk; - err =selinux_socket_connect_helper (sock, address, addrlen); + err =selinux_socket_connect_helper (sk, address, addrlen);if (err)return err;
@@ -5727,13 +5730,11 @@ static int selinux_sctp_bind_connect(strint len, err =0 , walk_size =0 ;void *addr_buf;struct sockaddr *addr; -struct socket *sock;if (!selinux_policycap_extsockclass ())return 0 ;/* Process one or more addresses that may be IPv4 or IPv6 */ - sock = sk->sk_socket; addr_buf = address;while (walk_size < addrlen) {
@@ -5762,14 +5763,14 @@ static int selinux_sctp_bind_connect(strcase SCTP_PRIMARY_ADDR :case SCTP_SET_PEER_PRIMARY_ADDR :case SCTP_SOCKOPT_BINDX_ADD : - err =selinux_socket_bind (sock, addr, len); + err =__selinux_socket_bind (sk, addr, len);break ;/* Connect checks */ case SCTP_SOCKOPT_CONNECTX :case SCTP_PARAM_SET_PRIMARY :case SCTP_PARAM_ADD_IP :case SCTP_SENDMSG_CONNECT : - err =selinux_socket_connect_helper (sock, addr, len); + err =selinux_socket_connect_helper (sk, addr, len);if (err)return err;
Greg Kroah-Hartman
maintainerPATCH 1625/2077 selinux: fix incorrect execmem checks on overlayfs
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit 9fe595fad54d4ac6a402edb3f60bec859d52cea6 upstream.
The commit fixing the overlayfs mmap() and mprotect() access checks failed to skip the execmem check in __file_map_prot_check() for the case where the "mounter check" is being performed. This check should be performed only against the credentials of the task that is calling mmap()/mprotect(), since it doesn't pertain to the file itself, but rather just gates the ability of the calling task to get an executable memory mapping in general.
The purpose of the "mounter check" is to guard against using an overlayfs mount to gain file access that would otherwise be denied to the mounter. For execmem this is not relevant, as there is no further file access granted based on it (notice that the file's context is not used as the target in the check), so checking it also against the mounter credentials would be incorrect.
Fix this by passing a boolean to [__]file_map_prot_check() and selinux_mmap_file_common() that indicates if we are doing the "mounter check" and skiping the execmem check in that case. Since this boolean also indicates if we use current_cred() or the mounter cred as the subject, also remove the "cred" argument from these functions and determine it based on the boolean and the file struct.
--- security/selinux/hooks.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-)
security/selinux/hooks.c +24 -18
@@ -3973,9 +3973,9 @@ static int selinux_file_ioctl_compat(strstatic int default_noexec__ro_after_init ; -static int __file_map_prot_check (const struct cred *cred, -const struct file *file,unsigned long prot, -bool shared,bool bf_user_file) +static int __file_map_prot_check (const struct file *file,unsigned long prot, +bool shared,bool mounter_check, +bool bf_user_file) {struct inode *inode =NULL ;bool prot_exec = prot &PROT_EXEC ;
@@ -3988,10 +3988,10 @@ static int __file_map_prot_check(const s inode =file_inode (file); } -if (default_noexec && prot_exec && +if (!mounter_check && default_noexec && prot_exec && (!file ||IS_PRIVATE (inode) || (!shared && prot_write))) {int rc; -u32 sid =cred_sid (cred); +u32 sid =current_sid ();/* * We are making executable an anonymous mapping or a private
@@ -4004,6 +4004,8 @@ static int __file_map_prot_check(const s }if (file) { +const struct cred *cred = mounter_check ? + file->f_cred :current_cred ();/* "read" always possible, "write" only if shared */ u32 av =FILE__READ ;if (shared && prot_write)
@@ -4017,11 +4019,11 @@ static int __file_map_prot_check(const sreturn 0 ; } -static inline int file_map_prot_check (const struct cred *cred, -const struct file *file, -unsigned long prot,bool shared) +static inline int file_map_prot_check (const struct file *file, +unsigned long prot,bool shared, +bool mounter_check) { -return __file_map_prot_check (cred, file, prot, shared, false); +return __file_map_prot_check (file, prot, shared, mounter_check, false); }static int selinux_mmap_addr (unsigned long addr)
@@ -4037,12 +4039,14 @@ static int selinux_mmap_addr(unsigned loreturn rc; } -static int selinux_mmap_file_common (const struct cred *cred,struct file *file, -unsigned long prot,bool shared) +static int selinux_mmap_file_common (struct file *file,unsigned long prot, +bool shared,bool mounter_check) {if (file) {int rc;struct common_audit_data ad; +const struct cred *cred = mounter_check ? + file->f_cred :current_cred (); ad.type =LSM_AUDIT_DATA_FILE ; ad.u.file = file;
@@ -4051,15 +4055,16 @@ static int selinux_mmap_file_common(consreturn rc; } -return file_map_prot_check (cred, file, prot, shared); +return file_map_prot_check (file, prot, shared, mounter_check); }static int selinux_mmap_file (struct file *file,unsigned long reqprot__always_unused ,unsigned long prot,unsigned long flags) { -return selinux_mmap_file_common (current_cred (), file, prot, - (flags &MAP_TYPE ) ==MAP_SHARED ); +return selinux_mmap_file_common (file, prot, + (flags &MAP_TYPE ) ==MAP_SHARED , + false); }/**
@@ -4091,8 +4096,9 @@ static int selinux_mmap_backing_file(strif (vma->vm_flags &VM_EXEC ) prot |=PROT_EXEC ; -return selinux_mmap_file_common (backing_file->f_cred, backing_file, - prot, vma->vm_flags &VM_SHARED ); +return selinux_mmap_file_common (backing_file, prot, + vma->vm_flags &VM_SHARED , + true); } static int selinux_file_mprotect(struct vm_area_struct *vma,
@@ -4153,11 +4159,11 @@ static int selinux_file_mprotect(struct } } - rc =__file_map_prot_check (cred, file, prot, shared, backing_file); + rc =__file_map_prot_check (file, prot, shared, false, backing_file);if (rc)return rc;if (backing_file) { - rc =file_map_prot_check (file->f_cred, file, prot, shared); + rc =file_map_prot_check (file, prot, shared, true);if (rc)return rc; }
Greg Kroah-Hartman
maintainerPATCH 1626/2077 leds: uleds: Fix potential buffer overread
In reply to Greg Kroah-Hartman7.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Armin Wolf <[email protected]>
commit c19fe864f667afc49d1391d764e20b66555bcf7a upstream.
The name string supplied by userspace is not guaranteed to be null-terminated, so using strchr() on it might result in a buffer overread. The same thing will happen when said string is used by the LED class device.
Fix this by using strnchr() instead and explicitly check that the name string is properly null-terminated.
--- drivers/leds/uleds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/uleds.c +2 -1
@@ -102,7 +102,8 @@ static ssize_t uleds_write(struct file * name = udev->user_dev.name;if (!name[0 ] || !strcmp (name,"." ) || !strcmp (name,".." ) || -strchr (name,'/' )) { +strnchr (name,sizeof (udev->user_dev.name),'/' ) || + !strnchr (name,sizeof (udev->user_dev.name),'\0' )) { ret = -EINVAL ; goto out; }