6.1.189-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 889/982 veth: manage XDP program pointers during channel resize
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 7104a370714346b667712913dc16abf14bbc97ed ]
veth_set_channels() tears down XDP resources for removed RX queues without clearing rq->xdp_prog. If the program is then detached or replaced, those queues keep the old pointer after bpf_prog_put(). A later channel increase can re-enable NAPI and run the freed program.
BUG: unable to handle page fault for address: ffffc90000256048
Oops: Oops: 0000 [#1] SMP KASAN NOPTI
RIP: veth_xdp_rcv_skb (include/linux/filter.h:779
include/net/xdp.h:696 drivers/net/veth.c:820)
Call Trace:
veth_xdp_rcv (drivers/net/veth.c:941)
veth_poll (drivers/net/veth.c:986)
__napi_poll (net/core/dev.c:7787)
net_rx_action (net/core/dev.c:7850 net/core/dev.c:8007)
handle_softirqs (kernel/softirq.c:645)
Kernel panic - not syncing: Fatal exception in interrupt--- drivers/net/veth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/veth.c +2 -0
@@ -1015,6 +1015,7 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)for (i = start; i < end; i++) {struct veth_rq *rq = &priv->rq[i]; +rcu_assign_pointer (rq->xdp_prog, priv->_xdp_prog);napi_enable (&rq->xdp_napi);rcu_assign_pointer (priv->rq[i].napi, &priv->rq[i].xdp_napi); }
@@ -1043,6 +1044,7 @@ static void veth_napi_del_range(struct net_device *dev, int start, int end)rcu_assign_pointer (priv->rq[i].napi,NULL );napi_disable (&rq->xdp_napi); +rcu_assign_pointer (rq->xdp_prog,NULL );__netif_napi_del (&rq->xdp_napi); }synchronize_net ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 890/982 net: skbuff: fix pull-bound underflow in skb_checksum_setup_ipv6()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shihuang Liu <[email protected]>
[ Upstream commit 3b4e0b0c008a8c1b474730248cd5b873026c74bd ]
skb_maybe_pull_tail() subtracts skb_headlen(skb) from the unsigned max argument and passes the result to __pskb_pull_tail() as a signed int. The function does not ensure that max is at least skb_headlen(skb).
This can happen while parsing IPv6 extension headers when an skb already has a linear area larger than MAX_IPV6_HDR_LEN. Once the parser needs data beyond the linear area, max - skb_headlen(skb) wraps and is converted to a negative delta. __pskb_pull_tail() then passes that negative length to skb_copy_bits(), where it can become a very large copy length.
Pass the requested length itself as the pull bound at the three extension-header call sites, so the delta can no longer go negative.
--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/skbuff.c +6 -3
@@ -5256,7 +5256,8 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate) err =skb_maybe_pull_tail (skb, off +sizeof (struct ipv6_opt_hdr ), -MAX_IPV6_HDR_LEN ); + off + +sizeof (struct ipv6_opt_hdr ));if (err <0 ) goto out;
@@ -5271,7 +5272,8 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate) err =skb_maybe_pull_tail (skb, off +sizeof (struct ip_auth_hdr ), -MAX_IPV6_HDR_LEN ); + off + +sizeof (struct ip_auth_hdr ));if (err <0 ) goto out;
@@ -5286,7 +5288,8 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate) err =skb_maybe_pull_tail (skb, off +sizeof (struct frag_hdr ), -MAX_IPV6_HDR_LEN ); + off + +sizeof (struct frag_hdr ));if (err <0 ) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 891/982 vrf: Stop corrupting skb->csum when capturing CHECKSUM_COMPLETE packets
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit ab7aa05c06ae340e5c7530bb78fa8d23794e460b ]
The VRF device is an Ethernet device but it can have non-Ethernet ports such as IP tunnels. Before the cited commit, capturing packets from such ports on the VRF device resulted in these packets being detected as malformed since they lack an Ethernet header.
The cited commit fixed it by pushing a dummy Ethernet header to such packets before the capture and pulling it afterwards. In the case of CHECKSUM_COMPLETE packets it also updated skb->csum with the checksum of the dummy Ethernet header. This is wrong as skb->csum should not include the checksum of the Ethernet header ("checksum of the _whole_ packet as seen by netif_rx()").
This also means that L4 protocols receive a corrupted skb->csum and potentially drop the packet, as is the case with UDP packets whose checksum was completed by software.
Fix by removing the unnecessary call to skb_postpush_rcsum().
--- drivers/net/vrf.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/vrf.c +0 -2
@@ -1278,8 +1278,6 @@ static int vrf_prepare_mac_header(struct sk_buff *skb, skb->protocol = eth->h_proto; skb->pkt_type =PACKET_HOST ; -skb_postpush_rcsum (skb, skb->data,ETH_HLEN ); -skb_pull_inline (skb,ETH_HLEN );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 892/982 bpf: Fix immediate JMP JEQ/JNE on MIPS32
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Almbladh <[email protected]>
[ Upstream commit db762fd96be225bd06161c9631160c755d891693 ]
An addu instruction was emitted instead of addiu, causing the immediate value 1 to be interpreted as register $at. This made the comparison result invalid when the immediate operand was negative. Note that $at is mapped to BPF_REG_AX, which is used for constant blinding.
Fix the instruction to use the immediate form.
Found with test_bpf on MIPS32r1 emulated by QEMU.
--- arch/mips/net/bpf_jit_comp32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/net/bpf_jit_comp32.c +1 -1
@@ -1111,7 +1111,7 @@ static void emit_jmp_i64(struct jit_context *ctx,emit (ctx, xor, tmp,lo (dst), tmp); }if (imm <0 ) {/* Compare sign extension */ -emit (ctx, addu,MIPS_R_T9 ,hi (dst),1 ); +emit (ctx, addiu,MIPS_R_T9 ,hi (dst),1 );emit (ctx, or, tmp, tmp,MIPS_R_T9 ); }else {/* Compare zero extension */ emit (ctx, or, tmp, tmp,hi (dst));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 893/982 bpf: Fix BSWAP 32 and 16 on MIPS64
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Almbladh <[email protected]>
[ Upstream commit 8110ba09777873443db286b3cbb89b0e6311c554 ]
The 16/32-bit byteswap implementations for MIPS64r1 and earlier do not have an explicit zero extension afterwards. The input is first sign-extended to 64 bits, and the byteswap sequence can then leave the result sign-extended depending on the value of the low bits.
Add the missing zero-extension.
Found with test_bpf on MIPS64r1 emulated by QEMU.
--- arch/mips/net/bpf_jit_comp64.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/net/bpf_jit_comp64.c +1 -2
@@ -302,8 +302,7 @@ static void emit_bswap_r64(struct jit_context *ctx, u8 dst, u32 width)case 16 :emit_sext (ctx, dst, dst);emit_bswap_r (ctx, dst, width); -if (cpu_has_mips64r2 || cpu_has_mips64r6) -emit_zext (ctx, dst); +emit_zext (ctx, dst);break ; }clobber_reg (ctx, dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 894/982 driver core: Better advertise dev_err_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 532888a59505da2a3fbb4abac6adad381cedb374 ]
Describing the usage of dev_err_probe() as being (only?) "deemed acceptable" has a bad connotation. In fact dev_err_probe() fulfills three tasks:
- handling of EPROBE_DEFER (even more than degrading to dev_dbg())
- symbolic output of the error code
- return err for compact error code paths
Advertise these better and claim the usage to be "fine" to get rid of the bad connotation.
Stable-dep-of: 4eb3f195ef08 ("tg3: use random MAC address when tg3_get_device_address fails")
--- drivers/base/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/base/core.c +5 -4
@@ -5042,13 +5042,14 @@ define_dev_printk_level(_dev_info, KERN_INFO);* * return dev_err_probe(dev, err, ...); * -* Note that it is deemed acceptable to use this function for error -* prints during probe even if the @err is known to never be -EPROBE_DEFER. +* Using this helper in your probe function is totally fine even if @err is +* known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format -* of the error code and the fact that the error code is returned. +* of the error code, it being emitted symbolically (i.e. you get "EAGAIN" +* instead of "-35") and the fact that the error code is returned which allows +* more compact error paths. * * Returns @err. -* */ int dev_err_probe (const struct device *dev,int err,const char *fmt, ...) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 895/982 driver core: Make dev_err_probe() silent for -ENOMEM
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 2f3cfd2f4b7cf3026fe6b9b2a5320cc18f4c184e ]
For an out-of-memory error there should be no additional output. Adapt dev_err_probe() to not emit the error message when err is -ENOMEM. This simplifies handling errors that might among others be -ENOMEM.
Stable-dep-of: 4eb3f195ef08 ("tg3: use random MAC address when tg3_get_device_address fails")
--- drivers/base/core.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/base/core.c +14 -3
@@ -5060,11 +5060,22 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; -if (err != -EPROBE_DEFER ) { -dev_err (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); - }else { +switch (err) { +case -EPROBE_DEFER :device_set_deferred_probe_reason (dev, &vaf);dev_dbg (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); +break ; + +case -ENOMEM : +/* +* We don't print anything on -ENOMEM, there is already enough +* output. +*/ +break ; + +default : +dev_err (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); +break ; }va_end (args);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 896/982 driver core: Add device probe log helper dev_warn_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragan Simic <[email protected]>
[ Upstream commit 36e69b160705b65bf136c2fb6a1194447eeb8478 ]
Some drivers can still provide their functionality to a certain extent even when some of their resource acquisitions eventually fail. In such cases, emitting errors isn't the desired action, but warnings should be emitted instead.
To solve this, introduce dev_warn_probe() as a new device probe log helper, which behaves identically as the already existing dev_err_probe(), while it produces warnings instead of errors. The intended use is with the resources that are actually optional for a particular driver.
While there, copyedit the kerneldoc for dev_err_probe() a bit, to simplify its wording a bit, and reuse it as the kerneldoc for dev_warn_probe(), with the necessary wording adjustments, of course.
Stable-dep-of: 4eb3f195ef08 ("tg3: use random MAC address when tg3_get_device_address fails")
--- drivers/base/core.c | 129 +++++++++++++++++++++++++++++-------- include/linux/dev_printk.h | 1 + 2 files changed, 102 insertions(+), 28 deletions(-)
drivers/base/core.c +101 -28
@@ -5018,6 +5018,49 @@ define_dev_printk_level(_dev_info, KERN_INFO);#endif +static void __dev_probe_failed (const struct device *dev,int err,bool fatal, +const char *fmt,va_list vargsp) +{ +struct va_format vaf; +va_list vargs; + +/* +* On x86_64 and possibly on other architectures, va_list is actually a +* size-1 array containing a structure. As a result, function parameter +* vargsp decays from T[1] to T*, and &vargsp has type T** rather than +* T(*)[1], which is expected by its assignment to vaf.va below. +* +* One standard way to solve this mess is by creating a copy in a local +* variable of type va_list and then using a pointer to that local copy +* instead, which is the approach employed here. +*/ +va_copy (vargs, vargsp); + + vaf.fmt = fmt; + vaf.va = &vargs; + +switch (err) { +case -EPROBE_DEFER : +device_set_deferred_probe_reason (dev, &vaf); +dev_dbg (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); +break ; + +case -ENOMEM : +/* Don't print anything on -ENOMEM, there's already enough output */ +break ; + +default : +/* Log fatal final failures as errors, otherwise produce warnings */ +if (fatal) +dev_err (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); +else +dev_warn (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); +break ; + } + +va_end (vargs); +} +/** * dev_err_probe - probe error check and log helper * @dev: the pointer to the struct device
@@ -5030,7 +5073,7 @@ define_dev_printk_level(_dev_info, KERN_INFO);* -EPROBE_DEFER and propagate error upwards. * In case of -EPROBE_DEFER it sets also defer probe reason, which can be * checked later by reading devices_deferred debugfs attribute. -* It replaces code sequence:: +* It replaces the following code sequence:: * * if (err != -EPROBE_DEFER) * dev_err(dev, ...);
@@ -5042,47 +5085,77 @@ define_dev_printk_level(_dev_info, KERN_INFO);* * return dev_err_probe(dev, err, ...); * -* Using this helper in your probe function is totally fine even if @err is -* known to never be -EPROBE_DEFER. +* Using this helper in your probe function is totally fine even if @err +* is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format -* of the error code, it being emitted symbolically (i.e. you get "EAGAIN" -* instead of "-35") and the fact that the error code is returned which allows -* more compact error paths. +* of the error code, which is emitted symbolically (i.e. you get "EAGAIN" +* instead of "-35"), and having the error code returned allows more +* compact error paths. * * Returns @err. */ int dev_err_probe (const struct device *dev,int err,const char *fmt, ...) { -struct va_format vaf; -va_list args; +va_list vargs; -va_start (args, fmt); - vaf.fmt = fmt; - vaf.va = &args; +va_start (vargs, fmt); -switch (err) { -case -EPROBE_DEFER : -device_set_deferred_probe_reason (dev, &vaf); -dev_dbg (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); -break ; +/* Use dev_err() for logging when err doesn't equal -EPROBE_DEFER */ +__dev_probe_failed (dev, err, true, fmt, vargs); -case -ENOMEM : -/* -* We don't print anything on -ENOMEM, there is already enough -* output. -*/ -break ; +va_end (vargs); -default : -dev_err (dev,"error %pe: %pV" ,ERR_PTR (err), &vaf); -break ; - } +return err; +} +EXPORT_SYMBOL_GPL (dev_err_probe); -va_end (args); +/** +* dev_warn_probe - probe error check and log helper +* @dev: the pointer to the struct device +* @err: error value to test +* @fmt: printf-style format string +* @...: arguments as specified in the format string +* +* This helper implements common pattern present in probe functions for error +* checking: print debug or warning message depending if the error value is +* -EPROBE_DEFER and propagate error upwards. +* In case of -EPROBE_DEFER it sets also defer probe reason, which can be +* checked later by reading devices_deferred debugfs attribute. +* It replaces the following code sequence:: +* +* if (err != -EPROBE_DEFER) +* dev_warn(dev, ...); +* else +* dev_dbg(dev, ...); +* return err; +* +* with:: +* +* return dev_warn_probe(dev, err, ...); +* +* Using this helper in your probe function is totally fine even if @err +* is known to never be -EPROBE_DEFER. +* The benefit compared to a normal dev_warn() is the standardized format +* of the error code, which is emitted symbolically (i.e. you get "EAGAIN" +* instead of "-35"), and having the error code returned allows more +* compact error paths. +* +* Returns @err. +*/ +int dev_warn_probe (const struct device *dev,int err,const char *fmt, ...) +{ +va_list vargs; + +va_start (vargs, fmt); + +/* Use dev_warn() for logging when err doesn't equal -EPROBE_DEFER */ +__dev_probe_failed (dev, err, false, fmt, vargs); + +va_end (vargs);return err; } -EXPORT_SYMBOL_GPL (dev_err_probe); +EXPORT_SYMBOL_GPL (dev_warn_probe);static inline bool fwnode_is_primary (struct fwnode_handle *fwnode) {
include/linux/dev_printk.h +1 -0
@@ -276,6 +276,7 @@ do { \ dev_driver_string(dev), dev_name(dev), ## arg) __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +__printf(3, 4) int dev_warn_probe(const struct device *dev, int err, const char *fmt, ...);/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */ #define dev_err_ptr_probe (dev, ___err, fmt, ...) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 897/982 tg3: use random MAC address when tg3_get_device_address fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Delalande <[email protected]>
[ Upstream commit 4eb3f195ef08c5acaed87958297e41cc49588dde ]
Some of the tg3 NICs we use (BCM57762) reset the SRAM MAC address to the placeholder address on link flaps, tg3_chip_reset, etc. We've typically fixed it from userspace, but since e4c00ba7274b ("tg3: replace placeholder MAC address with device property") was merged, tg3 just fails probe as we don't have a way to get it through the generic device_get_mac_address infrastructure as fallback on our systems.
Make the driver assign a random address in this condition instead of being fatal for probe. Set deferred_probe_reason through dev_warn_probe if the address isn't yet available from the provider.
--- drivers/net/ethernet/broadcom/tg3.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +7 -4
@@ -17834,11 +17834,14 @@ static int tg3_init_one(struct pci_dev *pdev, err =tg3_get_device_address (tp, addr);if (err) { -dev_err (&pdev->dev, -"Could not obtain valid ethernet address, aborting\n" ); - goto err_out_apeunmap; +dev_warn_probe (&pdev->dev, err, +"Could not obtain a valid ethernet address\n" ); +if (err == -EPROBE_DEFER ) + goto err_out_apeunmap; +eth_hw_addr_random (dev); + }else { +eth_hw_addr_set (dev, addr); } -eth_hw_addr_set (dev, addr); intmbx =MAILBOX_INTERRUPT_0 +TG3_64BIT_REG_LOW ; rcvmbx =MAILBOX_RCVRET_CON_IDX_0 +TG3_64BIT_REG_LOW ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 898/982 net: bcmgenet: fix 64-bit RTNL stats reading in ethtool on 32-bit systems
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 0e2bec77ea62895416600c90588f593516572bca ]
When bcmgenet was converted to 64-bit statistics, STAT_RTNL members were switched to point into struct rtnl_link_stats64, whose fields are 64-bit (__u64) regardless of architecture.
However, bcmgenet_get_ethtool_stats() retained a legacy check:
if (sizeof(unsigned long) != sizeof(u32) &&
s->stat_sizeof == sizeof(unsigned long))
On 32-bit systems, sizeof(unsigned long) == sizeof(u32), causing this condition to evaluate to false. As a result, 64-bit RTNL stats fields were read via *(u32 *)p. On 32-bit Big-Endian systems (such as MIPS BE), this reads the high 32 bits and returns 0 until the counter exceeds 4GB; on 32-bit Little-Endian systems (such as 32-bit ARM), the value is truncated to 32 bits.
Fix this by checking if s->stat_sizeof == sizeof(u64) so 64-bit fields are always read as 64-bit values.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +2 -3
@@ -1307,9 +1307,8 @@ static void bcmgenet_get_ethtool_stats(struct net_device *dev, p = (char *)&stats64; p += s->stat_offset; -if (sizeof (unsigned long ) !=sizeof (u32) && - s->stat_sizeof ==sizeof (unsigned long )) - data[i] = *(unsigned long *)p; +if (s->stat_sizeof ==sizeof (u64)) + data[i] = *(u64 *)p;else data[i] = *(u32 *)p; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 899/982 net: bcmgenet: initialize u64 stats seq counter for all queues
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 3aeaa609fda19c09d5298c9fedaaa3b6229601b5 ]
bcmgenet_gstrings_stats statically defines ethtool statistics for queues 0 through GENET_MAX_MQ_CNT (4). However, bcmgenet_probe() only initialized the u64_stats_sync seq counter up to priv->hw_params->rx_queues and priv->hw_params->tx_queues.
Since priv->hw_params->rx_queues is 0 across all hardware versions (and priv->hw_params->tx_queues is 0 on GENET V1), rings 1..4 have uninitialized u64_stats_sync structures. When ethtool -S is run on 32-bit kernels, bcmgenet_get_ethtool_stats() reads stats from rx_rings[1..4], causing lockdep warnings due to the uninitialized sequence counters.
Initialize the sequence counters for all GENET_MAX_MQ_CNT + 1 queues.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +2 -2
@@ -4073,10 +4073,10 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->rx_rings[i].rx_max_coalesced_frames =1 ;/* Initialize u64 stats seq counter for 32bit machines */ -for (i =0 ; i <= priv->hw_params->rx_queues; i++) +for (i =0 ; i <=GENET_MAX_MQ_CNT ; i++) {u64_stats_init (&priv->rx_rings[i].stats64.syncp); -for (i =0 ; i <= priv->hw_params->tx_queues; i++)u64_stats_init (&priv->tx_rings[i].stats64.syncp); + }/* libphy will determine the link state */ netif_carrier_off (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 900/982 net: bcmgenet: move bcmgenet_power_up into resume_noirq
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
[ Upstream commit ffce2bedd361177718dc0c3787f4adb4785a0151 ]
The bcmgenet_power_up() function is moved from the resume method to the resume_noirq method for symmetry with the suspend_noirq method. This allows the wol_active flag to be removed.
The UMAC_IRQ_WAKE_EVENT interrupts that can be unmasked by the bcmgenet_wol_power_down_cfg() function are now re-masked by the bcmgenet_wol_power_up_cfg() function at the resume_noirq level as well.
Stable-dep-of: cbbc1aee7776 ("net: bcmgenet: do not skip WoL power up on GENET V1")
--- .../net/ethernet/broadcom/genet/bcmgenet.c | 24 +++++++++---------- .../net/ethernet/broadcom/genet/bcmgenet.h | 1 - .../ethernet/broadcom/genet/bcmgenet_wol.c | 8 +++---- 3 files changed, 15 insertions(+), 18 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +12 -12
@@ -4142,8 +4142,20 @@ static int bcmgenet_resume_noirq(struct device *d) reg =bcmgenet_intrl2_0_readl (priv,INTRL2_CPU_STAT );if (reg &UMAC_IRQ_WAKE_EVENT )pm_wakeup_event (&priv->pdev->dev,0 ); + +/* From WOL-enabled suspend, switch to regular clock */ +bcmgenet_power_up (priv,GENET_POWER_WOL_MAGIC ); } +/* If this is an internal GPHY, power it back on now, before UniMAC is +* brought out of reset as absolutely no UniMAC activity is allowed +*/ +if (priv->internal_phy) +bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); + +/* take MAC out of reset */ +bcmgenet_umac_reset (priv); +bcmgenet_intrl2_0_writel (priv,UMAC_IRQ_WAKE_EVENT ,INTRL2_CPU_CLEAR );return 0 ;
@@ -4160,18 +4172,6 @@ static int bcmgenet_resume(struct device *d)if (!netif_running (dev))return 0 ; -/* From WOL-enabled suspend, switch to regular clock */ -if (device_may_wakeup (d) && priv->wolopts) -bcmgenet_power_up (priv,GENET_POWER_WOL_MAGIC ); - -/* If this is an internal GPHY, power it back on now, before UniMAC is -* brought out of reset as absolutely no UniMAC activity is allowed -*/ -if (priv->internal_phy) -bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); - -bcmgenet_umac_reset (priv); -init_umac (priv);phy_init_hw (dev->phydev);
drivers/net/ethernet/broadcom/genet/bcmgenet.h +0 -1
@@ -658,7 +658,6 @@ struct bcmgenet_priv {struct clk *clk_wol;u32 wolopts;u8 sopass[SOPASS_MAX ]; -bool wol_active;struct bcmgenet_mib_counters mib;
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +3 -5
@@ -177,7 +177,6 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv, retries);clk_prepare_enable (priv->clk_wol); - priv->wol_active =1 ;if (hfb_enable) { bcmgenet_hfb_reg_writel(priv, hfb_enable,
@@ -216,13 +215,12 @@ void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,return ; } -if (!priv->wol_active) -return ;/* failed to suspend so skip the rest */ - - priv->wol_active =0 ;clk_disable_unprepare (priv->clk_wol); priv->crc_fwd_en =0 ; +bcmgenet_intrl2_0_writel (priv,UMAC_IRQ_WAKE_EVENT , +INTRL2_CPU_MASK_SET ); +/* Disable Magic Packet Detection */ if (priv->wolopts & (WAKE_MAGIC |WAKE_MAGICSECURE )) { reg =bcmgenet_umac_readl (priv,UMAC_MPD_CTRL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 901/982 net: bcmgenet: allow return of power up status
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doug Berger <[email protected]>
[ Upstream commit 2432b9817b7cb91aaae9e5032da0bb017cb3102d ]
It is possible for a WoL power up to fail due to the GENET being reset while in the suspend state. Allow these failures to be returned as error codes to allow different recovery behavior when necessary.
Stable-dep-of: cbbc1aee7776 ("net: bcmgenet: do not skip WoL power up on GENET V1")
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 ++++++++----- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 4 ++-- drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 12 +++++++----- 3 files changed, 17 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -5
@@ -1697,13 +1697,14 @@ static int bcmgenet_power_down(struct bcmgenet_priv *priv,return ret; } -static void bcmgenet_power_up (struct bcmgenet_priv *priv, -enum bcmgenet_power_mode mode) +static int bcmgenet_power_up (struct bcmgenet_priv *priv, +enum bcmgenet_power_mode mode) { +int ret =0 ;u32 reg;if (!bcmgenet_has_ext (priv)) -return ; +return ret; reg =bcmgenet_ext_readl (priv,EXT_EXT_PWR_MGMT );
@@ -1739,11 +1740,13 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv, }break ;case GENET_POWER_WOL_MAGIC : -bcmgenet_wol_power_up_cfg (priv, mode); -return ; + ret =bcmgenet_wol_power_up_cfg (priv, mode); +break ;default :break ; } + +return ret; } static struct enet_cb *bcmgenet_get_txcb(struct bcmgenet_priv *priv,
drivers/net/ethernet/broadcom/genet/bcmgenet.h +2 -2
@@ -741,8 +741,8 @@ void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol);int bcmgenet_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol);int bcmgenet_wol_power_down_cfg (struct bcmgenet_priv *priv,enum bcmgenet_power_mode mode); -void bcmgenet_wol_power_up_cfg (struct bcmgenet_priv *priv, -enum bcmgenet_power_mode mode); +int bcmgenet_wol_power_up_cfg (struct bcmgenet_priv *priv, +enum bcmgenet_power_mode mode);void bcmgenet_eee_enable_set (struct net_device *dev,bool enable,bool tx_lpi_enabled);
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +7 -5
@@ -205,14 +205,14 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv,return 0 ; } -void bcmgenet_wol_power_up_cfg (struct bcmgenet_priv *priv, -enum bcmgenet_power_mode mode) +int bcmgenet_wol_power_up_cfg (struct bcmgenet_priv *priv, +enum bcmgenet_power_mode mode) {u32 reg;if (mode !=GENET_POWER_WOL_MAGIC ) {netif_err (priv, wol, priv->dev,"invalid mode: %d\n" , mode); -return ; +return -EINVAL ; }clk_disable_unprepare (priv->clk_wol);
@@ -225,7 +225,7 @@ void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,if (priv->wolopts & (WAKE_MAGIC |WAKE_MAGICSECURE )) { reg =bcmgenet_umac_readl (priv,UMAC_MPD_CTRL );if (!(reg &MPD_EN )) -return ;/* already reset so skip the rest */ +return -EPERM ;/* already reset so skip the rest */ reg &= ~(MPD_EN |MPD_PW_EN );bcmgenet_umac_writel (priv, reg,UMAC_MPD_CTRL ); }
@@ -234,7 +234,7 @@ void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,if (priv->wolopts &WAKE_FILTER ) { reg =bcmgenet_hfb_reg_readl (priv,HFB_CTRL );if (!(reg &RBUF_ACPI_EN )) -return ;/* already reset so skip the rest */ +return -EPERM ;/* already reset so skip the rest */ reg &= ~(RBUF_HFB_EN |RBUF_ACPI_EN );bcmgenet_hfb_reg_writel (priv, reg,HFB_CTRL ); }
@@ -245,4 +245,6 @@ void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, reg &= ~CMD_CRC_FWD ;bcmgenet_umac_writel (priv, reg,UMAC_CMD );spin_unlock_bh (&priv->reg_lock); + +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 902/982 net: bcmgenet: do not skip WoL power up on GENET V1
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit cbbc1aee7776c7fa1d89e6cb963a23e58c495dca ]
bcmgenet_power_up() had an early check for bcmgenet_has_ext(priv) before dispatching by power mode. GENET V1 does not have the EXT block (unlike GENET V2+), which causes bcmgenet_power_up() to immediately return 0.
As a consequence, when waking up from GENET_POWER_WOL_MAGIC on GENET V1, bcmgenet_wol_power_up_cfg() is never invoked to disable the WoL clock, clear wake event masks, and restore normal PHY and MAC operations.
Move the bcmgenet_has_ext() checks to the GENET_POWER_PASSIVE and GENET_POWER_CABLE_SENSE cases where the EXT registers are actually accessed, allowing GENET_POWER_WOL_MAGIC cleanup to execute on all hardware versions.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -5
@@ -1703,13 +1703,12 @@ static int bcmgenet_power_up(struct bcmgenet_priv *priv,int ret =0 ;u32 reg; -if (!bcmgenet_has_ext (priv)) -return ret; - - reg =bcmgenet_ext_readl (priv,EXT_EXT_PWR_MGMT ); -switch (mode) {case GENET_POWER_PASSIVE : +if (!bcmgenet_has_ext (priv)) +break ; + + reg =bcmgenet_ext_readl (priv,EXT_EXT_PWR_MGMT ); reg &= ~(EXT_PWR_DOWN_DLL |EXT_PWR_DOWN_BIAS |EXT_ENERGY_DET_MASK );if (GENET_IS_V5 (priv) && !bcmgenet_has_ephy_16nm (priv)) {
@@ -1733,8 +1732,12 @@ static int bcmgenet_power_up(struct bcmgenet_priv *priv,break ;case GENET_POWER_CABLE_SENSE : +if (!bcmgenet_has_ext (priv)) +break ; +/* enable APD */ if (!GENET_IS_V5 (priv)) { + reg =bcmgenet_ext_readl (priv,EXT_EXT_PWR_MGMT ); reg |=EXT_PWR_DN_EN_LD ;bcmgenet_ext_writel (priv, reg,EXT_EXT_PWR_MGMT ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 903/982 net: bcmgenet: validate Ethernet address in bcmgenet_set_mac_addr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 273941c85fc2632cd3e56ddff737b9245de7697d ]
bcmgenet_set_mac_addr() did not check whether the provided MAC address is a valid Ethernet address before applying it. Userspace could configure an invalid address (such as all zeroes or a multicast address) while the interface is down.
Add a call to is_valid_ether_addr() and return -EADDRNOTAVAIL if the MAC address is not valid.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +3 -0
@@ -3566,6 +3566,9 @@ static int bcmgenet_set_mac_addr(struct net_device *dev, void *p)if (netif_running (dev))return -EBUSY ; +if (!is_valid_ether_addr (addr->sa_data)) +return -EADDRNOTAVAIL ; +eth_hw_addr_set (dev, addr->sa_data);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 904/982 net: bcmgenet: mask DMA_TIMEOUT_MASK when reading DMA_RING0_TIMEOUT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit d64e277b955be4506931802837499b62c8f3968a ]
bcmgenet_get_coalesce() reads DMA_RING0_TIMEOUT to calculate rx_coalesce_usecs without masking out bits outside DMA_TIMEOUT_MASK (16 bits). If upper bits are non-zero or contain status/flags, the computed value of rx_coalesce_usecs returned to userspace via ethtool becomes corrupted.
Mask the register read with DMA_TIMEOUT_MASK before computing the timeout in microseconds.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +2 -1
@@ -837,7 +837,8 @@ static int bcmgenet_get_coalesce(struct net_device *dev, ec->rx_max_coalesced_frames =bcmgenet_rdma_ring_readl (priv,0 ,DMA_MBUF_DONE_THRESH ); ec->rx_coalesce_usecs = -bcmgenet_rdma_readl (priv,DMA_RING0_TIMEOUT ) *8192 /1000 ; + (bcmgenet_rdma_readl (priv,DMA_RING0_TIMEOUT ) & +DMA_TIMEOUT_MASK ) *8192 /1000 ;for (i =0 ; i <= priv->hw_params->rx_queues; i++) { ring = &priv->rx_rings[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 905/982 ip_gre: Reject enabling collect metadata through changelink
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
[ Upstream commit a3f315be9d30eeb6938d11fa17fd4b32d52f7c42 ]
ipgre_netlink_parms() can enable collect_md on an existing GRE, GRETAP or ERSPAN device. Unlike newlink, changelink does not enforce metadata tunnel uniqueness. Converting a non-metadata device can therefore replace the metadata receive entry for another device of the same type in the same netns. Deleting either device then clears the shared entry, breaking metadata receive lookup for the surviving device.
If parameter validation fails after collect_md is set, deleting the modified device can also clear an entry it never owned.
Reject enabling metadata mode in both changelink callbacks before any encapsulation or tunnel parameters are modified. Allow requests that repeat the metadata attribute on an existing metadata device.
--- net/ipv4/ip_gre.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/ipv4/ip_gre.c +12 -0
@@ -1409,6 +1409,12 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[],if (!rtnl_dev_link_net_capable (dev, t->net))return -EPERM ; +if (data && data[IFLA_GRE_COLLECT_METADATA ] && !t->collect_md) { +NL_SET_ERR_MSG (extack, +"Enabling collect_md on an existing device is not supported" ); +return -EOPNOTSUPP ; + } + err =ipgre_newlink_encap_setup (dev, data);if (err)return err;
@@ -1441,6 +1447,12 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[],if (!rtnl_dev_link_net_capable (dev, t->net))return -EPERM ; +if (data && data[IFLA_GRE_COLLECT_METADATA ] && !t->collect_md) { +NL_SET_ERR_MSG (extack, +"Enabling collect_md on an existing device is not supported" ); +return -EOPNOTSUPP ; + } + err =ipgre_newlink_encap_setup (dev, data);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 906/982 vxlan: use one headroom snapshot for neighbour replies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 481506a756dcd828ef42391cb08f38d8d96d38fc ]
vxlan_na_create() samples LL_RESERVED_SPACE() to size the reply skb and then samples it again to reserve headroom. A concurrent vxlan_changelink() can update needed_headroom between the two reads, creating a TOCTOU race. The second value can exceed the allocation and make the Ethernet header write out of bounds.
The race is reproducible on the unpatched kernel. It occurred when vxlan_na_create() generated a neighbour reply while vxlan_changelink() changed the link headroom. KASAN caught a four-byte write two bytes beyond a 704-byte skbuff_small_head allocation.
Snapshot the headroom once and use that value for both allocation and reservation.
--- drivers/net/vxlan/vxlan_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -2
@@ -2000,13 +2000,15 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,struct ipv6hdr *pip6;u8 *daddr;int na_olen =8 ;/* opt hdr + ETH_ALEN for target */ +int headroom;int ns_olen;int i, len;if (dev ==NULL || !pskb_may_pull (request, request->len))return NULL ; - len =LL_RESERVED_SPACE (dev) +sizeof (struct ipv6hdr ) + + headroom =LL_RESERVED_SPACE (dev); + len = headroom +sizeof (struct ipv6hdr ) +sizeof (*na) + na_olen + dev->needed_tailroom; reply =alloc_skb (len,GFP_ATOMIC );if (reply ==NULL )
@@ -2014,7 +2016,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request, reply->protocol =htons (ETH_P_IPV6 ); reply->dev = dev; -skb_reserve (reply,LL_RESERVED_SPACE (request->dev)); +skb_reserve (reply, headroom);skb_push (reply,sizeof (struct ethhdr ));skb_reset_mac_header (reply);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 907/982 net: xps: reject an out of range traffic class
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
[ Upstream commit 4da3b7b8b50f3e2fde54a4c18a82a8e3f6223910 ]
Only the entries below dev->num_tc are valid in dev->tc_to_txq[], and dev->prio_tc_map[] may only name classes below it. netdev_set_num_tc() lowers dev->num_tc without touching either array.
netdev_txq_to_tc() walks all TC_MAX_QUEUE slots and netdev_get_prio_tc_map() returns the entry as it stands, so a leftover entry is handed out as a traffic class >= dev->num_tc. Taking that class from netdev_txq_to_tc(), __netif_set_xps_queue() rejects only a negative one and indexes an XPS map sized for dev->num_tc classes:
tci = j * num_tc + tc; RCU_INIT_POINTER(new_dev_maps->attr_map[tci], map);
attr_map[] holds nr_ids * num_tc entries and j runs over the ids named in the mask, so a class that is not below num_tc pushes tci past the end of the map for the last ids and the store overruns it.
Any caller that lowers num_tc leaves such entries behind, and mqprio_destroy() tears down with netdev_set_num_tc(dev, 0) rather than netdev_reset_tc(). After mqprio with 8 classes then 1, tc_to_txq[1..7] still describe txq 1..7. The splat is from an XPS write to txq 2 on a veth with 8 rx queues: attr_map[] has 8 * 1 entries, tci = j + 2, and j == 6 stores one past the end of the 88-byte map:
BUG: KASAN: slab-out-of-bounds in __netif_set_xps_queue (net/core/dev.c:2954) Write of size 8 at addr ffff88813016bc58 by task xps_oob/634 __netif_set_xps_queue (net/core/dev.c:2954) xps_rxqs_store (net/core/net-sysfs.c:1880) netdev_queue_attr_store (net/core/net-sysfs.c:1390) Allocated by task 634: __kmalloc_noprof (mm/slub.c:5439) __netif_set_xps_queue (net/core/dev.c:2937) The buggy address is located 0 bytes to the right of allocated 88-byte region [ffff88813016bc00, ffff88813016bc58)
Reject a class the map has no room for.
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -2630,7 +2630,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, dev =netdev_get_tx_queue (dev, index)->sb_dev ? : dev; tc =netdev_txq_to_tc (dev, index); -if (tc <0 ) +if (tc <0 || tc >= num_tc)return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 908/982 tcp: fix use-after-free of retransmit_skb_hint in tcp_send_synack()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yilin Zhang <[email protected]>
[ Upstream commit fe99bbeee5c5dbd3abc30721a8079ced59649d97 ]
When tcp_send_synack() replaces the cloned SYN skb at the head of the retransmit queue with a copy, it frees the original with tcp_rtx_queue_unlink_and_free() and only repairs tp->highest_sack. tp->retransmit_skb_hint keeps pointing at the freed skbuff_fclone_cache object.
The dangling hint is read in tcp_verify_retransmit_hint() and used as the root of the rbtree walk in tcp_xmit_retransmit_queue(). An unprivileged TFO client (sendmsg(MSG_FASTOPEN)) can arm the hint with an attacker-supplied ICMP fragmentation-needed message, after which a simultaneous open frees the armed SYN skb:
BUG: KASAN: slab-use-after-free in tcp_mark_skb_lost (net/ipv4/tcp_input.c:1316) Read of size 4 at addr ffff88800604d928 by task swapper/1/0 Call Trace: tcp_mark_skb_lost (net/ipv4/tcp_input.c:1316) tcp_simple_retransmit (net/ipv4/tcp_input.c:3158) tcp_v4_err (net/ipv4/tcp_ipv4.c:587)
Sync the hint to the copy.
--- net/ipv4/tcp_output.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/tcp_output.c +3 -0
@@ -3551,6 +3551,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority)*/ int tcp_send_synack (struct sock *sk) { +struct tcp_sock *tp =tcp_sk (sk);struct sk_buff *skb; skb =tcp_rtx_queue_head (sk);
@@ -3568,6 +3569,8 @@ int tcp_send_synack(struct sock *sk)if (!nskb)return -ENOMEM ;INIT_LIST_HEAD (&nskb->tcp_tsorted_anchor); +if (skb == tp->retransmit_skb_hint) + tp->retransmit_skb_hint = nskb;tcp_highest_sack_replace (sk, skb, nskb);tcp_rtx_queue_unlink_and_free (skb, sk);__skb_header_release (nskb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 909/982 net/smc: fix UAF on lgr list traversal in smcr_port_err()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sidraya Jayagond <[email protected]>
[ Upstream commit 61cb282fe97b3b0ba32ca09417a693162bf4ae3f ]
smcr_port_err() traverses smc_lgr_list.list without holding smc_lgr_list.lock, allowing a concurrent smc_lgr_terminate_sched() to free an lgr while it is still being dereferenced.
Hold smc_lgr_list.lock across the traversal. Update smc_ib_gid_check() to call smcr_port_err() after releasing the lock.
--- net/smc/smc_core.c | 2 ++ net/smc/smc_ib.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
net/smc/smc_core.c +2 -0
@@ -1737,6 +1737,7 @@ void smcr_port_err(struct smc_ib_device *smcibdev, u8 ibport)struct smc_link_group *lgr, *n;int i; +spin_lock_bh (&smc_lgr_list.lock);list_for_each_entry_safe (lgr, n, &smc_lgr_list.list, list) {if (strncmp (smcibdev->pnetid[ibport -1 ], lgr->pnet_id,SMC_MAX_PNETID_LEN ))
@@ -1751,6 +1752,7 @@ void smcr_port_err(struct smc_ib_device *smcibdev, u8 ibport)smcr_link_down_cond_sched (lnk); } } +spin_unlock_bh (&smc_lgr_list.lock); }static void smc_link_down_work (struct work_struct *work)
net/smc/smc_ib.c +8 -2
@@ -333,6 +333,7 @@ static bool smc_ib_check_link_gid(u8 gid[SMC_GID_SIZE], bool smcrv2,static void smc_ib_gid_check (struct smc_ib_device *smcibdev,u8 ibport) {struct smc_link_group *lgr; +bool stale_gid = false;int i;spin_lock_bh (&smc_lgr_list.lock);
@@ -348,11 +349,16 @@ static void smc_ib_gid_check(struct smc_ib_device *smcibdev, u8 ibport)continue ;if (!smc_ib_check_link_gid (lgr->lnk[i].gid, lgr->smc_version ==SMC_V2 , - smcibdev, ibport)) -smcr_port_err (smcibdev, ibport); + smcibdev, ibport)) { + stale_gid = true; + goto out; + } } } +out:spin_unlock_bh (&smc_lgr_list.lock); +if (stale_gid) +smcr_port_err (smcibdev, ibport); }static int smc_ib_remember_port_attr (struct smc_ib_device *smcibdev,u8 ibport)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 910/982 tipc: Fix a data race on mon->peer_cnt in mon_timeout()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ginger Li <[email protected]>
[ Upstream commit 8e1937fed6738460554ec123c64839e2445e7d53 ]
mon_timeout() evaluates dom_size(mon->peer_cnt) before it takes mon->lock, while mon->peer_cnt is updated under that lock by tipc_mon_add_peer() and tipc_mon_remove_peer(). The value can therefore be stale, and the decision whether the local domain has to be recomputed can be based on an outdated member count.
Read mon->peer_cnt inside the write_lock_bh(&mon->lock) protected region.
--- net/tipc/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/tipc/monitor.c +2 -1
@@ -632,9 +632,10 @@ static void mon_timeout(struct timer_list *t) {struct tipc_monitor *mon =from_timer (mon, t, timer);struct tipc_peer *self; -int best_member_cnt =dom_size (mon->peer_cnt) -1 ; +int best_member_cnt;write_lock_bh (&mon->lock); + best_member_cnt =dom_size (mon->peer_cnt) -1 ; self = mon->self;if (self && (best_member_cnt != self->applied)) {mon_update_local_domain (mon);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 911/982 net: ethernet: stmmac: dwmac-rk: fix bulk clock leak when the PHY clock fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coia Prant <[email protected]>
[ Upstream commit 8db67bb6a1fffa4df68fbbc22e39943aeeff9178 ]
gmac_clk_enable() enables the bulk clocks first and then the optional PHY clock. If clk_prepare_enable() on the PHY clock fails, the function returns without rolling back the bulk clocks, and bsp_priv->clk_enabled stays false, so the later gmac_clk_enable(bsp_priv, false) becomes a no-op and the bulk clock references are leaked.
Add the missing clk_bulk_disable_unprepare() on that failure path.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +4 -1
@@ -1553,8 +1553,11 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)return ret; ret =clk_prepare_enable (bsp_priv->clk_phy); -if (ret) +if (ret) { +clk_bulk_disable_unprepare (bsp_priv->num_clks, + bsp_priv->clks);return ret; + }if (bsp_priv->ops && bsp_priv->ops->set_clock_selection) bsp_priv->ops->set_clock_selection(bsp_priv,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 912/982 llc: fix skb UAF and leaks on llc_mac_hdr_init() failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 72f9dd522f8d6c5a00be9695c7bb74631eb5069e ]
In llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(), if llc_mac_hdr_init() fails, kfree_skb(skb) is called instead of kfree_skb(nskb). This leaks the newly allocated nskb, reads from the freed skb via LLC_I_GET_NR(pdu), and double-frees skb when llc_conn_state_process() drops its reference.
In llc_sap_action_send_xid_r() and llc_sap_action_send_test_r(), nskb is leaked if llc_mac_hdr_init() returns an error.
Free nskb in all three error paths.
--- net/llc/llc_c_ac.c | 2 +- net/llc/llc_s_ac.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
net/llc/llc_c_ac.c +1 -1
@@ -443,7 +443,7 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,if (likely (!rc))llc_conn_send_pdu (sk, nskb);else -kfree_skb (skb); +kfree_skb (nskb); }if (rc) { nr =LLC_I_GET_NR (pdu);
net/llc/llc_s_ac.c +4 -0
@@ -127,6 +127,8 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb) rc =llc_mac_hdr_init (nskb, mac_sa, mac_da);if (likely (!rc)) rc =dev_queue_xmit (nskb); +else +kfree_skb (nskb); out:return rc; }
@@ -176,6 +178,8 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb) rc =llc_mac_hdr_init (nskb, mac_sa, mac_da);if (likely (!rc)) rc =dev_queue_xmit (nskb); +else +kfree_skb (nskb); out:return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 913/982 bridge: check llc_mac_hdr_init() return value in br_send_bpdu()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit ac704ff08e511c87643799c385f55ecd69b85e03 ]
If llc_mac_hdr_init() fails (for instance if the port device type does not support LLC or dev_hard_header() fails), br_send_bpdu() should drop the skb instead of resetting the mac header to the LLC payload and transmitting a malformed frame.
--- net/bridge/br_stp_bpdu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/bridge/br_stp_bpdu.c +4 -1
@@ -52,7 +52,10 @@ static void br_send_bpdu(struct net_bridge_port *p, LLC_SAP_BSPAN, LLC_PDU_CMD);llc_pdu_init_as_ui_cmd (skb); -llc_mac_hdr_init (skb, p->dev->dev_addr, p->br->group_addr); +if (llc_mac_hdr_init (skb, p->dev->dev_addr, p->br->group_addr)) { +kfree_skb (skb); +return ; + }skb_reset_mac_header (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 914/982 net/sched: sch_teql: fix shadowed err in __teql_resolve()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 907b978e82cb4c1c245fc2985bb27c5d5c88c8f6 ]
__teql_resolve() declares an inner 'int err;' inside the 'if (neigh_event_send(n, skb_res) == 0)' block, shadowing the outer 'int err = 0;'. As a result, a negative return from dev_hard_header() is written to the inner variable and __teql_resolve() still returns 0.
Remove the shadowed variable and set the outer err to -EINVAL when dev_hard_header() returns a negative error.
--- net/sched/sch_teql.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/sched/sch_teql.c +2 -5
@@ -265,14 +265,11 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, }if (neigh_event_send (n, skb_res) ==0 ) { -int err;char haddr[MAX_ADDR_LEN ];neigh_ha_snapshot (haddr, n, dev); - err =dev_hard_header (skb, dev,ntohs (skb_protocol (skb, false)), - haddr,NULL , skb->len); - -if (err <0 ) +if (dev_hard_header (skb, dev,ntohs (skb_protocol (skb, false)), + haddr,NULL , skb->len) <0 ) err = -EINVAL ; }else { err = (skb_res ==NULL ) ? -EAGAIN :1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 915/982 vlan: ensure sufficient headroom in vlan_dev_hard_header()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cd5dd68267c4238795fadaf02b3575ca3f8a6500 ]
Callers that only reserve ETH_HLEN or less (such as llc_alloc_frame()), or skbs allocated before dynamic device/headroom changes (e.g. toggling VLAN_FLAG_REORDER_HDR or bonding/team switching slaves), can reach vlan_dev_hard_header() with insufficient headroom and trigger skb_under_panic().
Use skb_cow_head() in vlan_dev_hard_header() when VLAN_FLAG_REORDER_HDR is not set to ensure sufficient headroom for the VLAN header(s) and the underlying device hard header.
Use READ_ONCE() to read dev->hard_header_len and dev->needed_headroom as they can be updated concurrently under RTNL (e.g. in vlan_transfer_features()) while vlan_dev_hard_header() runs locklessly on the transmit path. Also avoid LL_RESERVED_SPACE(dev) here so that the extra HH_DATA_MOD alignment padding does not trigger unnecessary pskb_expand_head() reallocations on inner stacked VLAN devices after the outer VLAN header has been pushed.
--- net/8021q/vlan_dev.c | 5 +++++ 1 file changed, 5 insertions(+)
net/8021q/vlan_dev.c +5 -0
@@ -53,6 +53,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,int rc;if (!(vlan->flags &VLAN_FLAG_REORDER_HDR )) { +unsigned int hlen =READ_ONCE (dev->hard_header_len) + +READ_ONCE (dev->needed_headroom); + +if (skb_cow_head (skb, hlen) <0 ) +return -ENOMEM ; vhdr =skb_push (skb,VLAN_HLEN ); vlan_tci = vlan->vlan_id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 916/982 autofs: fix sbi->pipe file reference leak in autofs_kill_sb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit aa5e44b29ffe4eaa08cc2237fd65bc2596bc023e ]
When autofs_fill_super() fails before clearing AUTOFS_SBI_CATATONIC (for example, when find_get_pid() fails on an invalid pgrp mount option, or when an fs_context is closed before mounting), deactivate_locked_super() invokes autofs_kill_sb() -> autofs_catatonic_mode(sbi).
Because AUTOFS_SBI_CATATONIC is still set in sbi->flags, autofs_catatonic_mode() returns early without calling fput(sbi->pipe), permanently leaking the pipe struct file reference.
Explicitly release sbi->pipe in autofs_kill_sb() if it is still non-NULL after autofs_catatonic_mode().
--- fs/autofs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/autofs/inode.c +4 -0
@@ -50,6 +50,10 @@ void autofs_kill_sb(struct super_block *sb)if (sbi) {/* Free wait queues, close pipe */ autofs_catatonic_mode (sbi); +if (sbi->pipe) { +fput (sbi->pipe); + sbi->pipe =NULL ; + }put_pid (sbi->oz_pgrp); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 917/982 perf/x86/intel: Ensure KVM guest PEBS path doesnt set unwanted PERF_GLOBAL_CTRL bits
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit cec38d5c098a350dcf084d345025136ade7e6d1e ]
When reinstating PEBS counters into PERF_GLOBAL_CTRL for a KVM guest, mask the value with perf's desired/original PERF_GLOBAL_CTRL value to ensure KVM doesn't unintentionally set reserved bits in PERF_GLOBAL_CTRL. E.g. if the guest's PEBS_ENABLE value had bit 63, "Enable Precise Store", set, then using the raw guest PEBS value would propagate bit 63 to the guest's PERF_GLOBAL_CTRL value (which thankfully would be a failed VM-Entry, not a VMX Abort).
The only reason this bug isn't reachable is because KVM doesn't support "Enable Precise Store" (which is probably a KVM bug?), i.e. bit 63 can't be set in kvm_pmu->pebs_enable and thus not in arr[pebs_enable].guest. In other words, this _should_ be a glorified NOP in the current code base.
--- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/core.c +1 -1
@@ -4190,7 +4190,7 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask; arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask;/* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */ - arr[global_ctrl].guest |= arr[pebs_enable].guest; + arr[global_ctrl].guest |= intel_ctrl & arr[pebs_enable].guest; }return arr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 918/982 perf/x86/intel: Dont write PEBS_ENABLED on host<=>guest xfers if CPU has PEBS isolation, to fix stuck PEBS_ENABLED
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 4b64dbdc5861477f148e13d1ed127e7fe7182e4f ]
When filling the list of MSRs to be loaded by KVM on VM-Enter and VM-Exit, *never* insert an entry for PEBS_ENABLED if the CPU properly isolates PEBS events, in which case disabling counters via PERF_GLOBAL_CTRL is sufficient to prevent unwanted PEBS events in the guest (or host). Because perf loads PEBS_ENABLE with the unfiltered cpu_hw_events.pebs_enabled, i.e. with both host and guest masks, there is no need to load different values for the guest versus host, perf+KVM can and should simply control which counters are enabled/disabled via PERF_GLOBAL_CTRL.
Avoiding touching PEBS_ENABLED "fixes" a bug where PEBS_ENABLED can end up with "stuck" bits if a PEBS event is throttled between generating the list and actually entering the guest (Intel CPUs can't arbtitrarily block NMIs). Fixes in quotes because leaving PEBS_ENABLED as-is doesn't fix the underlying problem of perf (via PMIs) being able to modify state after the perf<=>KVM handoff.
But not writing PEBS_ENABLED is desirable no matter what, as stating the obvious, leaving PEBS_ENABLED as-is avoids three MSR writes on every VMX
transition: one each on entry/exit, and one more explicit WRMSR to zero PEBS_ENABLED before VM-Entry (KVM assumes the only reason PEBS_ENABLED is in the load list is if the CPU lacks PEBS isolation and thus needs a quiescent period).
Opportunistically add comments to (better) explain the rules for generating the set of PEBS counters that will be active while the guest is running, along with a FIXME for the suspected hack-a-fix where perf disables guest PEBS if _any_ PEBS event is configured to count in the host (commit 854250329c02 ("KVM: x86/pmu: Disable guest PEBS temporarily in two rare situations") doesn't explain the motivation, at all).
--- arch/x86/events/intel/core.c | 55 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-)
arch/x86/events/intel/core.c +37 -18
@@ -4123,12 +4123,15 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)struct kvm_pmu *kvm_pmu = (struct kvm_pmu *)data;u64 intel_ctrl =hybrid (cpuc->pmu, intel_ctrl);u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable; -int global_ctrl, pebs_enable; +u64 guest_pebs_mask; +int global_ctrl;/* * In addition to obeying exclude_guest/exclude_host, remove bits being * used for PEBS when running a guest, because PEBS writes to virtual -* addresses (not physical addresses). +* addresses (not physical addresses). If the guest wants to utilize +* PEBS, and PEBS can be safely enabled in the guest, bits for the guest's +* PEBS-enabled counters will be OR'd back in as appropriate. */ *nr =0 ; global_ctrl = (*nr)++;
@@ -4175,24 +4178,40 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) }; } - pebs_enable = (*nr)++; - arr[pebs_enable] = (struct perf_guest_switch_msr ){ - .msr =MSR_IA32_PEBS_ENABLE , - .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask, - .guest = pebs_mask & ~cpuc->intel_ctrl_host_mask & kvm_pmu->pebs_enable, - }; +/* +* Restrict guest PEBS events to counters that (a) perf supports, (b) +* the guest wants to use for PEBS, (c) are not excluded from counting +* in the guest, and (d) _are_ excluded from counting in the host. +*/ + guest_pebs_mask = pebs_mask & intel_ctrl & kvm_pmu->pebs_enable & + ~cpuc->intel_ctrl_host_mask & + cpuc->intel_ctrl_guest_mask; -if (arr[pebs_enable].host) { -/* Disable guest PEBS if host PEBS is enabled. */ - arr[pebs_enable].guest =0 ; - }else { -/* Disable guest PEBS thoroughly for cross-mapped PEBS counters. */ - arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask; - arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask; -/* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */ - arr[global_ctrl].guest |= intel_ctrl & arr[pebs_enable].guest; - } +/* +* Disable counters where the guest PMC is different than the host PMC +* being used on behalf of the guest, as the PEBS record includes +* PERF_GLOBAL_STATUS, i.e. the guest will see overflow status for the +* wrong counter(s). +*/ + guest_pebs_mask &= ~kvm_pmu->host_cross_mapped_mask; + +/* +* FIXME: Allow guest and host usage of PEBS events to co-exist instead +* of disabling guest PEBS entirely if the host is using PEBS. +* What exactly goes wrong if guest and host are using PEBS is +* unknown. +*/ +if (pebs_mask & ~cpuc->intel_ctrl_guest_mask) + guest_pebs_mask =0 ; +/* +* Do NOT mess with PEBS_ENABLED. As above, disabling counters via +* PERF_GLOBAL_CTRL is sufficient, and loading a stale PEBS_ENABLED, +* e.g. on VM-Exit, can put the system in a bad state. Simply enable +* counters in PERF_GLOBAL_CTRL, as perf load PEBS_ENABLED with the +* full value, i.e. perf *also* relies on PERF_GLOBAL_CTRL. +*/ + arr[global_ctrl].guest |= guest_pebs_mask;return arr; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 919/982 mptcp: return sk_wait_data() errors from recvmsg()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Amirkan <[email protected]>
[ Upstream commit 60404266ef3e0a1cd8f7a164060e0c83efb72f4b ]
Commit 581302298524 ("mptcp: error out earlier on disconnect") made mptcp_recvmsg() stop when sk_wait_data() returns an error. The error is stored in err, but the function then jumps to a path which returns copied. When no data was copied, recvmsg() therefore returns zero and reports a false EOF.
Store the result in copied, which is the value returned by the function. This also keeps the usual partial-read result when data was copied before the error.
A recvmsg() blocked in one thread reproduces the issue when another thread disconnects the same MPTCP socket with connect(AF_UNSPEC). Before this change recvmsg() returns zero; afterwards it returns -EPIPE.
--- net/mptcp/protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/protocol.c +1 -1
@@ -2320,7 +2320,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,mptcp_cleanup_rbuf (msk, copied); err =sk_wait_data (sk, &timeo,NULL );if (err <0 ) { - err = copied ? : err; + copied = copied ? : err; goto out_err; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 920/982 rculist: add list_splice_rcu() for private lists
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit f902877b635551513729bdf9a8d1422c4aab7741 ]
This patch adds a helper function, list_splice_rcu(), to safely splice a private (non-RCU-protected) list into an RCU-protected list.
The function ensures that only the pointer visible to RCU readers (prev->next) is updated using rcu_assign_pointer(), while the rest of the list manipulations are performed with regular assignments, as the source list is private and not visible to concurrent RCU readers.
This is useful for moving elements from a private list into a global RCU-protected list, ensuring safe publication for RCU readers. Subsystems with some sort of batching mechanism from userspace can benefit from this new function.
The function __list_splice_rcu() has been added for clarity and to follow the same pattern as in the existing list_splice*() interfaces, where there is a check to ensure that the list to splice is not empty. Note that __list_splice_rcu() has no documentation for this reason.
--- include/linux/rculist.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
include/linux/rculist.h +29 -0
@@ -204,6 +204,35 @@ static inline void list_replace_rcu(struct list_head *old, old->prev =LIST_POISON2 ; } +static inline void __list_splice_rcu (struct list_head *list, +struct list_head *prev, +struct list_head *next) +{ +struct list_head *first = list->next; +struct list_head *last = list->prev; + + last->next = next; + first->prev = prev; + next->prev = last; +rcu_assign_pointer (list_next_rcu (prev), first); +} + +/** +* list_splice_rcu - splice a non-RCU list into an RCU-protected list, +* designed for stacks. +* @list: the non RCU-protected list to splice +* @head: the place in the existing RCU-protected list to splice +* +* The list pointed to by @head can be RCU-read traversed concurrently with +* this function. +*/ +static inline void list_splice_rcu (struct list_head *list, +struct list_head *head) +{ +if (!list_empty (list)) +__list_splice_rcu (list, head, head->next); +} +/** * __list_splice_init_rcu - join an RCU-protected list into an existing list. * @list: the RCU-protected list to splice
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 921/982 netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit a6134e62dba2ea4f760b29d5226907f447c92400 ]
Publish new hooks in the list into the basechain/flowtable using splice_list_rcu() to ensure netlink dump list traversal via rcu is safe while concurrent ruleset update is going on.
--- net/netfilter/nf_tables_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
@@ -9995,8 +9995,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)nft_trans_flowtable (trans), &nft_trans_flowtable_hooks (trans), NFT_MSG_NEWFLOWTABLE); -list_splice (&nft_trans_flowtable_hooks (trans), - &nft_trans_flowtable (trans)->hook_list); +list_splice_rcu (&nft_trans_flowtable_hooks (trans), + &nft_trans_flowtable (trans)->hook_list); }else {nft_clear (net,nft_trans_flowtable (trans)); nf_tables_flowtable_notify(&trans->ctx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 922/982 af_unix: Drop all SCM attributes for SOCKMAP.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 965dc93481d1b80d341bdd16c27b16fe197175ee ]
SOCKMAP can hide inflight fd from AF_UNIX GC.
When a socket in SOCKMAP receives skb with inflight fd, sk_psock_verdict_data_ready() looks up the mapped socket and enqueue skb to its psock->ingress_skb.
Since neither the old nor the new GC can inspect the psock queue, the hidden skb leaks the inflight sockets. Note that this cannot be detected via kmemleak because inflight sockets are linked to a global list.
In addition, SOCKMAP redirect breaks the Tarjan-based GC's assumption that unix_edge.successor is always alive, which is no longer true once skb is redirected, resulting in use-after-free below. [0]
Moreover, SOCKMAP does not call scm_stat_del() properly, so unix_show_fdinfo() could report an incorrect fd count.
sk_msg_recvmsg() does not support any SCM attributes in the first place.
Let's drop all SCM attributes before passing skb to the SOCKMAP layer.
[0]:
BUG: KASAN: slab-use-after-free in unix_del_edges (net/unix/garbage.c:118 net/unix/garbage.c:181 net/unix/garbage.c:251) Read of size 8 at addr ffff888125362670 by task kworker/56:1/496 CPU: 56 UID: 0 PID: 496 Comm: kworker/56:1 Not tainted 7.0.0-rc7-00263-gb9d8b856689d #3 PREEMPT(lazy) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 Workqueue: events sk_psock_backlog Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:122) print_report (mm/kasan/report.c:379) kasan_report (mm/kasan/report.c:597) unix_del_edges (net/unix/garbage.c:118 net/unix/garbage.c:181 net/unix/garbage.c:251) unix_destroy_fpl (net/unix/garbage.c:317) unix_destruct_scm (./include/net/scm.h:80 ./include/net/scm.h:86 net/unix/af_unix.c:1976) sk_psock_backlog (./include/linux/skbuff.h:?) process_scheduled_works (kernel/workqueue.c:?) worker_thread (kernel/workqueue.c:?) kthread (kernel/kthread.c:438) ret_from_fork (arch/x86/kernel/process.c:164) ret_from_fork_asm (arch/x86/entry/entry_64.S:258) </TASK> Allocated by task 955: kasan_save_track (mm/kasan/common.c:58 mm/kasan/common.c:78) __kasan_slab_alloc (mm/kasan/common.c:369) kmem_cache_alloc_noprof (mm/slub.c:4539) sk_prot_alloc (net/core/sock.c:2240) sk_alloc (net/core/sock.c:2301) unix_create1 (net/unix/af_unix.c:1099) unix_create (net/unix/af_unix.c:1169) __sock_create (net/socket.c:1606) __sys_socketpair (net/socket.c:1811) __x64_sys_socketpair (net/socket.c:1863 net/socket.c:1860 net/socket.c:1860) do_syscall_64 (arch/x86/entry/syscall_64.c:?) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Freed by task 496: kasan_save_track (mm/kasan/common.c:58 mm/kasan/common.c:78) kasan_save_free_info (mm/kasan/generic.c:587) __kasan_slab_free (mm/kasan/common.c:287) kmem_cache_free (mm/slub.c:6165) __sk_destruct (net/core/sock.c:2282 net/core/sock.c:2384) sk_psock_destroy (./include/net/sock.h:?) process_scheduled_works (kernel/workqueue.c:?) worker_thread (kernel/workqueue.c:?) kthread (kernel/kthread.c:438) ret_from_fork (arch/x86/kernel/process.c:164) ret_from_fork_asm (arch/x86/entry/entry_64.S:258)
[Lee: Drop skb_orphan() from unix_destruct_scm() and omit the
unix_stream_read_skb() / unix_dgram_read_skb() hunks as 69bbe2bcbe8c and d92fbaccd09a are not present]
--- net/unix/af_unix.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
net/unix/af_unix.c +32 -10
@@ -1784,16 +1784,19 @@ static void unix_peek_fds(struct scm_cookie *scm, struct sk_buff *skb)static void unix_destruct_scm (struct sk_buff *skb) { -struct scm_cookie scm; +struct scm_cookie scm = {}; + +swap (scm.pid,UNIXCB (skb).pid); -memset (&scm,0 ,sizeof (scm)); - scm.pid =UNIXCB (skb).pid;if (UNIXCB (skb).fp)unix_detach_fds (&scm, skb); -/* Alas, it calls VFS */ -/* So fscking what? fput() had been SMP-safe since the last Summer */ scm_destroy (&scm); +} + +static void unix_wfree (struct sk_buff *skb) +{ +unix_destruct_scm (skb);sock_wfree (skb); }
@@ -1809,7 +1812,7 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool senif (scm->fp && send_fds) err =unix_attach_fds (scm, skb); - skb->destructor = unix_destruct_scm; + skb->destructor = unix_wfree;return err; }
@@ -1886,6 +1889,13 @@ static void scm_stat_del(struct sock *sk, struct sk_buff *skb) } } +static void unix_orphan_scm (struct sock *sk,struct sk_buff *skb) +{ +scm_stat_del (sk, skb); +unix_destruct_scm (skb); + skb->destructor = sock_wfree; +} +/* * Send AF_UNIX data. */
@@ -2557,10 +2567,16 @@ static int unix_read_skb(struct sock *sk, skb_read_actor_t recv_actor)int err;mutex_lock (&u->iolock); + skb =skb_recv_datagram (sk,MSG_DONTWAIT , &err); -mutex_unlock (&u->iolock); -if (!skb) +if (!skb) { +mutex_unlock (&u->iolock);return err; + } + +unix_orphan_scm (sk, skb); + +mutex_unlock (&u->iolock);return recv_actor (sk, skb); }
@@ -2716,10 +2732,16 @@ static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)return -ENOTCONN ;mutex_lock (&u->iolock); + skb =skb_recv_datagram (sk,MSG_DONTWAIT , &err); -mutex_unlock (&u->iolock); -if (!skb) +if (!skb) { +mutex_unlock (&u->iolock);return err; + } + +unix_orphan_scm (sk, skb); + +mutex_unlock (&u->iolock);#if IS_ENABLED (CONFIG_AF_UNIX_OOB )if (unlikely (skb ==READ_ONCE (u->oob_skb))) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 923/982 net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanglei Zhu <[email protected]>
commit c7ead9704249d57d4693a04697e3bbd285138fa9 upstream.
The netif index carried in the DPMAIF PIT header is five bits wide, but ccmni_inst[] only has room for NIC_DEV_MAX (21) entries. t7xx_ccmni_recv_skb() indexes the array without a bounds check, so indexes 21 to 31 read past it. The out-of-bounds value lands in the callback table that follows the array, which is never NULL, so the existing !ccmni check does not catch it and the driver dereferences whatever sits there as a struct t7xx_ccmni.
Drop the skb when the index is out of range.
--- drivers/net/wwan/t7xx/t7xx_netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wwan/t7xx/t7xx_netdev.c +4 -0
@@ -321,6 +321,10 @@ static void t7xx_ccmni_recv_skb(struct t7xx_pci_dev *t7xx_dev, struct sk_buff *s skb_cb =T7XX_SKB_CB (skb); netif_id = skb_cb->netif_idx; +if (netif_id >=NIC_DEV_MAX ) { +dev_kfree_skb (skb); +return ; + } ccmni = t7xx_dev->ccmni_ctlb->ccmni_inst[netif_id];if (!ccmni) {dev_kfree_skb (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 924/982 x86/PCI: Disable enhanced atomics on AMD NBIO 7.7 and 7.11
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 4fde448225123442c5796f54b7a4400e2d3cbaf6 upstream.
Multiple users report data corruption during 64-bit DMA transfers on systems with AMD NBIO 7.7 and 7.11 controllers.
This occurs when BIOS enables AMD "enhanced atomic operations" on PCIe Root Ports. When enhanced atomics are enabled, any 64-bit DMA access may be corrupted.
Disable enhanced atomics using SMN for NBIO 7.7 and 7.11 based models.
--- arch/x86/pci/fixup.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
arch/x86/pci/fixup.c +99 -0
@@ -844,4 +844,103 @@ static void quirk_clear_strap_no_soft_re } }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,0x15b8 , quirk_clear_strap_no_soft_reset_dev2_f0); + +/* +* Enhanced atomic operations can cause corruption with 64-bit DMA +* on these devices. +*/ +#define RX_ENH_ATOMIC_EN BIT(8) + +static const u32 nbio_7_7_pcie_smn_addrs[] = { +0x111401d0 , +0x111411d0 , +0x111421d0 , +0x111431d0 , +0x111441d0 , +0x112401d0 , +0x112411d0 , +0x112421d0 , +0x112431d0 , +0x112441d0 , +0x112451d0 , +0x113401d0 , +0x114401d0 , +}; + +static const u32 nbio_7_11_pcie_smn_addrs[] = { +0x112401d0 , +0x112411d0 , +0x112421d0 , +0x112431d0 , +0x112441d0 , +0x112451d0 , +0x113401d0 , +0x113411d0 , +0x113421d0 , +0x113431d0 , +0x113441d0 , +0x113451d0 , +}; + +static void quirk_amd_nbio_enhanced_atomic (struct pci_dev *host_bridge, +const u32 *smn_addrs, +size_t nr_smn_addrs) +{ +bool changed = false; +size_t i; +u32 data; +int ret; + +for (i =0 ; i < nr_smn_addrs; i++) { + ret =amd_smn_read (0 , smn_addrs[i], &data); +if (ret) +continue ; +if (!(data &RX_ENH_ATOMIC_EN )) +continue ; + data = data & ~RX_ENH_ATOMIC_EN ; + ret =amd_smn_write (0 , smn_addrs[i], data); +if (ret) +continue ; +if (changed) +continue ; + ret =amd_smn_read (0 , smn_addrs[i], &data); +if (ret) +continue ; +if (data &RX_ENH_ATOMIC_EN ) +continue ; + changed = true; + } + +if (changed) +pci_info (host_bridge,"enhanced atomics disabled\n" ); +} + +static void quirk_amd_nbio_7_7_disable_enhanced_atomic (struct pci_dev *dev) +{ +quirk_amd_nbio_enhanced_atomic (dev, nbio_7_7_pcie_smn_addrs, +ARRAY_SIZE (nbio_7_7_pcie_smn_addrs)); +} + +static void quirk_amd_nbio_7_11_disable_enhanced_atomic (struct pci_dev *dev) +{ +quirk_amd_nbio_enhanced_atomic (dev, nbio_7_11_pcie_smn_addrs, +ARRAY_SIZE (nbio_7_11_pcie_smn_addrs)); +} + +/* Phoenix, Hawk Point (NBIO 7.7) */ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,0x14E8 , + quirk_amd_nbio_7_7_disable_enhanced_atomic); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_AMD ,0x14E8 , + quirk_amd_nbio_7_7_disable_enhanced_atomic); + +/* Strix, Krackan, Strix Halo (NBIO 7.11) */ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,0x1507 , + quirk_amd_nbio_7_11_disable_enhanced_atomic); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_AMD ,0x1507 , + quirk_amd_nbio_7_11_disable_enhanced_atomic); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AMD ,0x1122 , + quirk_amd_nbio_7_11_disable_enhanced_atomic); +DECLARE_PCI_FIXUP_RESUME (PCI_VENDOR_ID_AMD ,0x1122 , + quirk_amd_nbio_7_11_disable_enhanced_atomic); +#endif
Greg Kroah-Hartman
maintainerPATCH 925/982 tipc: reject invalid and unexpected GRP_ACK_MSG to prevent bc_ackers underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 99cc2a62e07a44a22254d7beca9ef1f8ad886d0d upstream.
Commit 48a5fe38772b ("tipc: fix bc_ackers underflow on duplicate GRP_ACK_MSG") rejected duplicate/stale ACKs in tipc_group_proto_rcv() by returning early when less_eq(acked, m->bc_acked).
However, that check remains incomplete in two ways:
1. When grp->bc_ackers is zero (e.g. on a quiet group, when replicast ACKs were not requested, or after all expected members have already acknowledged), an unexpected GRP_ACK_MSG with acked > m->bc_acked passes less_eq() and unconditionally decrements grp->bc_ackers. Because bc_ackers is a u16, this wraps to 65535, causing tipc_group_bc_cong() to permanently report congestion and blocking all future group broadcasts on the socket.
2. During an active broadcast round (grp->bc_ackers > 0), the sender transmits packet S and advances grp->bc_snd_nxt to S + 1. Receivers increment their expected counter to S + 1 upon consuming packet S, so the only valid ACK value for the current round is strictly acked == grp->bc_snd_nxt.
However, tipc_group_update_bc_members() initializes each member's m->bc_acked to prev = grp->bc_snd_nxt - 1 (S - 1 before increment). This leaves a 2-sequence gap (S - 1 to S + 1) in sequence space. An incoming ACK is therefore neither rejected as duplicate nor prevented from decrementing grp->bc_ackers if an unexpected or stale value (such as S) is received. A member sending acked = S followed by acked = S + 1 could decrement grp->bc_ackers twice in the same round, prematurely clearing bc_ackers or underflowing it.
Fix this by:
- Dropping GRP_ACK_MSG immediately if grp->bc_ackers is zero.
- Requiring acked == grp->bc_snd_nxt and rejecting duplicates where m->bc_acked == acked. Because replicast broadcast rounds are strictly sequential, only grp->bc_snd_nxt can be acknowledged, and each member can acknowledge at most once per round.
Note that a related pre-existing issue in tipc_group_delete_member() (where grp->bc_ackers decrementing to zero upon member departure does not restore *grp->open or trigger a socket wakeup) will be addressed in a separate patch.
--- net/tipc/group.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tipc/group.c +2 -2
@@ -797,10 +797,10 @@ void tipc_group_proto_rcv(struct tipc_grtipc_group_open (m, usr_wakeup);return ;case GRP_ACK_MSG : -if (!m) +if (!m || !grp->bc_ackers)return ; acked =msg_grp_bc_acked (hdr); -if (less_eq (acked, m->bc_acked)) +if (acked != grp->bc_snd_nxt || m->bc_acked == acked)return ; m->bc_acked = acked;if (--grp->bc_ackers)
Greg Kroah-Hartman
maintainerPATCH 926/982 sctp: discard the rest of the packet on a stale-cookie error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit 4498467a8af06cfa3d71cb04bd7c4170dec8f449 upstream.
When an association is in COOKIE-ECHOED state and the peer sends a bundled [ERROR(Stale Cookie)][DATA] packet from one of its non-primary addresses, processing the ERROR chunk takes the non-fatal stale-cookie retry path sctp_sf_do_5_2_6_stale(), which queues SCTP_CMD_DEL_NON_PRIMARY while keeping the association alive. sctp_cmd_del_non_primary() removes every non-primary transport - including the very transport this packet arrived on, which is still referenced by the receive lookup and shared by all chunks of the packet via chunk->transport.
sctp_assoc_rm_peer() does redirect asoc->peer.last_data_from away from the removed transport, but right afterwards the bundled DATA chunk makes sctp_assoc_bh_rcv() re-register asoc->peer.last_data_from = chunk->transport unconditionally, undoing the redirection with the just-removed transport.
Once the packet is done, the receive reference is dropped and the transport is RCU-freed, while the surviving association keeps the dangling last_data_from. A later FWD-TSN (or the delayed SACK timer) makes sctp_gen_sack() dereference it (->param_flags and friends), and sctp_make_sack()/sctp_outq_select_transport() may write to the freed object and link it into the live transport list. This is a use-after-free triggerable by any malicious SCTP peer (or a local unprivileged user acting as one) with no capabilities required:
BUG: KASAN: slab-use-after-free in sctp_do_sm+0x498a/0x5660
Read of size 4 at addr ffff88800e1e356c by task poc/115
Call Trace: sctp_do_sm <- sctp_assoc_bh_rcv <- sctp_inq_push <-
sctp_rcv <- ip_protocol_deliver_rcu <- ip_rcv
Allocated: sctp_transport_new <- sctp_assoc_add_peer <-
sctp_process_init (INIT-ACK processing)
Freed: kfree <- sctp_transport_destroy_rcu <- rcu_core
(call_rcu queued by sctp_transport_put at end of sctp_rcv)
The buggy address is located 364 bytes inside of freed 1024-byte
region [ffff88800e1e3400, ffff88800e1e3800), cache kmalloc-1kNote that commit 03a9d10ecf71 ("sctp: drop a chunk if its transport was removed") only covers the window between the receive lookup and the chunk processing (e.g. an ASCONF DEL-IP racing the socket backlog); here the transport is removed *while* the packet is being processed, by an earlier chunk of the same packet, so the drop in sctp_inq_push() does not reach this path. Verified with the bundled [ERROR(Stale Cookie)][DATA] + FWD-TSN reproducer: the KASAN report above still fires with that commit applied, and is gone with this patch on top.
Fix it by discarding the rest of the packet on this path, as suggested by Xin. After the stale-cookie ERROR has sent the association back to COOKIE-WAIT and removed the non-primary transports, the remaining chunks of the packet can only run against the restarted handshake while referencing the removed arrival transport through chunk->transport: besides the last_data_from registration above, sctp_cmd_setup_t2() and the sctp_make_*() reply builders would also copy that pointer into association-lifetime state that sctp_assoc_rm_peer() has already sanitized. Let the peer retransmit them, in line with what sctp_inq_push() does for chunks whose transport was removed before processing.
--- net/sctp/sm_statefuns.c | 2 ++ 1 file changed, 2 insertions(+)
net/sctp/sm_statefuns.c +2 -0
@@ -2625,6 +2625,8 @@ static enum sctp_disposition sctp_sf_do_sctp_add_cmd_sf (commands,SCTP_CMD_REPLY ,SCTP_CHUNK (reply)); +sctp_add_cmd_sf (commands,SCTP_CMD_DISCARD_PACKET ,SCTP_NULL ()); +return SCTP_DISPOSITION_CONSUME ; nomem:
Greg Kroah-Hartman
maintainerPATCH 927/982 af_packet: fix integer overflow in prb_calc_retire_blk_tmo()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dairui Zhang <[email protected]>
commit 56d82862a0a243ac14ba11b6d7b57ddc2d064b95 upstream.
prb_calc_retire_blk_tmo() computes in 32-bit int arithmetic:
mbits = (blk_size_in_bytes * 8) / (1024 * 1024);
If I'm reading the validation right, tp_block_size is user controlled and packet_set_ring() only rejects values that are <= 0 as int or not page aligned, so a 256MiB block goes right through (and alloc_one_pg_vec_page() even has a vzalloc fallback for it). 0x10000000 * 8 wraps to INT_MIN, and on a NIC reporting 1 Gbps (div == 1) the function ends up returning -2047.
The condition is actually (8 * size) mod 2^32 >= 2^31 && div == 1, so the trigger set is [256,512), [768,1024), [1280,1536) and [1792,2048) MiB. Other sizes wrap to non-negative values and faster links divide the unsigned value back below 2^31, which is why this doesn't blow up for everyone.
What makes it fatal is what happens next in init_prb_bdqc():
p1->interval_ktime = ms_to_ktime(prb_calc_retire_blk_tmo(...));
hrtimer_start(&p1->retire_blk_timer, p1->interval_ktime,
HRTIMER_MODE_REL_SOFT);A negative relative timeout expires immediately. The callback unconditionally returns HRTIMER_RESTART, and hrtimer_forward() turns the negative interval into hrtimer_resolution:
if (interval < hrtimer_resolution)
interval = hrtimer_resolution;
So the SOFT timer re-fires at the maximum rate forever, holding sk_receive_queue.lock each pass. One CPU spins in softirq until the socket is closed. Repeat with more rings and the machine is gone.
The overflow itself is ancient - it was introduced together with TPACKET_V3 in f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation."). Its effect prior to f7460d2989fa ("net:af_packet: Use hrtimer to do the retire operation", v6.18) was not as clear-cut, though: the return value was stored into an unsigned short retire_blk_tov, so a negative result was truncated, and a 0-jiffy delay loop could be programmed as well. Neither is nearly as detrimental as the immediate maximum-rate spin the hrtimer conversion turned it into.
(Unrelated to CVE-2019-20812 - that one was the ethtool failure path returning 0, which now returns DEFAULT_PRB_RETIRE_TOV.)
Reproducer, needs CAP_NET_RAW (a --network host container has it by default) and a 1 Gbps NIC (QEMU e1000 works):
int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
bind(fd, ...);
int v = TPACKET_V3;
setsockopt(fd, SOL_PACKET, PACKET_VERSION, &v, sizeof(v));
struct tpacket_req3 req = {
.tp_block_size = 0x10000000,
.tp_block_nr = 1,
.tp_frame_size = 2048,
.tp_frame_nr = 0x10000000 / 2048,
.tp_retire_blk_tov = 0,
};
setsockopt(fd, SOL_PACKET, PACKET_RX_RING, &req, sizeof(req));Compute in 64 bits instead. The operands are already bounded by the existing validation, so nothing else changes. If you'd prefer a different fix, just say so and I'll respin.
--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
@@ -638,7 +638,7 @@ static int prb_calc_retire_blk_tmo(strucreturn DEFAULT_PRB_RETIRE_TOV ; div = ecmd.base.speed /1000 ; - mbits = (blk_size_in_bytes *8 ) / (1024 *1024 ); + mbits = (u64 )blk_size_in_bytes *8 / (1024 *1024 );if (div) mbits /= div;
Greg Kroah-Hartman
maintainerPATCH 928/982 fou: reject omitted FOU_ATTR_IPPROTO on FOU_ENCAP_DIRECT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit d22609f3d13fc5baacd92c222731b03c593401db upstream.
Commit 7a9bc9e3f423 ("fou: Don't allow 0 for FOU_ATTR_IPPROTO.") added NLA_POLICY_MIN(NLA_U8, 1) to fou_nl_policy[FOU_ATTR_IPPROTO], which rejects an explicitly supplied FOU_ATTR_IPPROTO == 0 attribute with -ERANGE.
However, FOU_ATTR_IPPROTO is an optional netlink attribute. When a user sends FOU_CMD_ADD with FOU_ATTR_TYPE set to FOU_ENCAP_DIRECT and omits FOU_ATTR_IPPROTO entirely, nla_policy validation succeeds and parse_nl_config() leaves cfg->protocol as 0 (from memset(cfg, 0, sizeof(*cfg))). fou_create() then creates a FOU_ENCAP_DIRECT socket with fou->protocol == 0.
In fou_udp_recv(), returning -fou->protocol to udp_queue_rcv_one_skb() triggers IP protocol resubmission when fou->protocol > 0, whereas returning 0 tells the UDP tunnel layer that the skb was consumed without freeing it. When fou->protocol == 0, every packet received on the socket returns 0 from fou_udp_recv() and leaks the sk_buff.
Reject FOU_ENCAP_DIRECT when !cfg->protocol in fou_create() so that creating a direct encapsulation port without FOU_ATTR_IPPROTO fails with -EINVAL while leaving FOU_CMD_DEL and FOU_CMD_GET (which share parse_nl_config()) unaffected.
Tested in QEMU against Linux 7.3.0-rc3 by sending a FOU_CMD_ADD Generic Netlink request with FOU_ATTR_PORT = 5555 and FOU_ATTR_TYPE = FOU_ENCAP_DIRECT while omitting FOU_ATTR_IPPROTO. On the unfixed kernel, FOU_CMD_ADD succeeds (err = 0), FOU_CMD_GET reports fou->type = 1 and fou->protocol = 0, and sending 4000 UDP packets to 127.0.0.1:5555 leaks all 4000 sk_buffs (SUnreclaim in /proc/meminfo grows from 41456 kB to 59008 kB, +17552 kB); with this patch applied, FOU_CMD_ADD is rejected with -EINVAL (-22).
--- net/ipv4/fou_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/fou_core.c +4 -0
@@ -607,6 +607,10 @@ static int fou_create(struct net *net, s/* Initial for fou type */ switch (cfg->type) {case FOU_ENCAP_DIRECT : +if (!cfg->protocol) { + err = -EINVAL ; + goto error; + } tunnel_cfg.encap_rcv = fou_udp_recv; tunnel_cfg.gro_receive = fou_gro_receive; tunnel_cfg.gro_complete = fou_gro_complete;
Greg Kroah-Hartman
maintainerPATCH 929/982 writeback: bound cleanup_offline_cgwb() rescans by rotating scanned inodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Lu (Anthropic) <[email protected]>
commit f6988c90671e83db79df1b7b9d6fdb0e5947fd84 upstream.
cleanup_offline_cgwb() prepares at most WB_MAX_INODES_PER_ISW inodes per call and is called again until the dying wb is drained, but every call walks wb->b_attached and then wb->b_dirty_time from the same end. Inodes already prepared (they stay on the list with I_WB_SWITCH set until the switch worker runs) and inodes that cannot be switched (I_FREEING, I_WILL_FREE, !SB_ACTIVE, DAX, already on the target wb) stay where they are, so each pass rescans a growing run of them under wb->list_lock and a full drain is quadratic in the number of inodes on the list. With ~17M inodes attached to one dying cgwb we saw this end in soft lockups, with CPUs reported stuck for 21-48s.
Walk both lists from the oldest end and move every scanned inode to the newest end, so the next pass starts where the previous one stopped and the drain becomes linear. b_attached is unordered, so nobody sees the reorder there. b_dirty_time is ordered by dirtied_when, but the oldest unscanned inode stays at the end move_expired_inodes() picks from, sync takes the whole list regardless of order, and prepared inodes leave the list as soon as the switch work runs and get a new dirtied_time_when on the new wb anyway, so the only inodes left out of order are the ones that can never switch (DAX), and only on the dying wb.
--- fs/fs-writeback.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
fs/fs-writeback.c +20 -5
@@ -667,19 +667,34 @@ static bool isw_prepare_wbs_switch(strucstruct inode_switch_wbs_context *isw, struct list_head *list, int *nr) { - struct inode *inode; + struct inode *inode, *tmp; +LIST_HEAD (scanned); +bool full = false; + +/* +* Walk from the oldest end and move scanned inodes to the newest +* end, so the next scan resumes at unscanned inodes instead of +* re-walking an ever-growing run of prepared and skipped ones. +* For b_dirty_time this keeps the oldest unscanned inode at the +* end move_expired_inodes() picks from; b_attached is unordered. +*/ +list_for_each_entry_safe_reverse (inode, tmp, list, i_io_list) { +list_move (&inode->i_io_list, &scanned); -list_for_each_entry (inode, list, i_io_list) {if (!inode_prepare_wbs_switch (inode, new_wb))continue ; isw->inodes[*nr] = inode; (*nr)++; -if (*nr >=WB_MAX_INODES_PER_ISW -1 ) -return true; +if (*nr >=WB_MAX_INODES_PER_ISW -1 ) { + full = true; +break ; + } } -return false; +list_splice (&scanned, list); + +return full; }/**
Greg Kroah-Hartman
maintainerPATCH 930/982 workqueue: Fix NULL current_pwq deref in flush dependency check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavankumar Kondeti <[email protected]>
commit db6365ced4d5855e321f772b240c0e473bcfcdd5 upstream.
check_flush_dependency() uses current_wq_worker() to determine whether the caller is a workqueue worker and then dereferences worker->current_pwq to test whether the current workqueue is WQ_MEM_RECLAIM.
current_wq_worker() only means that %current has PF_WQ_WORKER set. A kworker can reach check_flush_dependency() while it is not executing a work item. One such path is worker_thread() acting as the pool manager, where create_worker() does GFP_KERNEL allocation and the allocation path invokes the OOM notifier. In that state worker->current_pwq is NULL because current_pwq is set only by process_one_work() and cleared again after the work function returns.
[ 416.760634][ T375] Call trace: [ 416.760638][ T375] check_flush_dependency+0x80/0x120 (P) [ 416.760648][ T375] __flush_work+0x98/0x224 [ 416.760657][ T375] flush_work+0x30/0x44 [ 416.760665][ T375] ... [ 416.760710][ T375] blocking_notifier_call_chain+0x58/0xa0 [ 416.760719][ T375] out_of_memory+0xb4/0x458 [ 416.760730][ T375] __alloc_pages_may_oom+0x11c/0x1a8 [ 416.760739][ T375] __alloc_pages_slowpath+0x314/0x46c [ 416.760746][ T375] __alloc_frozen_pages_noprof+0x110/0x1a4 [ 416.760753][ T375] new_slab+0x12c/0x484 [ 416.760759][ T375] ___slab_alloc+0x7a8/0xc7c [ 416.760765][ T375] __slab_alloc+0x74/0xd8 [ 416.760772][ T375] __kmalloc_cache_node_noprof+0x2ac/0x304 [ 416.760779][ T375] alloc_worker+0x28/0x60 [ 416.760785][ T375] create_worker+0x4c/0x20c [ 416.760790][ T375] worker_thread+0xe8/0x2b8 [ 416.760796][ T375] kthread+0x1a8/0x200 [ 416.760805][ T375] ret_from_fork+0x10/0x20
Guard the WQ_MEM_RECLAIM-worker warning with worker->current_pwq. If the kworker is not currently executing a work item, there is no current workqueue to diagnose with that warning. The PF_MEMALLOC warning is left unchanged so explicit reclaim context flushing a !WQ_MEM_RECLAIM target is still reported.
--- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
@@ -2628,7 +2628,7 @@ static void check_flush_dependency(strucWARN_ONCE (current->flags &PF_MEMALLOC ,"workqueue: PF_MEMALLOC task %d(%s) is flushing !WQ_MEM_RECLAIM %s:%ps" , current->pid, current->comm, target_wq->name, target_func); - WARN_ONCE(worker && ((worker->current_pwq->wq->flags & + WARN_ONCE(worker && worker->current_pwq && ((worker->current_pwq->wq->flags & (WQ_MEM_RECLAIM | __WQ_LEGACY)) == WQ_MEM_RECLAIM), "workqueue: WQ_MEM_RECLAIM %s:%ps is flushing !WQ_MEM_RECLAIM %s:%ps", worker->current_pwq->wq->name, worker->current_func,
Greg Kroah-Hartman
maintainerPATCH 931/982 writeback: report a Tasks-RCU quiescent state per cgwb drain pass
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 407a5d205179a4ab186571b0e16ec42725dc77bc upstream.
cleanup_offline_cgwbs_workfn() drains a dying cgwb by calling cleanup_offline_cgwb() until it returns false, with a cond_resched() between passes. On a CONFIG_PREEMPTION kernel that cond_resched() does
nothing: _cond_resched() is a plain "return 0", and under PREEMPT_DYNAMIC the full and lazy modes disable it. Since commit 7dadeaa6e851 ("sched:
Further restrict the preemption modes") those are the only two models on the architectures with PREEMPT_LAZY support, arm64 and x86 among them, so the drain loop never reports a Tasks-RCU quiescent state.
A worker draining a cgwb with millions of attached inodes runs for minutes. On a 6.18 arm64 host in lazy mode the cgwb worker drained one dying cgroup's writeback domain for over 11 minutes. A BPF program unlink (bpf_trampoline_unlink_prog -> bpf_trampoline_update -> unregister_ftrace_direct -> ftrace_shutdown -> synchronize_rcu_tasks()) waited on that grace period while holding the trampoline mutex, 42 tasks queued behind it in D state, and the hung task detector fired at 614 s and panicked the host. Any BPF or ftrace detach during a long drain inherits the drain's length.
Fix this by calling cond_resched_tasks_rcu_qs() so we do not stall out anybody who calls sycnrhonize_rcu_tasks(). We put this in a do { } while loop because if we have many small cgroups cleanup_offline_cgwb() will return false and we will never call cond_resched_tasks_rcu_qs(), creating the same problem.
--- mm/backing-dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/backing-dev.c +3 -2
@@ -694,8 +694,9 @@ static void cleanup_offline_cgwbs_workfncontinue ;spin_unlock_irq (&cgwb_lock); -while (cleanup_offline_cgwb (wb)) -cond_resched (); +do { +cond_resched_tasks_rcu_qs (); + }while (cleanup_offline_cgwb (wb));spin_lock_irq (&cgwb_lock);wb_put (wb);
Greg Kroah-Hartman
maintainerPATCH 932/982 fsl/fman: Fix clk reference leak in read_dts_node()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit a644f09b2090ad22a13fbcf9d141084f573108ef upstream.
of_clk_get() returns a clock with its reference count incremented, but read_dts_node() only uses it to read the rate and never calls clk_put(). The clock is not stored anywhere, so the reference cannot be released later either.
Release the clock once its rate has been read, which also covers the error path taken when the rate is zero.
--- drivers/net/ethernet/freescale/fman/fman.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/fman/fman.c +1 -0
@@ -2747,6 +2747,7 @@ static struct fman *read_dts_node(struct } clk_rate =clk_get_rate (clk); +clk_put (clk);if (!clk_rate) { err = -EINVAL ; dev_err(&of_dev->dev, "%s: Failed to determine FM%d clock rate\n",
Greg Kroah-Hartman
maintainerPATCH 933/982 ipv6: do not let ipv6_find_hdr() return an offset past the packet end
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
commit ee319bd3a0e976af5087cbe59ebc50a66f31d202 upstream.
ipv6_find_hdr() walks the extension header chain, skipping each header by the length that header itself declares. ipv6_optlen() returns up to 2048, and the skip is never checked against skb->len, so the offset stored in *offset can point past the end of the packet.
openvswitch installs that offset as the transport header, and update_ipv6_checksum() then reads and writes the transport checksum field out of bounds:
BUG: KASAN: slab-use-after-free in inet_proto_csum_replace16+0x445/0x470 Read of size 2 at addr ffff88810b754b06 by task ovs_ipv6_oob/629 CPU: 4 UID: 1000 PID: 629 Comm: ovs_ipv6_oob Tainted: G N 7.3.0-rc3+ #348 Call Trace: inet_proto_csum_replace16+0x445/0x470 set_ipv6_addr+0x3dd/0x460 do_execute_actions+0x6a3d/0x7c40 ovs_execute_actions+0xfd/0x480 ovs_packet_cmd_execute+0xc38/0xf20 genl_rcv_msg+0x59e/0x870 netlink_rcv_skb+0x18b/0x450 genl_rcv+0x2d/0x40 netlink_unicast+0x6bc/0xa20 The buggy address belongs to the object at ffff88810b754980 which belongs to the cache skbuff_small_head of size 704 The buggy address is located 390 bytes inside of freed 704-byte region [ffff88810b754980, ffff88810b754c40)
Other callers use that offset too, so bound it here rather than in one caller.
Reject a header whose declared length does not fit in the packet. ipv6_find_hdr() already fails with -EBADMSG on a malformed chain, so this adds no new failure mode.
--- net/ipv6/exthdrs_core.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/exthdrs_core.c +3 -0
@@ -271,6 +271,9 @@ int ipv6_find_hdr(const struct sk_buff * hdrlen =ipv6_optlen (hp);if (!found) { +if (skb->len - start < hdrlen) +return -EBADMSG ; + nexthdr = hp->nexthdr; start += hdrlen; }
Greg Kroah-Hartman
maintainerPATCH 934/982 ipv6: sr: enforce exact attribute length for SEG6_ATTR_DST
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit 2d959c75c27f90e9ec489d18ce5ee6b852ad4741 upstream.
In seg6_genl_policy, SEG6_ATTR_DST is defined with .type = NLA_BINARY and .len = sizeof(struct in6_addr). For NLA_BINARY, .len only enforces the maximum payload length and permits shorter payloads (e.g., 0 bytes). When seg6_genl_set_tunsrc() copies sizeof(struct in6_addr) bytes via kmemdup(val, sizeof(*val), GFP_KERNEL), a short SEG6_ATTR_DST attribute triggers a 16-byte out-of-bounds read past skb->tail into uninitialized skb->head memory, which is stored in sdata->tun_src and leaked back to userspace via SEG6_CMD_GET_TUNSRC.
Switch SEG6_ATTR_DST in seg6_genl_policy to NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)) so that generic netlink validation rejects any attribute whose length is not exactly sizeof(struct in6_addr) with -ERANGE.
Tested in QEMU against Linux 7.3.0-rc3 by sending a SEG6_CMD_SET_TUNSRC Generic Netlink message with a 0-byte SEG6_ATTR_DST attribute followed by SEG6_CMD_GET_TUNSRC. On the unfixed kernel, SEG6_CMD_SET_TUNSRC succeeds (err = 0) and SEG6_CMD_GET_TUNSRC leaks 16 bytes of uninitialized kernel heap memory (tun_src = 836a61ecc4d25a1042a8d60411cfb378); with this patch applied, SEG6_CMD_SET_TUNSRC is rejected by netlink policy validation with -ERANGE (-34) and tun_src remains zeroed.
--- net/ipv6/seg6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/seg6.c +2 -2
@@ -140,8 +140,8 @@ out:static struct genl_family seg6_genl_family;static const struct nla_policy seg6_genl_policy[SEG6_ATTR_MAX +1 ] = { - [SEG6_ATTR_DST ] = { .type =NLA_BINARY , - .len =sizeof (struct in6_addr ) }, + [SEG6_ATTR_DST ] = +NLA_POLICY_EXACT_LEN (sizeof (struct in6_addr )), [SEG6_ATTR_DSTLEN ] = { .type =NLA_S32 , }, [SEG6_ATTR_HMACKEYID ] = { .type =NLA_U32 , }, [SEG6_ATTR_SECRET ] = { .type =NLA_BINARY , },
Greg Kroah-Hartman
maintainerPATCH 935/982 gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit e9d810279f84b30738f7790c0ed15f8dd5b9024a upstream.
Switching a persistent GPIO line from input to output acquires a runtime PM reference on the parent device, but if the subsequent regmap_update_bits() fails the reference is never dropped and no later direction_in() can balance it since the direction was never changed. Drop the reference on the update failure path.
--- drivers/gpio/gpio-arizona.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpio/gpio-arizona.c +6 -2
@@ -118,8 +118,12 @@ static int arizona_gpio_direction_out(stif (value) value =ARIZONA_GPN_LVL ; -return regmap_update_bits (arizona->regmap,ARIZONA_GPIO1_CTRL + offset, -ARIZONA_GPN_DIR |ARIZONA_GPN_LVL , value); + ret =regmap_update_bits (arizona->regmap,ARIZONA_GPIO1_CTRL + offset, +ARIZONA_GPN_DIR |ARIZONA_GPN_LVL , value); +if (ret <0 && (val &ARIZONA_GPN_DIR ) && persistent) +pm_runtime_put_autosuspend (chip->parent); + +return ret; }static void arizona_gpio_set (struct gpio_chip *chip,unsigned offset,int value)
Greg Kroah-Hartman
maintainerPATCH 936/982 gpio: zynq: fix runtime PM leak on request error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
commit e9438ab5328a177c9c0e5df87eb92a7162841e98 upstream.
pm_runtime_get_sync() leaves the usage counter incremented even when it fails, and zynq_gpio_request() returns the error without dropping it.
gpiolib does not call ->free() when ->request() fails, so zynq_gpio_free(), which holds the only matching pm_runtime_put(), never runs. The reference is leaked and the controller can no longer runtime-suspend, so its clock stays enabled.
Switch to pm_runtime_resume_and_get(), which only increments the usage counter on success.
--- drivers/gpio/gpio-zynq.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpio/gpio-zynq.c +1 -9
@@ -789,15 +789,7 @@ static int __maybe_unused zynq_gpio_runtstatic int zynq_gpio_request (struct gpio_chip *chip,unsigned int offset) { -int ret; - - ret =pm_runtime_get_sync (chip->parent); - -/* -* If the device is already active pm_runtime_get() will return 1 on -* success, but gpio_request still needs to return 0. -*/ -return ret <0 ? ret :0 ; +return pm_runtime_resume_and_get (chip->parent); }static void zynq_gpio_free (struct gpio_chip *chip,unsigned int offset)
Greg Kroah-Hartman
maintainerPATCH 937/982 llc: reserve device headroom for allocated frames
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zixuan Chai <[email protected]>
commit 72b5b9a28b996e09b8b5b944370c79851bb68f52 upstream.
llc_alloc_frame() reserves link-layer headroom using the device type. This is insufficient for stacked Ethernet devices such as VLAN devices, where vlan_dev_hard_header() pushes a VLAN header before the lower device's Ethernet header. An LLC response on such a device can therefore underflow skb headroom in eth_header().
Use LL_RESERVED_SPACE() to account for the device's actual required headroom while preserving the existing LLC device-type check.
--- net/llc/llc_sap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/llc/llc_sap.c +4 -4
@@ -25,12 +25,12 @@#include <linux/llc.h> #include <linux/slab.h> -static int llc_mac_header_len (unsigned short devtype) +static int llc_mac_header_len (struct net_device *dev) { -switch (devtype) { +switch (dev->type) {case ARPHRD_ETHER :case ARPHRD_LOOPBACK : -return sizeof (struct ethhdr ); +return LL_RESERVED_SPACE (dev); }return 0 ; }
@@ -51,7 +51,7 @@ struct sk_buff *llc_alloc_frame(struct sint hlen = type ==LLC_PDU_TYPE_U ?3 :4 ;struct sk_buff *skb; - hlen +=llc_mac_header_len (dev->type); + hlen +=llc_mac_header_len (dev); skb =alloc_skb (hlen + data_size,GFP_ATOMIC );if (skb) {
Greg Kroah-Hartman
maintainerPATCH 938/982 rds: ib: Clear the sg list when mapping an MR fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dongliang Qin <[email protected]>
commit 58eb1b3325edac42dc6df72c80962bd53a3c8ca7 upstream.
rds_ib_map_frmr() stores the caller's scatterlist in the MR before DMA mapping and registration can fail. On failure, __rds_rdma_map() unpins the pages and frees the scatterlist, but rds_ib_free_frmr() can still return the MR to the pool with the stale pointer set.
This leaves the pool with a dangling scatterlist and can lead to local privilege escalation. KASAN detects the resulting use-after-free when the MR is later torn down:
BUG: KASAN: slab-use-after-free in __rds_ib_teardown_mr Read of size 8 Call Trace: __rds_ib_teardown_mr rds_ib_unreg_frmr rds_ib_flush_mr_pool rds_ib_flush_mrs rds_free_mr rds_setsockopt
Store the scatterlist in the MR only after DMA mapping succeeds. If DMA mapping fails, return directly while the MR fields remain clear; the caller keeps ownership of the scatterlist and its pinned pages. If a later registration step fails, unmap the scatterlist and clear the MR fields before returning.
--- net/rds/ib_frmr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/rds/ib_frmr.c +5 -6
@@ -204,19 +204,16 @@ static int rds_ib_map_frmr(struct rds_ib*/ rds_ib_teardown_mr (ibmr); - ibmr->sg = sg; - ibmr->sg_len = sg_len; - ibmr->sg_dma_len =0 ; frmr->sg_byte_len =0 ; -WARN_ON (ibmr->sg_dma_len); - ibmr->sg_dma_len =ib_dma_map_sg (dev, ibmr->sg, ibmr->sg_len, + ibmr->sg_dma_len =ib_dma_map_sg (dev, sg, sg_len,DMA_BIDIRECTIONAL );if (unlikely (!ibmr->sg_dma_len)) {pr_warn ("RDS/IB: %s failed!\n" , __func__);return -EBUSY ; } - frmr->sg_byte_len =0 ; + ibmr->sg = sg; + ibmr->sg_len = sg_len; frmr->dma_npages =0 ; len =0 ;
@@ -264,6 +261,8 @@ out_unmap:ib_dma_unmap_sg (rds_ibdev->dev, ibmr->sg, ibmr->sg_len,DMA_BIDIRECTIONAL ); ibmr->sg_dma_len =0 ; + ibmr->sg =NULL ; + ibmr->sg_len =0 ;return ret; }
Greg Kroah-Hartman
maintainerPATCH 939/982 drm/i915: fix incorrect RCU teardown order
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit d2da6696e0c4e60414706e607029d0bb0330c67e upstream.
i915_gem_busy_ioctl uses dma_resv_for_each_fence_unlocked() to iterate over the fences in an GEM object without holding a reference but only the RCU read side lock.
What can happen here is that the GEM object is destroyed concurrently while i915_gem_busy_ioctl is still running. This won't free the GEM objects memory, but still drops all the dma_fence references.
Now when dma_resv_for_each_fence_unlocked() sees a destroyed dma_fence it assumes that a new fence list was installed and re-starts the loop.
But in the case of a destroyed GEM object a new fence list is never installed, only the old one freed and therefore the iteration never finishes resulting in an endless loop.
The solution is to drop the fence references only after the RCU grace period.
The fixes tag is not necessary the patch introducing the problem, but the one making it so worse that we need to address it.
This problem was pointed out by Sashiko-bot.
--- drivers/gpu/drm/i915/gem/i915_gem_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +1 -1
@@ -59,6 +59,7 @@ struct drm_i915_gem_object *i915_gem_objvoid i915_gem_object_free (struct drm_i915_gem_object *obj) { +dma_resv_fini (&obj->base._resv);return kmem_cache_free (slab_objects, obj); }
@@ -110,7 +111,6 @@ void __i915_gem_object_fini(struct drm_i {mutex_destroy (&obj->mm.get_page.lock);mutex_destroy (&obj->mm.get_dma_page.lock); -dma_resv_fini (&obj->base._resv); }/**
Greg Kroah-Hartman
maintainerPATCH 940/982 drm/amdgpu: Fix last_update fence leak in amdgpu_vm_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit b4f7b4459b1b155e4c4977a6482b5df2cf08758c upstream.
amdgpu_vm_init() initializes vm->last_update, vm->last_unlocked and vm->last_tlb_flush with references to the stub fence taken via dma_fence_get_stub(). The error label at the end of the function releases the last_unlocked and last_tlb_flush references with dma_fence_put(), but the reference stored in vm->last_update is never dropped, so whenever the page table root creation, the reservation of the root BO or the PASID registration fails, the stub fence reference leaks.
Drop the vm->last_update reference together with the other stub fence references on the error path.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -0
@@ -2135,6 +2135,7 @@ error_free_root: vm->root.bo =NULL ; error_free_delayed: +dma_fence_put (vm->last_update);dma_fence_put (vm->last_tlb_flush);dma_fence_put (vm->last_unlocked);drm_sched_entity_destroy (&vm->delayed);
Greg Kroah-Hartman
maintainerPATCH 941/982 drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 2b86ab1bd6673c525adda88819d7658ba9e784ec upstream.
amdgpu_debugfs_test_ib_show() resumes the device with pm_runtime_get_sync() before taking the reset domain semaphore with down_write_killable(). If the write lock acquisition is interrupted, the function returns without calling pm_runtime_put_autosuspend(), leaking the runtime PM reference acquired for the device and keeping the GPU awake.
Drop the runtime PM reference on the interrupted down_write_killable() error path before returning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -1
@@ -1494,8 +1494,10 @@ static int amdgpu_debugfs_test_ib_show(s/* Avoid accidently unparking the sched thread during GPU reset */ r =down_write_killable (&adev->reset_domain->sem); -if (r) +if (r) { +pm_runtime_put_autosuspend (dev->dev);return r; + }/* hold on the scheduler */ for (i =0 ; i <AMDGPU_MAX_RINGS ; i++) {
Greg Kroah-Hartman
maintainerPATCH 942/982 drm/amdgpu: Fix vmid_wait fence leak in amdgpu_ring_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit aea841bc62a76242396610d22d8ff40c13065f64 upstream.
amdgpu_ring_init() initializes ring->vmid_wait with a reference to the stub fence taken via dma_fence_get_stub(). When a later step of the initialization fails, e.g. amdgpu_fence_driver_init_ring(), a writeback slot allocation or the ring buffer allocation, the function returns an error without releasing the stub fence reference and the reference is leaked if the ring is torn down without amdgpu_ring_fini().
Move the stub fence assignment to the end of the initialization, right before the ring is registered with the GPU scheduler, where no further failure is possible. The stub fence is only consumed by command submission handling in amdgpu_ids.c once the ring is up and running, so nothing reads it during the error-prone part of the initialization.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -1
@@ -201,7 +201,6 @@ int amdgpu_ring_init(struct amdgpu_devic ring->adev = adev; ring->num_hw_submission = sched_hw_submission; ring->sched_score = sched_score; - ring->vmid_wait =dma_fence_get_stub ();if (!ring->is_mes_queue) { ring->idx = adev->num_rings++;
@@ -323,6 +322,7 @@ int amdgpu_ring_init(struct amdgpu_devic ring->max_dw = max_dw; ring->hw_prio = hw_prio; + ring->vmid_wait =dma_fence_get_stub ();if (!ring->no_scheduler && ring->funcs->type <AMDGPU_HW_IP_NUM ) { hw_ip = ring->funcs->type;
Greg Kroah-Hartman
maintainerPATCH 943/982 drm/nouveau: fix autosuspend cleanup during teardown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit fefd9480ec361969f1a836df46326a1801062c26 upstream.
nouveau_drm_device_init() calls pm_runtime_use_autosuspend(), but nouveau_drm_device_fini() does not call the matching pm_runtime_dont_use_autosuspend().
If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without calling pm_runtime_dont_use_autosuspend() during teardown, this reference is not dropped and usage_count remains unbalanced.
The documentation for pm_runtime_use_autosuspend() also notes that it is important to undo it with pm_runtime_dont_use_autosuspend() at driver exit time, unless runtime PM was initially enabled with devm_pm_runtime_enable().
Add the missing pm_runtime_dont_use_autosuspend() call to the common device teardown path.
This issue was found by manual code inspection.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -0
@@ -658,6 +658,7 @@ nouveau_drm_device_fini(struct drm_devicif (nouveau_pmops_runtime ()) {pm_runtime_get_sync (dev->dev);pm_runtime_forbid (dev->dev); +pm_runtime_dont_use_autosuspend (dev->dev); }nouveau_led_fini (dev);
Greg Kroah-Hartman
maintainerPATCH 944/982 drm/nouveau: Fix bridge reference leak in nv1a_ram_new()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 67b4411538c8341692548429d43256f25be99f7a upstream.
pci_get_domain_bus_and_slot() takes a reference to the PCI device, which is never released once the memory size has been read from its config space. Drop the reference before returning.
--- drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +2 -0
@@ -51,6 +51,8 @@ nv1a_ram_new(struct nvkm_fb *fb, struct mib = ((mem >>4 ) &127 ) +1 ; } +pci_dev_put (bridge); +return nvkm_ram_new_ (&nv04_ram_func, fb,NVKM_RAM_TYPE_STOLEN , mib *1024 *1024 , pram); }
Greg Kroah-Hartman
maintainerPATCH 945/982 drm/nouveau: fix double-free in nvif_vmm_dtor
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peiyang He <[email protected]>
commit 97077ac87afe9e91ec074ef0be64454e7ccbf344 upstream.
On failure, nouveau_cli_init() calls nouveau_cli_fini() to tear the client down. Then, nouveau_drm_open() also enters into its cleanup path and calls nouveau_cli_fini() AGAIN. nouveau_cli_fini() calls nouveau_vmm_fini():
void
nouveau_vmm_fini(struct nouveau_vmm *vmm)
{
nouveau_svmm_fini(&vmm->svmm);
nvif_vmm_dtor(&vmm->vmm);
vmm->cli = NULL;
}Inside nvif_vmm_dtor(), vmm->page is freed unconditionally:
void
nvif_vmm_dtor(struct nvif_vmm *vmm)
{
kfree(vmm->page);
nvif_object_dtor(&vmm->object);
}vmm->page is never cleared after being freed, so the second call of nvif_vmm_dtor() will cause a double-free.
Found by fuzzing the nouveau driver with a modified Syzkaller:
BUG: KASAN: double-free in nvif_vmm_dtor+0x31/0x50 drivers/gpu/drm/nouveau/nvif/vmm.c:194 Free of addr ffff888010fcdc30 by task syz.0.173/2567 CPU: 1 UID: 0 PID: 2567 Comm: syz.0.173 Not tainted 7.2.0 #24 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x95/0xe0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcb/0x5a0 mm/kasan/report.c:482 kasan_report_invalid_free+0xaa/0xd0 mm/kasan/report.c:557 check_slab_allocation+0xe4/0x110 mm/kasan/common.c:235 kasan_slab_pre_free include/linux/kasan.h:199 [inline] slab_free_hook mm/slub.c:2622 [inline] slab_free mm/slub.c:6377 [inline] kfree+0x192/0x590 mm/slub.c:6692 nvif_vmm_dtor+0x31/0x50 drivers/gpu/drm/nouveau/nvif/vmm.c:194 nouveau_vmm_fini+0x16/0x50 drivers/gpu/drm/nouveau/nouveau_vmm.c:127 nouveau_cli_fini+0x10e/0x210 drivers/gpu/drm/nouveau/nouveau_drm.c:225 nouveau_drm_open+0x24e/0x740 drivers/gpu/drm/nouveau/nouveau_drm.c:1255 drm_file_alloc+0x5f2/0xad0 drivers/gpu/drm/drm_file.c:176 drm_open_helper+0x1d7/0x4a0 drivers/gpu/drm/drm_file.c:335 drm_open+0x190/0x3d0 drivers/gpu/drm/drm_file.c:388 drm_stub_open+0x1f2/0x460 drivers/gpu/drm/drm_drv.c:1211 chrdev_open+0x21c/0x660 fs/char_dev.c:411 do_dentry_open+0x59d/0x12b0 fs/open.c:947 vfs_open+0x82/0x390 fs/open.c:1052 do_open fs/namei.c:4700 [inline] path_openat+0x2345/0x3420 fs/namei.c:4863 do_file_open+0x207/0x460 fs/namei.c:4892 do_sys_openat2+0xd1/0x1d0 fs/open.c:1368 do_sys_open fs/open.c:1374 [inline] __do_sys_openat fs/open.c:1390 [inline] __se_sys_openat fs/open.c:1385 [inline] __x64_sys_openat+0x144/0x200 fs/open.c:1385 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x690 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fc6d687594d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fc6d5295008 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007fc6d6b06180 RCX: 00007fc6d687594d RDX: 0000000000022501 RSI: 0000200000000000 RDI: ffffffffffffff9c RBP: 00007fc6d691c303 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fc6d6b06218 R14: 00007fc6d6b06180 R15: 00007ffd9451d760 </TASK> Allocated by task 2567 on cpu 1 at 163.593900s: kasan_save_stack+0x24/0x50 mm/kasan/common.c:57 kasan_save_track+0x17/0x60 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5334 [inline] __kmalloc_noprof+0x304/0x7c0 mm/slub.c:5359 _kmalloc_noprof include/linux/slab.h:992 [inline] nvif_vmm_ctor+0x3c0/0x7e0 drivers/gpu/drm/nouveau/nvif/vmm.c:237 nouveau_vmm_init+0x40/0x90 drivers/gpu/drm/nouveau/nouveau_vmm.c:134 nouveau_cli_init+0x7b9/0xe10 drivers/gpu/drm/nouveau/nouveau_drm.c:293 nouveau_drm_open+0x236/0x740 drivers/gpu/drm/nouveau/nouveau_drm.c:1243 drm_file_alloc+0x5f2/0xad0 drivers/gpu/drm/drm_file.c:176 drm_open_helper+0x1d7/0x4a0 drivers/gpu/drm/drm_file.c:335 drm_open+0x190/0x3d0 drivers/gpu/drm/drm_file.c:388 drm_stub_open+0x1f2/0x460 drivers/gpu/drm/drm_drv.c:1211 chrdev_open+0x21c/0x660 fs/char_dev.c:411 do_dentry_open+0x59d/0x12b0 fs/open.c:947 vfs_open+0x82/0x390 fs/open.c:1052 do_open fs/namei.c:4700 [inline] path_openat+0x2345/0x3420 fs/namei.c:4863 do_file_open+0x207/0x460 fs/namei.c:4892 do_sys_openat2+0xd1/0x1d0 fs/open.c:1368 do_sys_open fs/open.c:1374 [inline] __do_sys_openat fs/open.c:1390 [inline] __se_sys_openat fs/open.c:1385 [inline] __x64_sys_openat+0x144/0x200 fs/open.c:1385 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x690 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 2567 on cpu 1 at 163.601355s: kasan_save_stack+0x24/0x50 mm/kasan/common.c:57 kasan_save_track+0x17/0x60 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:253 [inline] __kasan_slab_free+0x61/0x80 mm/kasan/common.c:285 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2677 [inline] slab_free mm/slub.c:6377 [inline] kfree+0x383/0x590 mm/slub.c:6692 nvif_vmm_dtor+0x31/0x50 drivers/gpu/drm/nouveau/nvif/vmm.c:194 nouveau_vmm_fini+0x16/0x50 drivers/gpu/drm/nouveau/nouveau_vmm.c:127 nouveau_cli_fini+0x10e/0x210 drivers/gpu/drm/nouveau/nouveau_drm.c:225 nouveau_cli_init+0x593/0xe10 drivers/gpu/drm/nouveau/nouveau_drm.c:324 nouveau_drm_open+0x236/0x740 drivers/gpu/drm/nouveau/nouveau_drm.c:1243 drm_file_alloc+0x5f2/0xad0 drivers/gpu/drm/drm_file.c:176 drm_open_helper+0x1d7/0x4a0 drivers/gpu/drm/drm_file.c:335 drm_open+0x190/0x3d0 drivers/gpu/drm/drm_file.c:388 drm_stub_open+0x1f2/0x460 drivers/gpu/drm/drm_drv.c:1211 chrdev_open+0x21c/0x660 fs/char_dev.c:411 do_dentry_open+0x59d/0x12b0 fs/open.c:947 vfs_open+0x82/0x390 fs/open.c:1052 do_open fs/namei.c:4700 [inline] path_openat+0x2345/0x3420 fs/namei.c:4863 do_file_open+0x207/0x460 fs/namei.c:4892 do_sys_openat2+0xd1/0x1d0 fs/open.c:1368 do_sys_open fs/open.c:1374 [inline] __do_sys_openat fs/open.c:1390 [inline] __se_sys_openat fs/open.c:1385 [inline] __x64_sys_openat+0x144/0x200 fs/open.c:1385 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x690 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888010fcdc30 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 0 bytes inside of 16-byte region [ffff888010fcdc30, ffff888010fcdc40) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10fcd flags: 0x100000000000000(node=0|zone=1) page_type: f5(slab) raw: 0100000000000000 ffff88800d441640 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000550055 00000000f5000000 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888010fcdb00: fc fc 00 04 fc fc fc fc fa fb fc fc fc fc fa fb ffff888010fcdb80: fc fc fc fc fa fb fc fc fc fc 00 07 fc fc fc fc >ffff888010fcdc00: fa fb fc fc fc fc fa fb fc fc fc fc fa fb fc fc ^ ffff888010fcdc80: fc fc fa fb fc fc fc fc 00 04 fc fc fc fc fa fb ffff888010fcdd00: fc fc fc fc 00 00 fc fc fc fc fa fb fc fc fc fc
Fix by removing the redundant teardown in nouveau_drm_open(), since nouveau_cli_init() already does the cleanup work. Also clear vmm->page after its freeing.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 4 +--- drivers/gpu/drm/nouveau/nvif/vmm.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -3
@@ -1136,10 +1136,8 @@ nouveau_drm_open(struct drm_device *dev,mutex_unlock (&drm->clients_lock); done: -if (ret && cli) { -nouveau_cli_fini (cli); +if (ret && cli)kfree (cli); - }pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);
drivers/gpu/drm/nouveau/nvif/vmm.c +1 -0
@@ -108,6 +108,7 @@ void nvif_vmm_dtor(struct nvif_vmm *vmm) {kfree (vmm->page); + vmm->page =NULL ;nvif_object_dtor (&vmm->object); }
Greg Kroah-Hartman
maintainerPATCH 946/982 drm/nouveau: Fix gem reference leak in validate_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 5ea72f7b7139b123713a7983448f910bc4514d9e upstream.
On the ttm_bo_reserve() failure and "vma not found" error paths, the loop breaks without adding the looked-up object to any validate list, so the reference taken by drm_gem_object_lookup() is never released; validate_fini() only walks the spliced lists. Drop the reference before breaking out on both paths.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nouveau_gem.c +2 -0
@@ -471,6 +471,7 @@ retry:if (unlikely (ret)) {if (ret != -ERESTARTSYS )NV_PRINTK (err, cli,"fail reserve\n" ); +drm_gem_object_put (gem);break ; } }
@@ -480,6 +481,7 @@ retry:struct nouveau_vma *vma =nouveau_vma_find (nvbo, vmm);if (!vma) {NV_PRINTK (err, cli,"vma not found!\n" ); +drm_gem_object_put (gem); ret = -EINVAL ;break ; }
Greg Kroah-Hartman
maintainerPATCH 947/982 drm/nouveau: dont bump pin count on failed re-pin in nouveau_bo_pin_locked()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peiyang He <[email protected]>
commit 6a6870d3077faa501ca97760057ddca22b68418d upstream.
nouveau_bo_pin_locked() checks whether an already pinned BO is in a memory domain compatible with a new pin request. When the domains are incompatible, it sets -EBUSY but still calls ttm_bo_pin() before returning.
Callers treat a failed nouveau_bo_pin() as not having acquired a new pin, so the extra pin count is never decreased by a matching unpin. This triggers the warning in ttm_bo_release():
WARN_ON_ONCE(bo->pin_count);
Found when fuzzing the nouveau driver with a modified Syzkaller:
WARNING: drivers/gpu/drm/ttm/ttm_bo.c:256 at ttm_bo_release+0x827/0x9e0 drivers/gpu/drm/ttm/ttm_bo.c:256, CPU#1: syz.3.24/2212 Modules linked in: CPU: 1 UID: 0 PID: 2212 Comm: syz.3.24 Not tainted 7.2.0 #24 PREEMPT(lazy) nouveau 0000:01:00.0: gsp:msg fn:103 len:0x40/0x20 res:0x19 resp:0x19 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:ttm_bo_release+0x827/0x9e0 drivers/gpu/drm/ttm/ttm_bo.c:256 Code: 02 00 0f 85 51 01 00 00 48 8b 7b 08 e8 d2 20 01 00 e9 80 fd ff ff e8 d8 15 c0 fe 90 0f 0b 90 e9 e1 f8 ff ff e8 ca 15 c0 fe 90 <0f> 0b 90 e9 a4 f8 ff ff e8 bc 15 c0 fe be 03 00 00 00 4c 89 e7 e8 msg: 00000000: 05 00 d0 c1 04 00 f0 f1 01 30 00 00 2d 90 00 00 .........0..-... RSP: 0018:ffffc9000f5cf710 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffff888018e5d2a8 RCX: ffffffff82bb1b36 RDX: ffff888017b68000 RSI: 0000000000000004 RDI: ffff888018e5d2a8 msg: 00000010: 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ RBP: ffff88801261c720 R08: 0000000000000001 R09: ffffed10031cba55 R10: ffff888018e5d2ab R11: 00000000000000f3 R12: ffff888018e5d290 R13: ffff888018e5d2d4 R14: ffff88801b219c18 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8880e0f6f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b31223ffc CR3: 0000000028e00005 CR4: 0000000000770ef0 PKRU: 80000000 Call Trace: <TASK> kref_put include/linux/kref.h:65 [inline] ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:325 [inline] ttm_bo_fini+0x55/0x80 drivers/gpu/drm/ttm/ttm_bo.c:330 nouveau_gem_object_del+0xb2/0x1b0 drivers/gpu/drm/nouveau/nouveau_gem.c:90 drm_gem_object_free+0x5f/0x90 drivers/gpu/drm/drm_gem.c:1165 kref_put include/linux/kref.h:65 [inline] __drm_gem_object_put include/drm/drm_gem.h:562 [inline] drm_gem_object_put include/drm/drm_gem.h:575 [inline] nouveau_abi16_chan_fini.constprop.0+0x44f/0x5a0 drivers/gpu/drm/nouveau/nouveau_abi16.c:195 nouveau 0000:01:00.0: syz.2.23[2209]: Unknown handle 0x00000000 nouveau_abi16_fini+0x1d0/0x340 drivers/gpu/drm/nouveau/nouveau_abi16.c:225 nouveau_drm_postclose+0x18b/0x3e0 drivers/gpu/drm/nouveau/nouveau_drm.c:1284 nouveau 0000:01:00.0: syz.2.23[2209]: validate_init drm_file_free.part.0+0x6d6/0xb60 drivers/gpu/drm/drm_file.c:267 drm_file_free drivers/gpu/drm/drm_file.c:237 [inline] drm_close_helper.isra.0+0x11a/0x160 drivers/gpu/drm/drm_file.c:290 drm_release+0x1ab/0x330 drivers/gpu/drm/drm_file.c:438 __fput+0x39c/0xa60 fs/file_table.c:512 nouveau 0000:01:00.0: syz.2.23[2209]: validate: -2 task_work_run+0x15a/0x230 kernel/task_work.c:233 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0x82b/0x25a0 kernel/exit.c:1009 do_group_exit+0xc2/0x280 kernel/exit.c:1152 get_signal+0x1d6e/0x1f30 kernel/signal.c:3046 arch_do_signal_or_restart+0x7d/0x6e0 arch/x86/kernel/signal.c:337 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline] exit_to_user_mode_loop+0xdf/0x440 kernel/entry/common.c:101 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline] syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline] do_syscall_64+0x4f8/0x690 arch/x86/entry/syscall_64.c:100 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f12bac8594d Code: Unable to access opcode bytes at 0x7f12bac85923. RSP: 002b:00007f12b96e70d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca RAX: 0000000000000001 RBX: 00007f12baf15fa8 RCX: 00007f12bac8594d RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 00007f12baf15fac RBP: 00007f12baf15fa0 R08: 00007f12baee8000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f12baf16038 R14: 0000000000000006 R15: 00007ffe2ed394b0 </TASK> irq event stamp: 47867 hardirqs last enabled at (47883): [<ffffffff815cafc6>] __up_console_sem+0x66/0x70 kernel/printk/printk.c:347 hardirqs last disabled at (47892): [<ffffffff815cafab>] __up_console_sem+0x4b/0x70 kernel/printk/printk.c:345 softirqs last enabled at (47880): [<ffffffff81434277>] __do_softirq kernel/softirq.c:656 [inline] softirqs last enabled at (47880): [<ffffffff81434277>] invoke_softirq kernel/softirq.c:496 [inline] softirqs last enabled at (47880): [<ffffffff81434277>] __irq_exit_rcu+0x137/0x1c0 kernel/softirq.c:735 softirqs last disabled at (47875): [<ffffffff81434277>] __do_softirq kernel/softirq.c:656 [inline] softirqs last disabled at (47875): [<ffffffff81434277>] invoke_softirq kernel/softirq.c:496 [inline] softirqs last disabled at (47875): [<ffffffff81434277>] __irq_exit_rcu+0x137/0x1c0 kernel/softirq.c:735
Fix by calling ttm_bo_pin() only when the existing placement is compatible with the new pin request. This matches the correct behavior in other DRM drivers such as amdgpu_bo_pin() in amdgpu.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -1
@@ -460,8 +460,9 @@ nouveau_bo_pin(struct nouveau_bo *nvbo,"0x%08x vs 0x%08x\n" , bo, bo->resource->mem_type, domain); ret = -EBUSY ; + }else { +ttm_bo_pin (&nvbo->bo); } -ttm_bo_pin (&nvbo->bo); goto out; }
Greg Kroah-Hartman
maintainerPATCH 948/982 HID: alps: fix use-after-free on input2 registration failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
commit d3aba3442798ce4a4c8ce3104d7b286d61e605f9 upstream.
alps_input_configured() stores data->input2 before calling input_register_device(). If registration fails, input_free_device() frees the input device but data->input2 still points to the freed memory. alps_input_configured() calls hid_hw_open() before allocating input2, so URBs are already active and raw_event can fire during the failure window. A U1_SP_ABSOLUTE_REPORT_ID report arriving then causes u1_raw_event() to dereference the freed data->input2 -> use-after-free.
Fix by only storing input2 into drvdata after successful registration and adding a NULL guard in the raw_event path.
--- drivers/hid/hid-alps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hid/hid-alps.c +4 -2
@@ -407,6 +407,8 @@ static int u1_raw_event(struct alps_devreturn 1 ;case U1_SP_ABSOLUTE_REPORT_ID : +if (!hdata->input2) +return 0 ; sp_x =get_unaligned_le16 (data+2 ); sp_y =get_unaligned_le16 (data+4 );
@@ -738,7 +740,6 @@ static int alps_input_configured(struct goto exit; } - data->input2 = input2; input2->phys = input->phys; input2->name ="DualPoint Stick" ; input2->id.bustype =BUS_I2C ;
@@ -762,11 +763,12 @@ static int alps_input_configured(struct__set_bit (INPUT_PROP_POINTER , input2->propbit);__set_bit (INPUT_PROP_POINTING_STICK , input2->propbit); -if (input_register_device (data->input2)) { +if (input_register_device (input2)) {input_free_device (input2); ret = -ENOENT ; goto exit; } + data->input2 = input2; } exit:
Greg Kroah-Hartman
maintainerPATCH 949/982 HID: quirks: add ALWAYS_POLL quirk for SDINNOVATION gaming keyboard
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junjie Cao <[email protected]>
commit cdb669a3b8f844aca71fc3224990157d61562165 upstream.
The SDINNOVATION gaming keyboard (USB ID 36ae:feab) stops reporting input events after its RGB lighting mode is switched about twice. Disabling USB autosuspend and unbinding the other HID interfaces make no difference; the issue does not occur on Windows.
HID_QUIRK_ALWAYS_POLL alone resolves it, verified on 7.1.8 via usbhid.quirks=0x36ae:0xfeab:0x400.
--- drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -1155,6 +1155,9 @@#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 +#define USB_VENDOR_ID_SDINNOVATION 0x36ae +#define USB_DEVICE_ID_SDINNOVATION_GAMING_KBD 0xfeab +#define USB_VENDOR_ID_SEMICO 0x1a2c#define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023#define USB_DEVICE_ID_SEMICO_USB_KEYKOARD2 0x0027
drivers/hid/hid-quirks.c +1 -0
@@ -171,6 +171,7 @@ static const struct hid_device_id hid_qu { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_PRO), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X65), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SDINNOVATION, USB_DEVICE_ID_SDINNOVATION_GAMING_KBD), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD2), HID_QUIRK_NO_INIT_REPORTS }, { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS }, { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 950/982 HID: wacom: fix OOB read in wacom_wac_pen_serial_enforce()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Jie LAW <[email protected]>
commit 9aa237cf66495b2426ddde8532e9b08a0ed83aaa upstream.
The 'wacom_wac_pen_serial_enforce()' function may calculate and pass an invalid offset to hid_field_extract(), resulting in memory reads at incorrect addresses -- possibly beyond the end of the report. If a field in the HID descriptor lists more usages than its Report Count actually reserves space for, the function's inner 'j' will walk past the end of the field:
for (i = 0; i < report->maxfield; i++) {
for (j = 0; j < report->field[i]->maxusage; j++) {
...
value = hid_field_extract(hdev, raw_data + 1,
offset + j * size, size);A descriptor listing 12288 usages against Report Count 1 has the loop extract the usage at index 12287 from bit offset 98296 -- about 12 KB past a 2-byte received report. The value is stored in wacom_wac->serial[0] and can reach userspace as an MSC_SERIAL event, making this an information disclosure.
Clamp the loop to field->report_count, the number of value slots the report holds. Value slots past the last declared usage are still scanned; they reuse that usage (HID 1.11, 6.2.2.8).
Verified on v6.12.105 with a UHID reproducer: a 2-byte report from such a descriptor trips KASAN before the patch and not after it.
--- drivers/hid/wacom_sys.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hid/wacom_sys.c +3 -2
@@ -97,8 +97,9 @@ static int wacom_wac_pen_serial_enforce(/* Queue events which have invalid tool type or serial number */ for (i =0 ; i < report->maxfield; i++) { -for (j =0 ; j < report->field[i]->maxusage; j++) { -struct hid_field *field = report->field[i]; +struct hid_field *field = report->field[i]; + +for (j =0 ; j < field->report_count; j++) {struct hid_usage *usage = &field->usage[j];unsigned int equivalent_usage =wacom_equivalent_usage (usage->hid);unsigned int offset;
Greg Kroah-Hartman
maintainerPATCH 951/982 net/mlx5: Fix rev_entry reference leak in mlx5_tc_ct_shared_counter_get()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 0bf6bb567f0edaa771e7dd208ef98da50e6a4485 upstream.
When the reverse entry is found but its counter is already being released, refcount_inc_not_zero() fails and the reference taken by mlx5_tc_ct_entry_get() is never dropped before falling through to create_counter. Drop it so the reverse entry is not kept alive forever by a shared counter lookup that did not use it.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3 -0
@@ -1016,6 +1016,9 @@ mlx5_tc_ct_shared_counter_get(struct mlxspin_unlock_bh (&ct_priv->ht_lock); +if (rev_entry) +mlx5_tc_ct_entry_put (rev_entry); + create_counter: shared_counter =mlx5_tc_ct_counter_create (ct_priv);
Greg Kroah-Hartman
maintainerPATCH 952/982 net/sched: reject IDR error pointers when deleting actions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit c82b797abe668d0b668601a93ba2c0b071a63574 upstream.
tcf_action_delete() drops the reference held by its lookup before calling tcf_idr_delete_index() with the saved action index. An unlocked classifier can remove that action and reserve the same IDR slot with ERR_PTR(-EBUSY) in between.
tcf_idr_delete_index() only checks the lookup result for NULL. It therefore treats the reservation as a tc_action and dereferences tcfa_bindcnt. A hardware execution breakpoint was used to schedule the interleaving without changing the kernel source. KASAN reported this decoded trace:
BUG: KASAN: null-ptr-deref in tca_action_gd+0x5b9/0x1010
Read of size 4 at addr 0000000000000010 by task poc/150
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002
RIP: tca_action_gd+0x5c0/0x1010:
arch_atomic_read at arch/x86/include/asm/atomic.h:23
raw_atomic_read at include/linux/atomic/atomic-arch-fallback.h:457
atomic_read at include/linux/atomic/atomic-instrumented.h:33
tcf_idr_delete_index at net/sched/act_api.c:766
tcf_action_delete at net/sched/act_api.c:1859
tcf_del_notify at net/sched/act_api.c:2014
tca_action_gd at net/sched/act_api.c:2064
R13: 0000000000000010 R15: fffffffffffffff0
Kernel panic - not syncing: Fatal exceptionR15 contains ERR_PTR(-EBUSY), and adding the tcfa_bindcnt offset produces the address in R13. With the guard applied, the same reproducer returned -ENOENT without a KASAN report or panic. Treat error pointers as absent and return -ENOENT.
--- net/sched/act_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_api.c +1 -1
@@ -712,7 +712,7 @@ static int tcf_idr_delete_index(struct tmutex_lock (&idrinfo->lock); p =idr_find (&idrinfo->action_idr, index); -if (!p) { +if (IS_ERR_OR_NULL (p)) {mutex_unlock (&idrinfo->lock);return -ENOENT ; }
Greg Kroah-Hartman
maintainerPATCH 953/982 net: arp: terminate device name before lookup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijie Huang <[email protected]>
commit d8b6529e80bcb4fb8177121404cbb3377acaebd2 upstream.
The ARP ioctl copies a user-provided struct arpreq into a stack object. Its arp_dev field may contain IFNAMSIZ bytes without a NUL terminator.
Such input is passed to dev_get_by_name_rcu() or __dev_get_by_name(), where strcmp() can read past the end of the stack object when a matching alternative interface name exists.
Terminate the field before the lookup to prevent the out-of-bounds read.
--- net/ipv4/arp.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/arp.c +1 -0
@@ -1222,6 +1222,7 @@ int arp_ioctl(struct net *net, unsigned err =copy_from_user (&r, arg,sizeof (struct arpreq ));if (err)return -EFAULT ; + r.arp_dev[IFNAMSIZ -1 ] ='\0' ;break ;default :return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 954/982 net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gajdos Tamás <[email protected]>
commit 43e746821f5f5afbbf68e388bf9fbe221e03bfca upstream.
Same issue as atl1c (see the first commit in this series, "net:
atl1c: fix soft lockup on out-of-range tpd_cons read"): the hardware can report an out-of-range cmb_tpd_next_to_clean (seen as 0xffff) while the PCIe link/MAC is resetting. An out-of-range value can never be reached and the loop below would spin forever. Treat it as "nothing new to clean" instead.
--- drivers/net/ethernet/atheros/atlx/atl1.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/atheros/atlx/atl1.c +3 -0
@@ -2066,6 +2066,9 @@ static int atl1_intr_tx(struct atl1_adap sw_tpd_next_to_clean =atomic_read (&tpd_ring->next_to_clean); cmb_tpd_next_to_clean =le16_to_cpu (adapter->cmb.cmb->tpd_cons_idx); +if (unlikely (cmb_tpd_next_to_clean >= tpd_ring->count)) + cmb_tpd_next_to_clean = sw_tpd_next_to_clean; +while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) { buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean];if (buffer_info->dma) {
Greg Kroah-Hartman
maintainerPATCH 955/982 net: hisilicon: hns_dsaf_mac: fix mdio device leak in hns_mac_register_phy()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 999e8295bc41d6ce45b8e54f88150efa96f3f01e upstream.
hns_dsaf_find_platform_device() returns the mdio platform device with its reference count incremented. hns_mac_register_phy() never drops that reference, so the mdio device can not be released.
Release the reference on both the deferred probe and the normal path.
--- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +3 -0
@@ -793,6 +793,7 @@ static int hns_mac_register_phy(struct hdev_err (mac_cb->dev,"mac%d mdio is NULL, dsaf will probe again later\n" , mac_cb->mac_id); +put_device (&pdev->dev);return -EPROBE_DEFER ; }
@@ -801,6 +802,8 @@ static int hns_mac_register_phy(struct hdev_dbg (mac_cb->dev,"mac%d register phy addr:%d\n" , mac_cb->mac_id, addr); +put_device (&pdev->dev); +return rc; }
Greg Kroah-Hartman
maintainerPATCH 956/982 net: openvswitch: conntrack: avoid modifying shared unconfirmed ct entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 26b2bd70d22457556e2fa01cbf1192cb1a94d619 upstream.
In a case where skb with an unconfirmed ct entry gets cloned, we may end up committing both but with different sets of extensions.
The series of events:
1. The first clone wants to commit and runs the helpers wiring up the extension pointer into the expectation list.
2. Then it looses the confirmation keeping the entry unconfirmed.
3. Second clone now wants to commit labels and adds the new extension for that breaking the pointer in the expectation list causing UAF on the destruction path later.
While this is possible to trigger, there should be no practical network pipeline where committing both clones without modifications into the same zone is needed. So, let's just reset the entry in case for some reason we got an skb with a shared one during commit. This doesn't affect any known use cases, but avoids any potential problems with sharing and modification of the unconfirmed ct entry.
The fixes tag points to the introduction of helpers, since that's the main UAF trigger for the sharing.
--- include/net/netfilter/nf_conntrack.h | 5 +++++ net/openvswitch/conntrack.c | 12 ++++++++++++ 2 files changed, 17 insertions(+)
include/net/netfilter/nf_conntrack.h +5 -0
@@ -194,6 +194,11 @@ static inline void nf_ct_put(struct nf_cint nf_ct_l3proto_try_module_get (unsigned short l3proto);void nf_ct_l3proto_module_put (unsigned short l3proto); +static inline bool nf_ct_shared (const struct nf_conn *ct) +{ +return refcount_read (&ct->ct_general.use) >1 ; +} +/* load module; enable/disable conntrack in this namespace */ int nf_ct_netns_get (struct net *net,u8 nfproto);void nf_ct_netns_put (struct net *net,u8 nfproto);
net/openvswitch/conntrack.c +12 -0
@@ -970,6 +970,18 @@ static int __ovs_ct_lookup(struct net *nenum ip_conntrack_info ctinfo;struct nf_conn *ct; +/* If the ct entry is not confirmed and shared with some other skb, +* e.g., a cloned one, we can't just modify it with the commit as we +* must not modify the extension set. Reset. +*/ +if (cached && info->commit) { + ct =nf_ct_get (skb, &ctinfo); +if (ct && !nf_ct_is_confirmed (ct) &&nf_ct_shared (ct)) { +nf_reset_ct (skb); + cached = false; + } + } +if (!cached) {struct nf_hook_state state = { .hook =NF_INET_PRE_ROUTING ,
Greg Kroah-Hartman
maintainerPATCH 957/982 net: atl1c: fix soft lockup on out-of-range tpd_cons read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gajdos Tamás <[email protected]>
commit 36c2009d90f2210ef92e6f4f2850e8b57b09e754 upstream.
The hardware can report an out-of-range tpd_cons (seen as 0xffff) while the PCIe link/MAC is resetting. An out-of-range value can never be reached and the loop below would spin forever. To avoid a soft lockup treat it as "nothing new to clean" instead.
Reproduced on two machines, same NIC (Qualcomm Atheros AR8151 v2.0, 4-port), triggered by rebooting a Mikrotik CCR2004 PCIe card that the ports are directly linked to:
- Ubuntu 26.04.1 LTS, kernel 7.0.0-31-generic. The link-flap precursor, before the lockup was captured with a full trace elsewhere:
atl1c 0000:05:00.0 enp5s0f0: NETDEV WATCHDOG: CPU: 4: transmit queue 2 timed out 489984 ms
atl1c 0000:05:00.0: MAC state machine can't be idle since disabled for 10ms second
atl1c 0000:05:00.0: atl1c: enp5s0f0 NIC Link is Up<65535 Mbps Full Duplex> 65535 (0xffff) here is the same value tpd_cons reads back once the loop below gets stuck.
- Proxmox VE, kernel 7.0.14-11-pve. Same NIC/trigger, this time caught by the soft lockup watchdog with a full stack trace:
watchdog: BUG: soft lockup - CPU#12 stuck for 354s! [napi/eth%d-0:329]
CPU: 12 UID: 0 PID: 329 Comm: napi/eth%d-0 Tainted: P O L 7.0.14-11-pve #1 PREEMPT(lazy)
RIP: 0010:atl1c_clean_tx+0x142/0x2d0 [atl1c]
Call Trace:
<TASK>
__napi_poll+0x32/0x1e0
napi_threaded_poll_loop+0x286/0x2e0
napi_threaded_poll+0xfd/0x140
kthread+0xf7/0x130
ret_from_fork+0x2da/0x3a0
ret_from_fork_asm+0x1a/0x30
</TASK>--- drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +3 -0
@@ -1611,6 +1611,9 @@ static int atl1c_clean_tx(struct napi_stAT_READ_REGW (&adapter->hw, atl1c_qregs[tpd_ring->num].tpd_cons, &hw_next_to_clean); +if (unlikely (hw_next_to_clean >= tpd_ring->count)) + hw_next_to_clean = next_to_clean; +while (next_to_clean != hw_next_to_clean) { buffer_info = &tpd_ring->buffer_info[next_to_clean];if (buffer_info->skb) {
Greg Kroah-Hartman
maintainerPATCH 958/982 net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gajdos Tamás <[email protected]>
commit 374bf9e4b90f979e052332c4faca2d745c491a12 upstream.
Same issue as atl1c (see the first commit in this series, "net:
atl1c: fix soft lockup on out-of-range tpd_cons read"): the hardware can report an out-of-range hw_next_to_clean (seen as 0xffff) while the PCIe link/MAC is resetting. An out-of-range value can never be reached and the loop below would spin forever. Treat it as "nothing new to clean" instead.
--- drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/atheros/atl1e/atl1e_main.c +3 -0
@@ -1234,6 +1234,9 @@ static bool atl1e_clean_tx_irq(struct atu16 hw_next_to_clean =AT_READ_REGW (&adapter->hw,REG_TPD_CONS_IDX );u16 next_to_clean =atomic_read (&tx_ring->next_to_clean); +if (unlikely (hw_next_to_clean >= tx_ring->count)) + hw_next_to_clean = next_to_clean; +while (next_to_clean != hw_next_to_clean) { tx_buffer = &tx_ring->tx_buffer[next_to_clean];if (tx_buffer->dma) {
Greg Kroah-Hartman
maintainerPATCH 959/982 net: usb: cdc_mbim: add MeiG Smart SRM821 to ZLP whitelist
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Wang <[email protected]>
commit f75f21ef36285e5f56ee0c428bd2909ee81165b9 upstream.
The MeiG Smart SRM821 5G module (0x2dee:0x4d53) crashes and drops off the USB bus when it receives a Zero Length Packet (ZLP) after sending or receiving an NTB of exactly 16384 bytes (tx_max).
According to the MBIM specification, devices do not require a ZLP if the NTB size is exactly dwNtbOutMaxSize. However, the cdc_mbim driver defaults to sending ZLPs for devices not explicitly whitelisted to accommodate non-conformant hardware. This default behavior breaks the strictly conformant MeiG SRM821 module.
Add this device to the ZLP conformance whitelist (cdc_mbim_info) so the driver will pad the NTB to avoid sending ZLPs, preventing the device firmware from crashing.
--- drivers/net/usb/cdc_mbim.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/usb/cdc_mbim.c +5 -0
@@ -634,6 +634,11 @@ static const struct usb_device_id mbim_d .driver_info = (unsigned long)&cdc_mbim_info, }, +/* MeiG Smart SRM821 ZLP conformance */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d53, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), + .driver_info = (unsigned long)&cdc_mbim_info, + }, +/* Some Huawei devices, ME906s-158 (12d1:15c1) and E3372 * (12d1:157d), are known to fail unless the NDP is placed * after the IP packets. Applying the quirk to all Huawei
Greg Kroah-Hartman
maintainerPATCH 960/982 net: usb: lan78xx: Fix URB reference leak in lan78xx_submit_deferred_urbs()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 17741334d00bf5ebd37f8c1c36bc9c146a351deb upstream.
usb_get_from_anchor() hands over a reference to the URB, which the caller must release. lan78xx_submit_deferred_urbs() never does, so every deferred Tx URB keeps an extra reference: the counter grows on each suspend/resume cycle and the URBs are never freed when the buffers are released. Drop the reference after submitting, and on the path that drops the packet instead of submitting it.
--- drivers/net/usb/lan78xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/usb/lan78xx.c +2 -0
@@ -4935,10 +4935,12 @@ static bool lan78xx_submit_deferred_urbs !netif_carrier_ok(dev->net) || pipe_halted) {lan78xx_release_tx_buf (dev, skb); +usb_put_urb (urb);continue ; } ret =usb_submit_urb (urb,GFP_ATOMIC ); +usb_put_urb (urb);if (ret ==0 ) {netif_trans_update (dev->net);
Greg Kroah-Hartman
maintainerPATCH 961/982 netfilter: ip6t_rpfilter: reject routes without inet6_dev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
commit 1b9b5323725e458906c7620a3bc10398b51ad954 upstream.
ip6_route_lookup() can return an error-free route whose rt6i_idev is NULL. Lowering an external nexthop device's MTU below IPV6_MIN_MTU tears down its inet6_dev while fib6_ifdown() leaves routes using nexthop objects in the FIB. An unprivileged user can construct this state with rtnetlink in a private user and network namespace, then trigger a NULL dereference through an IPv6 rpfilter lookup:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: rpfilter_mt (net/ipv6/netfilter/ip6t_rpfilter.c:75) Call Trace: ip6t_do_table (net/ipv6/netfilter/ip6_tables.c:316) nf_hook_slow (net/netfilter/core.c:619) ipv6_rcv (net/ipv6/ip6_input.c:351) __netif_receive_skb_one_core (net/core/dev.c:6216) process_backlog (net/core/dev.c:6680) __napi_poll (net/core/dev.c:7739) net_rx_action (net/core/dev.c:7959) handle_softirqs (kernel/softirq.c:622) do_softirq.part.0 (kernel/softirq.c:523) __local_bh_enable_ip (kernel/softirq.c:450) __dev_queue_xmit (net/core/dev.c:4913) packet_sendmsg (net/packet/af_packet.c:3139) __sys_sendto (net/socket.c:2252) __x64_sys_sendto (net/socket.c:2259) 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
Reject routes without an inet6_dev immediately after lookup. Such routes are not eligible for reverse-path filtering, and the check protects all later rt6i_idev dereferences.
--- net/ipv6/netfilter/ip6t_rpfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/netfilter/ip6t_rpfilter.c +1 -1
@@ -61,7 +61,7 @@ static bool rpfilter_lookup_reverse6(str fl6.flowi6_oif = dev->ifindex; rt = (void *)ip6_route_lookup (net, &fl6, skb, lookup_flags); -if (rt->dst.error) +if (rt->dst.error || !rt->rt6i_idev) goto out;if (rt->rt6i_flags & (RTF_REJECT |RTF_ANYCAST ))
Greg Kroah-Hartman
maintainerPATCH 962/982 netfilter: ip6t_rt: fix zero-address non-strict match out-of-bounds read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
commit 82313c169eddc02b1bf5ba6b427803e272d3ec42 upstream.
rt_mt6_check() permits rules to be configured with rtinfo->addrnr == 0 even when address matching (IP6T_RT_FST_MASK) is requested.
In the IP6T_RT_FST_NSTRICT path, rt_mt6() evaluates packet routing addresses against rtinfo->addrs[i] and terminates backwards at the bottom of the loop:
if (ipv6_addr_equal(ap, &rtinfo->addrs[i])) {
i++;
}
if (i == rtinfo->addrnr)
break;When addrnr is 0, if the first packet address matches rtinfo->addrs[0], i is incremented to 1. Because i is now strictly greater than addrnr (0), the loop termination condition (i == rtinfo->addrnr) is bypassed and will never be satisfied.
If a crafted IPv6 packet contains matching routing addresses, i will advance past IP6T_RT_HOPS (16). The subsequent call to ipv6_addr_equal() reads beyond struct ip6t_rt, triggering UBSAN/KASAN out-of-bounds warnings or kernel panics.
Fix this by:
1. Rejecting rules in rt_mt6_check() where IP6T_RT_FST_MASK is set but rtinfo->addrnr is zero.
2. In rt_mt6(), moving the termination condition (i < rtinfo->addrnr) into the for-loop header condition and removing the backwards break at the end of the loop body.
--- net/ipv6/netfilter/ip6t_rt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/ipv6/netfilter/ip6t_rt.c +8 -3
@@ -96,7 +96,8 @@ static bool rt_mt6(const struct sk_buffunsigned int i =0 ;for (temp =0 ; - temp < (unsigned int )((hdrlen -8 ) /16 ); + temp < (unsigned int )((hdrlen -8 ) /16 ) && + i < rtinfo->addrnr; temp++) { ap =skb_header_pointer (skb, ptr
@@ -112,8 +113,6 @@ static bool rt_mt6(const struct sk_buffif (ipv6_addr_equal (ap, &rtinfo->addrs[i])) i++; -if (i == rtinfo->addrnr) -break ; }if (i == rtinfo->addrnr)return ret;
@@ -162,6 +161,12 @@ static int rt_mt6_check(const struct xt_pr_debug ("too many addresses specified\n" );return -EINVAL ; } + +if ((rtinfo->flags &IP6T_RT_FST_MASK ) && !rtinfo->addrnr) { +pr_info_ratelimited ("address list match requested but addrnr is 0\n" ); +return -EINVAL ; + } + if ((rtinfo->flags & (IP6T_RT_RES | IP6T_RT_FST_MASK)) && (!(rtinfo->flags & IP6T_RT_TYP) || (rtinfo->rt_type != 0) ||
Greg Kroah-Hartman
maintainerPATCH 963/982 nfc: fix use-after-free in nfc_get_local_general_bytes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
commit dcab71a7011918f6fdba7adcec02d217dcb84b8d upstream.
Commit 6709d4b7bc2e ("net: nfc: Fix use-after-free caused by nfc_llcp_find_local") attempted to fix a use-after-free (UAF) issue by invoking nfc_llcp_local_put(local) after accessing local->gb. However, if the reference count drops to zero, local is freed immediately, leading to a use-after-free when callers access the returned pointer. Alternative approaches using dynamic allocation (e.g. kmemdup) introduced memory leaks because callers consistently treat the returned pointer as borrowed memory.
Fix this properly by refactoring nfc_llcp_general_bytes() and nfc_get_local_general_bytes() to accept a caller-provided output buffer (out_gb) and its maximum length (gb_max_len). The general bytes are safely copied into out_gb before calling nfc_llcp_local_put(local), ensuring safe lifetime management without ownership transfer complications.
Update all callers across drivers (microread, pn533, pn544, st21nfca, digital_dep, and nci) to provide their own destination buffers and pass them to nfc_get_local_general_bytes().
--- drivers/nfc/microread/microread.c | 6 +++--- drivers/nfc/pn533/pn533.c | 14 ++++++++------ drivers/nfc/pn533/pn533.h | 4 +++- drivers/nfc/pn544/pn544.c | 7 +++---- drivers/nfc/st21nfca/core.c | 8 ++++---- include/net/nfc/hci.h | 2 +- include/net/nfc/nfc.h | 3 ++- net/nfc/core.c | 15 +++++++-------- net/nfc/digital_dep.c | 8 ++++---- net/nfc/llcp_core.c | 17 +++++++++++++---- net/nfc/nci/core.c | 10 +++++----- net/nfc/nfc.h | 3 ++- 12 files changed, 55 insertions(+), 42 deletions(-)
drivers/nfc/microread/microread.c +3 -3
@@ -251,9 +251,9 @@ static int microread_start_poll(struct n param[1 ] |= (1 <<1 );if ((im_protocols | tm_protocols) &NFC_PROTO_NFC_DEP_MASK ) { - hdev->gb =nfc_get_local_general_bytes (hdev->ndev, - &hdev->gb_len); -if (hdev->gb ==NULL || hdev->gb_len ==0 ) { +nfc_get_local_general_bytes (hdev->ndev, hdev->gb, +sizeof (hdev->gb), &hdev->gb_len); +if (hdev->gb_len ==0 ) { im_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; }
drivers/nfc/pn533/pn533.c +8 -6
@@ -1355,10 +1355,11 @@ static int pn533_poll_dep(struct nfc_devu8 *next, nfcid3[NFC_NFCID3_MAXSIZE ];u8 passive_data[PASSIVE_DATA_LEN ] = {0x00 ,0xff ,0xff ,0x00 ,0x3 }; -if (!dev->gb) { - dev->gb =nfc_get_local_general_bytes (nfc_dev, &dev->gb_len); - -if (!dev->gb || !dev->gb_len) { +if (!dev->gb_len) { +nfc_get_local_general_bytes (nfc_dev, dev->gb, +sizeof (dev->gb), + &dev->gb_len); +if (!dev->gb_len) { dev->poll_dep =0 ;queue_work (dev->wq, &dev->rf_work); }
@@ -1660,8 +1661,9 @@ static int pn533_start_poll(struct nfc_d }if (tm_protocols) { - dev->gb =nfc_get_local_general_bytes (nfc_dev, &dev->gb_len); -if (dev->gb ==NULL ) +nfc_get_local_general_bytes (nfc_dev, dev->gb, +sizeof (dev->gb), &dev->gb_len); +if (dev->gb_len ==0 ) tm_protocols =0 ; }
drivers/nfc/pn533/pn533.h +3 -1
@@ -6,6 +6,8 @@* Copyright (C) 2012-2013 Tieto Poland */ +#include <net/nfc/nfc.h> +#define PN533_DEVICE_STD 0x1#define PN533_DEVICE_PASORI 0x2#define PN533_DEVICE_ACR122U 0x3
@@ -166,7 +168,7 @@ struct pn533 {struct timer_list listen_timer;int cancel_listen; -u8 *gb; +u8 gb[NFC_MAX_GT_LEN ];size_t gb_len;u8 tgt_available_prots;
drivers/nfc/pn544/pn544.c +3 -4
@@ -377,10 +377,9 @@ static int pn544_hci_start_poll(struct nreturn r;if ((im_protocols | tm_protocols) &NFC_PROTO_NFC_DEP_MASK ) { - hdev->gb =nfc_get_local_general_bytes (hdev->ndev, - &hdev->gb_len); -pr_debug ("generate local bytes %p\n" , hdev->gb); -if (hdev->gb ==NULL || hdev->gb_len ==0 ) { +nfc_get_local_general_bytes (hdev->ndev, hdev->gb, +sizeof (hdev->gb), &hdev->gb_len); +if (hdev->gb_len ==0 ) { im_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; }
drivers/nfc/st21nfca/core.c +4 -4
@@ -351,10 +351,10 @@ static int st21nfca_hci_start_poll(strucif (r <0 )return r; }else { - hdev->gb =nfc_get_local_general_bytes (hdev->ndev, - &hdev->gb_len); - -if (hdev->gb ==NULL || hdev->gb_len ==0 ) { +nfc_get_local_general_bytes (hdev->ndev, hdev->gb, +sizeof (hdev->gb), + &hdev->gb_len); +if (hdev->gb_len ==0 ) { im_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK ; }
include/net/nfc/hci.h +1 -1
@@ -144,7 +144,7 @@ struct nfc_hci_dev {data_exchange_cb_t async_cb;void *async_cb_context; -u8 *gb; +u8 gb[NFC_MAX_GT_LEN ];size_t gb_len;unsigned long quirks;
include/net/nfc/nfc.h +2 -1
@@ -269,7 +269,8 @@ struct sk_buff *nfc_alloc_recv_skb(unsigint nfc_set_remote_general_bytes (struct nfc_dev *dev,const u8 *gt,u8 gt_len); -u8 *nfc_get_local_general_bytes (struct nfc_dev *dev,size_t *gb_len); +u8 *nfc_get_local_general_bytes (struct nfc_dev *dev,u8 *out_gb, +size_t gb_max_len,size_t *gb_len);int nfc_fw_download_done (struct nfc_dev *dev,const char *firmware_name,u32 result);
net/nfc/core.c +7 -8
@@ -279,10 +279,10 @@ static struct nfc_target *nfc_find_targeint nfc_dep_link_up (struct nfc_dev *dev,int target_index,u8 comm_mode) { -int rc =0 ; -u8 *gb; -size_t gb_len;struct nfc_target *target; +u8 gb[NFC_MAX_GT_LEN ]; +size_t gb_len =0 ; +int rc =0 ;pr_debug ("dev_name=%s comm %d\n" ,dev_name (&dev->dev), comm_mode);
@@ -301,7 +301,7 @@ int nfc_dep_link_up(struct nfc_dev *dev, goto error; } - gb =nfc_llcp_general_bytes (dev, &gb_len); +nfc_get_local_general_bytes (dev, gb,sizeof (gb), &gb_len);if (gb_len >NFC_MAX_GT_LEN ) { rc = -EINVAL ; goto error;
@@ -644,11 +644,10 @@ int nfc_set_remote_general_bytes(struct }EXPORT_SYMBOL (nfc_set_remote_general_bytes); -u8 *nfc_get_local_general_bytes (struct nfc_dev *dev,size_t *gb_len) +u8 *nfc_get_local_general_bytes (struct nfc_dev *dev,u8 *out_gb, +size_t gb_max_len,size_t *gb_len) { -pr_debug ("dev_name=%s\n" ,dev_name (&dev->dev)); - -return nfc_llcp_general_bytes (dev, gb_len); +return nfc_llcp_general_bytes (dev, out_gb, gb_max_len, gb_len); }EXPORT_SYMBOL (nfc_get_local_general_bytes);
net/nfc/digital_dep.c +4 -4
@@ -1490,14 +1490,14 @@ static int digital_tg_send_atr_res(struc struct digital_atr_req *atr_req) {struct digital_atr_res *atr_res; +u8 gb[NFC_MAX_GT_LEN ];struct sk_buff *skb; -u8 *gb, payload_bits; +u8 payload_bits;size_t gb_len;int rc; - gb =nfc_get_local_general_bytes (ddev->nfc_dev, &gb_len); -if (!gb) - gb_len =0 ; +nfc_get_local_general_bytes (ddev->nfc_dev, gb,sizeof (gb), + &gb_len); skb =digital_skb_alloc (ddev,sizeof (struct digital_atr_res ) + gb_len);if (!skb)
net/nfc/llcp_core.c +13 -4
@@ -651,23 +651,32 @@ out:return ret; } -u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,size_t *general_bytes_len) +u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,u8 *out_gb,size_t gb_max_len, +size_t *general_bytes_len) {struct nfc_llcp_local *local; +if (!out_gb || !general_bytes_len) +return NULL ; + local =nfc_llcp_find_local (dev); -if (local ==NULL ) { +if (!local) { *general_bytes_len =0 ;return NULL ; }nfc_llcp_build_gb (local); - *general_bytes_len = local->gb_len; +if (local->gb_len) { + *general_bytes_len =min_t (size_t, local->gb_len, gb_max_len); +memcpy (out_gb, local->gb, *general_bytes_len); + }else { + *general_bytes_len =0 ; + }nfc_llcp_local_put (local); -return local->gb; +return out_gb; }int nfc_llcp_set_remote_gb (struct nfc_dev *dev,const u8 *gb,u8 gb_len)
net/nfc/nci/core.c +5 -5
@@ -762,15 +762,15 @@ static int nci_set_local_general_bytes(s {struct nci_dev *ndev =nfc_get_drvdata (nfc_dev);struct nci_set_config_param param; +u8 gb[NFC_MAX_GT_LEN ];int rc; - param.val =nfc_get_local_general_bytes (nfc_dev, ¶m.len); -if ((param.val ==NULL ) || (param.len ==0 )) +nfc_get_local_general_bytes (nfc_dev, gb,sizeof (gb), + ¶m.len); +if (param.len ==0 )return 0 ; -if (param.len >NFC_MAX_GT_LEN ) -return -EINVAL ; - + param.val = gb; param.id =NCI_PN_ATR_REQ_GEN_BYTES ; rc = nci_request(ndev, nci_set_config_req, ¶m,
net/nfc/nfc.h +2 -1
@@ -49,7 +49,8 @@ void nfc_llcp_mac_is_up(struct nfc_dev *int nfc_llcp_register_device (struct nfc_dev *dev);void nfc_llcp_unregister_device (struct nfc_dev *dev);int nfc_llcp_set_remote_gb (struct nfc_dev *dev,const u8 *gb,u8 gb_len); -u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,size_t *general_bytes_len); +u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,u8 *out_gb,size_t gb_max_len, +size_t *general_bytes_len);int nfc_llcp_data_received (struct nfc_dev *dev,struct sk_buff *skb);struct nfc_llcp_local *nfc_llcp_find_local (struct nfc_dev *dev);int nfc_llcp_local_put (struct nfc_llcp_local *local);
Greg Kroah-Hartman
maintainerPATCH 964/982 nfc: llcp: drop truncated I/RR/RNR PDUs in nfc_llcp_recv_hdlc()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
commit 273f9d667cde649f8de9d72b1303cc2f4b658c50 upstream.
nfc_llcp_recv_hdlc() reads the sequence byte skb->data[2], via nfc_llcp_ns()/nfc_llcp_nr(), before any length check. The receive path only guarantees the two-byte LLCP header -- __nfc_llcp_recv() checks it with pskb_may_pull() and nfc_llcp_recv_agf() admits two-byte inner PDUs -- so a two-byte I, RR or RNR PDU reads one byte of uninitialised skb tailroom. The byte becomes N(R)/N(S); a peer can already set those with a well-formed PDU, so this is acting on uninitialised memory, not new peer control.
Guard the read with pskb_may_pull(), as commit 95674f506c63 ("nfc: llcp:
reject PDUs shorter than the LLCP header") did for the two-byte header, so the sequence byte is present and linear before it is read. RR and RNR PDUs are LLCP_HEADER_SIZE + LLCP_SEQUENCE_SIZE bytes and an I PDU is longer, so no valid frame is rejected; a truncated PDU is malformed, so return without a DM reply.
--- net/nfc/llcp_core.c | 3 +++ 1 file changed, 3 insertions(+)
net/nfc/llcp_core.c +3 -0
@@ -1099,6 +1099,9 @@ static void nfc_llcp_recv_hdlc(struct nfstruct sock *sk;u8 dsap, ssap, ptype, ns, nr; +if (!pskb_may_pull (skb,LLCP_HEADER_SIZE +LLCP_SEQUENCE_SIZE )) +return ; + ptype =nfc_llcp_ptype (skb); dsap =nfc_llcp_dsap (skb); ssap =nfc_llcp_ssap (skb);
Greg Kroah-Hartman
maintainerPATCH 965/982 nfc: port100: reject frames whose declared length exceeds the received data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doruk Tan Ozturk <[email protected]>
commit 092c6a605cbd6414ef499834c2e0da69c2c3388e upstream.
port100_recv_response() passes the URB transfer buffer to port100_rx_frame_is_valid(), which checksums le16_to_cpu(frame->datalen) bytes of frame->data. datalen is a 16-bit field supplied by the device and is never checked against the number of bytes actually received (urb->actual_length), so a device reporting a datalen larger than the received frame makes port100_data_checksum() read out of bounds past the transfer buffer.
Reject a response whose declared frame size does not fit the received length before validating it.
Found by 0sec (https://0sec.ai) using automated source analysis; the missing bound is evident from source. Compile-tested.
--- drivers/nfc/port100.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/nfc/port100.c +7 -0
@@ -636,6 +636,13 @@ static void port100_recv_response(struct in_frame = dev->in_urb->transfer_buffer; +if (urb->actual_length <PORT100_FRAME_HEADER_LEN || + urb->actual_length <port100_rx_frame_size (in_frame)) { +nfc_err (&dev->interface->dev,"Received a truncated frame\n" ); + cmd->status = -EIO ; + goto sched_wq; + } +if (!port100_rx_frame_is_valid (in_frame)) {nfc_err (&dev->interface->dev,"Received an invalid frame\n" ); cmd->status = -EIO ;
Greg Kroah-Hartman
maintainerPATCH 966/982 scsi: libiscsi_tcp: Check the data direction of a Data-In PDU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
commit bce07e2f37b5e4a427d36fd6b1c14067b27591db upstream.
The Data-In branch of iscsi_tcp_hdr_dissect() resolves the ITT to a task and copies the PDU's data segment into that command's scatterlist without asking whether the command was reading. iscsi_tcp_r2t_rsp() in the same file does ask, and rejects an R2T for a command that is not DMA_TO_DEVICE.
A target that answers a WRITE command's ITT with a Data-In therefore has the initiator write target-supplied bytes into the pages that write was about to send. Those are the caller's own pinned pages for an O_DIRECT write, and page cache pages for a buffered one.
Observed against a test target that emits one 512-byte Data-In naming a 128 KB write's ITT, after the R2T for that write. With O_DIRECT the caller's buffer ends up holding 512 bytes of the target's data while pwrite() returns 131072. Buffered is quieter: pwrite() and fsync() both succeed, nothing is logged, and reading those blocks back returns the target's bytes out of the page cache without a command going on the wire.
Check the direction before using the scatterlist, the way the R2T path already does.
--- drivers/scsi/libiscsi_tcp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/libiscsi_tcp.c +3 -0
@@ -491,6 +491,9 @@ static int iscsi_tcp_data_in(struct iscsint datasn =be32_to_cpu (rhdr->datasn);unsigned total_in_length = task->sc->sdb.length; +if (task->sc->sc_data_direction !=DMA_FROM_DEVICE ) +return ISCSI_ERR_PROTO ; +/* * lib iscsi will update this in the completion handling if there * is status.
Greg Kroah-Hartman
maintainerPATCH 967/982 pinctrl: single: free the IRQ on domain creation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 1d9bb9c870632adea249cfdec49ac37e6f069164 upstream.
pcs_irq_init_chained_handler() requests a shared IRQ on affected SoCs, but its domain creation failure path only removes a chained handler. That does not release the action installed by request_irq(). The probe can continue without interrupt support while leaving the shared IRQ action registered.
Use pcs_irq_free() to undo the appropriate type of handler registration. At this point pcs->domain is NULL, so the helper only releases the parent IRQ handler. Then mark the IRQ invalid, as the other initialization error paths already do, to prevent another release from a later probe unwind or remove.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/pinctrl/pinctrl-single.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +2 -1
@@ -1631,7 +1631,8 @@ static int pcs_irq_init_chained_handler( &pcs_irqdomain_ops, pcs_soc);if (!pcs->domain) { -irq_set_chained_handler (pcs_soc->irq,NULL ); +pcs_irq_free (pcs); + pcs_soc->irq =-1 ;return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 968/982 s390/cio: Fix NULL pointer dereference in ccw_device_get_util_str()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineeth Vijayan <[email protected]>
commit 5b76268dac968612f7283d59b539036de955b7d9 upstream.
The channel path registry entry associated with a CHPID may be removed while the subchannel's PMCW still references that CHPID. In this case, chpid_to_chp() can return NULL, leading to a NULL pointer dereference.
Add the missing NULL check before dereferencing the returned pointer.
--- drivers/s390/cio/device_ops.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/cio/device_ops.c +2 -0
@@ -509,6 +509,8 @@ u8 *ccw_device_get_util_str(struct ccw_dchp_id_init (&chpid); chpid.id = sch->schib.pmcw.chpid[chp_idx]; chp =chpid_to_chp (chpid); +if (!chp) +return NULL ; util_str =kmalloc (sizeof (chp->desc_fmt3.util_str),GFP_KERNEL );if (!util_str)
Greg Kroah-Hartman
maintainerPATCH 969/982 RISC-V: KVM: Synchronize hrtimer callback during teardown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit aaad136d56d91252517272b68cd533e5714698d5 upstream.
The non-Sstc hrtimer callback clears next_set before its final uses of the enclosing vCPU. If teardown observes next_set as false while the callback is still running, kvm_riscv_vcpu_timer_cancel() skips hrtimer_cancel() and kvm_destroy_vcpus() can free the vCPU before the callback enters kvm_riscv_vcpu_set_interrupt().
A guest can arm the timer with SBI TIME and request shutdown with SBI legacy shutdown or SRST. A VMM that honors KVM_EXIT_SYSTEM_EVENT and destroys the VM supplies the teardown side of the race; no post-launch host ioctl is needed to arm or request teardown.
On upstream master 62cc90241548, generic KASAN reported:
BUG: KASAN: slab-use-after-free in do_raw_spin_lock Write of size 4 at addr ff60000005e58898
kvm_riscv_vcpu_set_interrupt
kvm_riscv_vcpu_hrtimer_expired
__hrtimer_run_queues
hrtimer_interrupt
The object was allocated by KVM_CREATE_VCPU and freed concurrently by:
kvm_destroy_vcpus
kvm_arch_destroy_vm
kvm_destroy_vm
__fput
For deterministic validation, I added mdelay(1000) immediately after the existing next_set = false assignment. This only widens the existing post-clear callback window. A no-delay trace build naturally reached the callback-after-teardown-start/before-deinit ordering in 12 of 200 runs, but 1,500 stock-kernel stress iterations did not produce a KASAN report, so natural reproduction is timing-sensitive.
Always invoke hrtimer_cancel() for an initialized timer. Preserve the existing -EINVAL result when the timer is no longer set, but only after synchronizing with a running callback.
With this patch, hrtimer_cancel() blocked for the full widened callback window before vCPU destruction. KASAN reported no error in 100 fixed-and-widened runs or 200 fix-only timing-sweep runs.
--- arch/riscv/kvm/vcpu_timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/riscv/kvm/vcpu_timer.c +4 -1
@@ -60,10 +60,13 @@ static enum hrtimer_restart kvm_riscv_vcstatic int kvm_riscv_vcpu_timer_cancel (struct kvm_vcpu_timer *t) { -if (!t->init_done || !t->next_set) +if (!t->init_done)return -EINVAL ;hrtimer_cancel (&t->hrt); + +if (!t->next_set) +return -EINVAL ; t->next_set = false;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 970/982 Bluetooth: hci_sock: validate event length before filtering
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
commit b0a6cf99afd57a39598b1beca0e86ef5004980de upstream.
is_filtered_packet() reads the event code from skb->data[0] without first checking that the skb is nonempty. When an opcode filter is configured, it also reads the command opcode at offsets 3 or 4 without checking that a Command Complete or Command Status event is long enough.
hci_send_to_sock() invokes the filter before hci_event_packet() validates the event header. A malformed event supplied by a controller or a vhci device can therefore cause an out-of-bounds read.
Keep the unmasked event code for the opcode checks. The masked value is needed for the 64-bit event bitmap, but using it to identify command events aliases event codes above 0x3f. In particular, Synchronous Train Complete (0x4f) was treated as Command Status (0x0f) even though its payload has no opcode.
Reject actual command events that are too short for the field being inspected. A truncated command event cannot match a configured opcode.
--- net/bluetooth/hci_sock.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
net/bluetooth/hci_sock.c +14 -3
@@ -166,6 +166,7 @@ static bool is_filtered_packet(struct so {struct hci_filter *flt;int flt_type, flt_event; +u8 event;/* Apply filter */ flt = &hci_pi (sk)->filter;
@@ -179,7 +180,11 @@ static bool is_filtered_packet(struct soif (hci_skb_pkt_type (skb) !=HCI_EVENT_PKT )return false; - flt_event = (*(__u8 *)skb->data &HCI_FLT_EVENT_BITS ); +if (skb->len <1 ) +return true; + + event = *(__u8 *)skb->data; + flt_event = event &HCI_FLT_EVENT_BITS ;if (!hci_test_bit (flt_event, &flt->event_mask))return true;
@@ -188,11 +193,17 @@ static bool is_filtered_packet(struct soif (!flt->opcode)return false; -if (flt_event ==HCI_EV_CMD_COMPLETE && +if (event ==HCI_EV_CMD_COMPLETE && skb->len <5 ) +return true; + +if (event ==HCI_EV_CMD_COMPLETE && flt->opcode !=get_unaligned ((__le16 *)(skb->data +3 )))return true; -if (flt_event ==HCI_EV_CMD_STATUS && +if (event ==HCI_EV_CMD_STATUS && skb->len <6 ) +return true; + +if (event ==HCI_EV_CMD_STATUS && flt->opcode !=get_unaligned ((__le16 *)(skb->data +4 )))return true;
Greg Kroah-Hartman
maintainerPATCH 971/982 Bluetooth: hci_sock: reject out-of-range OCF values
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
commit e93fad891c72deb84cae49430163b384ebcc92b1 upstream.
The raw HCI socket security filter has 128 OCF bits per supported OGF, but masks the 10-bit OCF with 127 before looking up the command. An unprivileged socket can therefore submit a reserved OCF that aliases an allowlisted command modulo 128.
A conforming controller should reject reserved opcodes. Nevertheless, the security decision must apply to the opcode that will actually be sent, especially since controller-specific behavior is outside the host stack's control.
Reject OCF values that cannot be represented by the security filter instead of aliasing them onto an unrelated command.
--- net/bluetooth/hci_sock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/hci_sock.c +2 -1
@@ -1823,7 +1823,8 @@ static int hci_sock_sendmsg(struct sockeu16 ocf =hci_opcode_ocf (opcode);if (((ogf >HCI_SFLT_MAX_OGF ) || - !hci_test_bit (ocf &HCI_FLT_OCF_BITS , + (ocf >HCI_FLT_OCF_BITS ) || + !hci_test_bit (ocf, &hci_sec_filter.ocf_mask[ogf])) && !capable (CAP_NET_RAW )) { err = -EPERM ;
Greg Kroah-Hartman
maintainerPATCH 972/982 Bluetooth: L2CAP: validate frame length before control and FCS access
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
commit 6c78a213d9070b610c7f418af2c25b66180b7e37 upstream.
l2cap_data_rcv() unpacks either a two-byte or four-byte control field without first ensuring that it is present. A short ERTM or streaming-mode frame can therefore cause an out-of-bounds read.
There is a second short-frame case when CRC16 is enabled. After the control field is pulled, l2cap_check_fcs() subtracts two from skb->len without checking it. If fewer than two bytes remain, the subtraction wraps; skb_trim() leaves the buffer unchanged and the subsequent FCS load reads past the logical end of the frame.
Validate that the frame contains both its control field and, when enabled, its FCS before either field is accessed.
--- net/bluetooth/l2cap_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +9 -1
@@ -6725,9 +6725,17 @@ static int l2cap_stream_rx(struct l2cap_static int l2cap_data_rcv (struct l2cap_chan *chan,struct sk_buff *skb) {struct l2cap_ctrl *control = &bt_cb (skb)->l2cap; -u16 len; +u16 len, min_len;u8 event; + min_len =test_bit (FLAG_EXT_CTRL , &chan->flags) ? +L2CAP_EXT_CTRL_SIZE :L2CAP_ENH_CTRL_SIZE ; +if (chan->fcs ==L2CAP_FCS_CRC16 ) + min_len +=L2CAP_FCS_SIZE ; + +if (skb->len < min_len) + goto drop; +__unpack_control (chan, skb); len = skb->len;
Greg Kroah-Hartman
maintainerPATCH 973/982 Bluetooth: RFCOMM: fix NULL dereference of dlc->session in RFCOMM_CONNINFO
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit 46f8ffd0a1f1eb6cbc94946a92c11ef601e228a1 upstream.
The RFCOMM_CONNINFO getsockopt handler accepts a socket that is not connected as long as deferred setup is enabled:
if (sk->sk_state != BT_CONNECTED &&
!rfcomm_pi(sk)->dlc->defer_setup) {
err = -ENOTCONN;
break;
}
l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk;dlc->defer_setup is set in rfcomm_sock_init() when rfcomm_connect_ind() creates a child socket for an incoming connection on a listening socket that has BT_DEFER_SETUP enabled. It is never cleared afterwards. The session, however, can go away underneath it.
rfcomm_recv_disc() forces the dlc state before tearing it down:
d->state = BT_CLOSED; __rfcomm_dlc_close(d, err);
The RFCOMM_DEFER_SETUP early return in __rfcomm_dlc_close() only covers BT_CONNECT, BT_CONFIG, BT_OPEN and BT_CONNECT2, so with the state already BT_CLOSED that switch does not match and the function falls through to rfcomm_dlc_unlink(), which sets d->session = NULL, while d->defer_setup stays 1.
A getsockopt(SOL_RFCOMM, RFCOMM_CONNINFO) on the accepted socket after that point therefore skips the -ENOTCONN path -- sk->sk_state is BT_CLOSED, but dlc->defer_setup is still set -- and dereferences the NULL session. No race is needed: once the DISC has been processed, the dereference is unconditional.
Reproduced on a KASAN kernel under QEMU with a BR/EDR peer emulated over /dev/vhci: the peer brings up an ACL link, opens L2CAP on the RFCOMM PSM, starts a session and sends SABM for a channel bound with BT_DEFER_SETUP, and sends DISC for that dlci after the socket has been accepted. getsockopt(SOL_RFCOMM, RFCOMM_CONNINFO) on the accepted socket then hits:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] CPU: 1 UID: 0 PID: 150 Comm: init Tainted: G B 7.3.0-rc3-g5dd1818b15d9 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:rfcomm_sock_getsockopt+0x529/0x780 Call Trace: <TASK> do_sock_getsockopt+0x3ad/0x7d0 __sys_getsockopt+0x10e/0x1b0 __x64_sys_getsockopt+0xc2/0x160 do_syscall_64+0xda/0x4b0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
0x10 is the offset of sock in struct rfcomm_session; rfcomm_sock_getsockopt_old() is inlined into rfcomm_sock_getsockopt().
Commit 43a556b2fd43 ("Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept") fixed the same "a remote DISC clears the session while deferred setup is still flagged" problem in rfcomm_dlc_accept(); this is the remaining instance of it, in the getsockopt path.
Deferred setup only leaves a socket usable here once it has reached BT_CONNECT2, so restrict the exception to that state and check that a session is actually present before following it.
--- net/bluetooth/rfcomm/sock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/rfcomm/sock.c +4 -2
@@ -786,8 +786,10 @@ static int rfcomm_sock_getsockopt_old(stbreak ;case RFCOMM_CONNINFO : -if (sk->sk_state !=BT_CONNECTED && - !rfcomm_pi (sk)->dlc->defer_setup) { +if ((sk->sk_state !=BT_CONNECTED && + !(sk->sk_state ==BT_CONNECT2 && +rfcomm_pi (sk)->dlc->defer_setup)) || + !rfcomm_pi (sk)->dlc->session) { err = -ENOTCONN ;break ; }
Greg Kroah-Hartman
maintainerPATCH 974/982 smb: client: validate POSIX create context length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
commit fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc upstream.
parse_posix_ctxt() reads the fixed nlink, reparse_tag, and mode fields before checking that the POSIX create context contains them. A short context can pass the generic checks and still make these fixed-width reads run past its declared data.
The current in-tree smb2_open_file() path passes a NULL posix pointer, so this handler is not reached on the ordinary open path. Still require the POSIX data to cover all three fields before reading them because the helper performs those unguarded reads. Keep the existing soft-failure behavior so malformed optional metadata does not fail the open.
--- fs/smb/client/smb2pdu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/smb/client/smb2pdu.c +5 -2
@@ -2190,12 +2190,15 @@ static void parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info, struct create_posix_rsp *posix) { - int sid_len; u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset); -u8 *end = beg +le32_to_cpu (cc->DataLength); +u32 dlen =le32_to_cpu (cc->DataLength); +u8 *end = beg + dlen; +int sid_len;u8 *sid;memset (posix,0 ,sizeof (*posix)); +if (dlen <3 *sizeof (__le32)) +return ; posix->nlink =get_unaligned_le32 (beg); posix->reparse_tag =get_unaligned_le32 (beg +4 );
Greg Kroah-Hartman
maintainerPATCH 975/982 xfs: fix blockgc group quota scanning when usrquota isnt enforced
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
commit f8f6382ff13109e19d0fc1d0224ff7d29641e56a upstream.
LOLLM noticed the copy-paste error here -- if user quotas aren't enforced but we're near the group quota limit, we fail to set FLAG_GID and hence we might not actually free any preallocations, causing unnecessary EDQUOT. Fix that.
--- fs/xfs/xfs_icache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_icache.c +1 -1
@@ -1578,7 +1578,7 @@ xfs_blockgc_free_dquots( do_work = true; } -if (XFS_IS_UQUOTA_ENFORCED (mp) && gdqp &&xfs_dquot_lowsp (gdqp)) { +if (XFS_IS_GQUOTA_ENFORCED (mp) && gdqp &&xfs_dquot_lowsp (gdqp)) { icw.icw_gid =make_kgid (mp->m_super->s_user_ns, gdqp->q_id); icw.icw_flags |=XFS_ICWALK_FLAG_GID ; do_work = true;
Greg Kroah-Hartman
maintainerPATCH 976/982 net: tls: fix silent data drop under pipe back-pressure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 7e7be31bfdb066c1c780dcd6b1224078fc54063f ]
tls_sw_splice_read() uses len when advancing rxm->offset / rxm->full_len after skb_splice_bits(), rather than copied (the actual number of bytes successfully spliced into the pipe). When the destination pipe cannot accept all the requested bytes, splice_to_pipe() returns fewer bytes than len, and 'len - copied' of data is effectively skipped over.
--- net/tls/tls_sw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/tls/tls_sw.c +3 -3
@@ -2392,9 +2392,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,if (copied <0 ) goto splice_requeue; -if (chunk < rxm->full_len) { - rxm->offset += len; - rxm->full_len -= len; +if (copied < rxm->full_len) { + rxm->offset += copied; + rxm->full_len -= copied; goto splice_requeue; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 977/982 perf test: Change all remaining #!/bin/sh to #!/bin/bash
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Clark <[email protected]>
commit 2f5d370dec3f800b44bbf7b68875d521e0af43cd upstream.
There are 43 instances of posix shell tests and 35 instances of bash. To give us a single consistent language for testing in, replace all #!/bin/sh to #!/bin/bash. Common sources that are included in both different shells will now work as expected. And we no longer have to fix up bashisms that appear to work when someone's system has sh symlinked to bash, but don't work on other systems that have both shells installed.
Although we could have chosen sh, it's not backwards compatible so it wouldn't be possible to bulk convert without re-writing the existing bash tests.
Choosing bash also gives us some nicer features including 'local' variable definitions and regexes in if statements that are already widely used in the tests.
It's not expected that there are any users with only sh available due to the large number of bash tests that exist.
Discussed in relation to running shellcheck here:
https://lore.kernel.org/linux-perf-users/e3751a74be34bbf3781c4644f518702a7270220b.1749785642.git.collin.funk1@gmail.com/
When commit b02027776ac5 ("perf tests: Fix flakiness in BPF counters test on hybrid systems") was backported to several stable series (v5.15.221, v6.1.188, v6.6.157, v6.12.110, v6.18.52, v7.2.6) it introduced specific bash syntax. For versions after 2f5d370dec3f ("perf
test: Change all remaining #!/bin/sh to #!/bin/bash") in v6.17-rc1 this is not a problem as the shebang was already hanged to #!/bin/bash. For the older stable series this introduced invalid syntax if #!/bin/sh is not bash:
$ sh -n tools/perf/tests/shell/stat_bpf_counters.sh
tools/perf/tests/shell/stat_bpf_counters.sh: 12: Syntax error: "(" unexpected $ checkbashism tools/perf/tests/shell/stat_bpf_counters.sh
possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 52 (bash arrays, ${name[0|*|@]}):
base_instructions=$(perf stat --no-big-num -e instructions:u -- "${workload[@]}" 2>&1 | \
awk -v i=0 -v c=0 '/instructions/ { \
if ($1 != "<not") { i++; c += $1 } \
} END { if (i > 0) printf "%.0f", c; else print "<not" }')
possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 57 (bash arrays, ${name[0|*|@]}):
bpf_instructions=$(perf stat --no-big-num --bpf-counters -e instructions:u \
-- "${workload[@]}" 2>&1 | \
awk -v i=0 -v c=0 '/instructions/ { \
if ($1 != "<not") { i++; c += $1 } \
} END { if (i > 0) printf "%.0f", c; else print "<not" }')
possible bashism in tools/perf/tests/shell/stat_bpf_counters.sh line 68 (bash arrays, ${name[0|*|@]}):
stat_output=$(perf stat --no-big-num \
-e instructions/name=base_instructions/u,instructions/name=bpf_instructions/bu \
-- "${workload[@]}" 2>&1)Change shebang for the stat_bpf_counters.sh script.
No upstream commit exists for this change as for versions post 6.17-rc1 the scripts were converted to #!/bin/bash already.
--- tools/perf/tests/shell/stat_bpf_counters.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/stat_bpf_counters.sh +1 -1
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # perf stat --bpf-counters test # SPDX-License-Identifier: GPL-2.0
Greg Kroah-Hartman
maintainerPATCH 978/982 tools/thermal/tmon: Fix compilation warning for wrong format
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Eckert <[email protected]>
commit 9da39ef332c417ce52732564c1c682a6e1209302 upstream.
The following warnings are shown during compilation:
tui.c: In function 'show_cooling_device':
tui.c:216:40: warning: format '%d' expects argument of type 'int', but
argument 7 has type 'long unsigned int' [-Wformat=]
216 | "%02d %12.12s%6d %6d",
| ~~^
| |
| int
| %6ld
......
219 | ptdata.cdi[j].cur_state,
| ~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
tui.c:216:44: warning: format '%d' expects argument of type 'int', but
argument 8 has type 'long unsigned int' [-Wformat=]
216 | "%02d %12.12s%6d %6d",
| ~~^
| |
| int
| %6ld
......
220 | ptdata.cdi[j].max_state);
| ~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned intTo fix this, the correct string format must be used for printing.
--- tools/thermal/tmon/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tui.c +1 -1
@@ -213,7 +213,7 @@ void show_cooling_device(void)* cooling device instances. skip unused idr. */ mvwprintw(cooling_device_window, j + 2, 1, - "%02d %12.12s%6d %6d", + "%02d %12.12s%6lu %6lu", ptdata.cdi[j].instance, ptdata.cdi[j].type, ptdata.cdi[j].cur_state,
Greg Kroah-Hartman
maintainerPATCH 979/982 lan78xx: Enable 125 MHz CLK configuration for LAN7801 if NO EEPROM is detected
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rengarajan S <[email protected]>
commit 5160b129f65fc6e1a4aa282d44f824e12aa800ee upstream.
The 125MHz and 25MHz clock configurations are enabled in the initialization regardless of EEPROM (125MHz is needed for RGMII 1000Mbps operation). After a lite reset (lan78xx_reset), these contents go back to defaults(all 0, so no 125MHz or 25MHz clock).
--- drivers/net/usb/lan78xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/usb/lan78xx.c +2 -0
@@ -2979,6 +2979,8 @@ static int lan78xx_reset(struct lan78xx_return ret; buf |=HW_CFG_MEF_ ; + buf |=HW_CFG_CLK125_EN_ ; + buf |=HW_CFG_REFCLK25_EN_ ; ret =lan78xx_write_reg (dev,HW_CFG , buf);if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 980/982 lan78xx: Enable Auto Speed and Auto Duplex configuration for LAN7801 if NO EEPROM is detected
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rengarajan S <[email protected]>
commit 799f532de13601f91ecb9cc6169d45d6e6933b0f upstream.
Enabled ASD/ADD configuration for LAN7801 in the absence of EEPROM. After the lite reset these contents go back to defaults where ASD/ ADD is disabled. The check is already available for LAN7800.
--- drivers/net/usb/lan78xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +4 -1
@@ -3069,8 +3069,11 @@ static int lan78xx_reset(struct lan78xx_return ret;/* LAN7801 only has RGMII mode */ -if (dev->chipid ==ID_REV_CHIP_ID_7801_ ) +if (dev->chipid ==ID_REV_CHIP_ID_7801_ ) { buf &= ~MAC_CR_GMII_EN_ ; +/* Enable Auto Duplex and Auto speed */ + buf |=MAC_CR_AUTO_DUPLEX_ |MAC_CR_AUTO_SPEED_ ; + }if (dev->chipid ==ID_REV_CHIP_ID_7800_ || dev->chipid ==ID_REV_CHIP_ID_7850_ ) {
Greg Kroah-Hartman
maintainerPATCH 981/982 drm/amdgpu/atom: Check kcalloc() for WS buffer in amdgpu_atom_execute_table_locked()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit cc9a8e238e42c1f43b98c097995137d644b69245 upstream.
kcalloc() may fail. When WS is non-zero and allocation fails, ectx.ws remains NULL while ectx.ws_size is set, leading to a potential NULL pointer dereference in atom_get_src_int() when accessing WS entries.
Return -ENOMEM on allocation failure to avoid the NULL dereference.
--- drivers/gpu/drm/amd/amdgpu/atom.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +7 -2
@@ -1228,10 +1228,15 @@ static int amdgpu_atom_execute_table_loc ectx.ps = params; ectx.abort = false; ectx.last_jump =0 ; -if (ws) +if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); -else +if (!ectx.ws) { + ret = -ENOMEM ; + goto free; + } + }else { ectx.ws =NULL ; + } debug_depth++;while (1 ) {
Greg Kroah-Hartman
maintainerPATCH 982/982 ALSA: hda: Fix missing pointer check in hda_component_manager_init function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit 1cf11d80db5df805b538c942269e05a65bcaf5bc upstream.
The __component_match_add function may assign the 'matchptr' pointer the value ERR_PTR(-ENOMEM), which will subsequently be dereferenced.
The call stack leading to the error looks like this:
hda_component_manager_init
|-> component_match_add
|-> component_match_add_release
|-> __component_match_add ( ... ,**matchptr, ... )
|-> *matchptr = ERR_PTR(-ENOMEM); // assign
|-> component_master_add_with_match( ... match)
|-> component_match_realloc(match, match->num); // dereferenceAdd IS_ERR() check to prevent the crash.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
[Roman: Instead of modifying hda_component_manager_init() (which does not yet exist in version 6.1), a check needs to be added to the cs35l41_generic_fixup() function—the very function introduced by the offending commit, which calls component_match_add() without verifying its successful completion.]
--- sound/pci/hda/patch_realtek.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/hda/patch_realtek.c +5 -0
@@ -7021,6 +7021,11 @@ static void cs35l41_generic_fixup(struct spec->comps[i].codec = cdc;component_match_add (dev, &spec->match, comp_match_cs35l41_dev_name, rec); +if (IS_ERR (spec->match)) { +codec_err (cdc,"Fail to add component %ld\n" , +PTR_ERR (spec->match)); +return ; + } } ret =component_master_add_with_match (dev, &comp_master_ops, spec->match);if (ret)
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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 Fri, 02 Oct 2026 15:23:04 +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/v6.x/stable-review/patch-6.1.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Am 30.09.2026 um 17:12 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.1.y
Best regards,
Pavel
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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 Fri, 02 Oct 2026 15:23:04 +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/v6.x/stable-review/patch-6.1.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 8 lines · On Wed, 30 Sep 2026 17:12:16 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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 Fri, 02 Oct 2026 15:23:04 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64:
Thanks!
Cheers,
Miguel
# Librecast Test Results
044/044 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.1.189-rc1-00983-gae9e011542b0 #1 SMP PREEMPT_DYNAMIC Thu Oct 1 15:02:46 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.189 release. There are 982 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 Fri, 02 Oct 2026 15:23:04 +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/v6.x/stable-review/patch-6.1.189-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
Tested on an amd64 laptop (Lenovo ThinkPad T14 Gen 1). Working well, no regressions observed.
Signature · 1 line
-Barry K. Nathan <[email protected]>