6.6.158-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 393/1193 net/sched: act_api: fix skb sizing and action leak on reoffload delete
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 251367a0a3319fa565daf7468b0afd933b1f5ab1 ]
tcf_reoffload_del_notify_msg() sizes the RTM_DELACTION skb with tcf_action_fill_size(action) alone. Unlike every other notification path it never wraps that in tcf_action_full_attrs_size(), so the nlmsg_put() header, struct tcamsg and the TCA_ACT_TAB nest that tca_get_fill() emits - 24 bytes on x86_64 - are not budgeted. As long as the single action stays well under NLMSG_GOODSIZE the floor in alloc_skb() hides this, but once its fill size crosses NLMSG_GOODSIZE the allocation is exactly 24 bytes short and tca_get_fill() runs out of tailroom. That is now easy to reach for an offloadable act_pedit with a large tcfp_nkeys, which commit 8e2efb3f45a5 ("net/sched: add get_fill_size callbacks for actions missing them") started accounting for properly.
When that happens tcf_reoffload_del_notify() returns early, before tcf_idr_release_unsafe(), and tcf_action_reoffload_cb() discards the return value:
if (tc_act_skip_sw(p->tcfa_flags) && !tc_act_in_hw(p)) tcf_reoffload_del_notify(net, p);
The action has just lost its last hardware instance and is skip_sw, so it is left installed while processing no packets, and with no notification to tell userspace about it. An -ENOBUFS from alloc_skb() gets the same treatment.
Fix this by budgeting the message header the way the add and delete paths do, and release the action even when the notification cannot be built - dropping the notification is strictly better than leaking a dead action, and there is no caller left to report the error to.
--- net/sched/act_api.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/sched/act_api.c +11 -6
@@ -1834,11 +1834,13 @@ static int tcf_action_delete(struct net *net, struct tc_action *actions[])static struct sk_buff *tcf_reoffload_del_notify_msg (struct net *net,struct tc_action *action) { -size_t attr_size =tcf_action_fill_size (action);struct tc_action *actions[TCA_ACT_MAX_PRIO ] = { [0 ] = action, };struct sk_buff *skb; +size_t attr_size; + + attr_size =tcf_action_full_attrs_size (tcf_action_fill_size (action)); skb =alloc_skb (max (attr_size,NLMSG_GOODSIZE ),GFP_KERNEL );if (!skb)
@@ -1855,15 +1857,18 @@ static struct sk_buff *tcf_reoffload_del_notify_msg(struct net *net,static int tcf_reoffload_del_notify (struct net *net,struct tc_action *action) {const struct tc_action_ops *ops = action->ops; -struct sk_buff *skb; +struct sk_buff *skb =NULL ;int ret; -if (!rtnl_notify_needed (net,0 ,RTNLGRP_TC )) { - skb =NULL ; - }else { +if (rtnl_notify_needed (net,0 ,RTNLGRP_TC )) { skb =tcf_reoffload_del_notify_msg (net, action); +/* The action has already lost its hardware instance and is +* skip_sw, so it must be released whether or not the +* notification can be built. Drop the notification rather +* than leave an action behind that processes no packets. +*/ if (IS_ERR (skb)) -return PTR_ERR (skb); + skb =NULL ; } ret =tcf_idr_release_unsafe (action);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/1193 sctp: fix a TOCTOU race in SCTP_CMD_TIMER_START
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 2188569e7e1b0bc3f3b557dc97ab7a02befc11c8 ]
The SCTP_CMD_TIMER_START handler checks timer_pending() before calling timer_reduce(). The timer can expire and detach between these operations, causing timer_reduce() to rearm the timer without taking the association reference required for the newly armed timer.
The timer callback later unconditionally drops its association reference, which can leave the association reference count unbalanced and result in use-after-free during association teardown.
Use the return value of timer_reduce() to determine whether the timer was actually armed. Take the association reference only when timer_reduce() successfully starts a new timer, closing the race between checking the timer state and rearming it.
This issue was reported by Nico Yip (@_cyeaa_) working with TrendAI Zero Day Initiative.
--- net/sctp/sm_sideeffect.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
net/sctp/sm_sideeffect.c +1 -10
@@ -1539,17 +1539,8 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type, timeout = asoc->timeouts[cmd->obj.to];BUG_ON (!timeout); -/* -* SCTP has a hard time with timer starts. Because we process -* timer starts as side effects, it can be hard to tell if we -* have already started a timer or not, which leads to BUG -* halts when we call add_timer. So here, instead of just starting -* a timer, if the timer is already started, and just mod -* the timer with the shorter of the two expiration times -*/ -if (!timer_pending (timer)) +if (!timer_reduce (timer, jiffies + timeout))sctp_association_hold (asoc); -timer_reduce (timer, jiffies + timeout);break ;case SCTP_CMD_TIMER_RESTART :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/1193 scsi: mpi3mr: Fix NULL pointer dereference in mpi3mr_sas_port_add()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milan P. Gandhi <[email protected]>
[ Upstream commit dba9e2181ca5e875f98b8b9b4535cdaab87dcb0d ]
sas_port_alloc_num() can return NULL on memory allocation failure. The return value is passed directly to sas_port_add() without a NULL check, which causes a NULL pointer dereference.
Additionally, if sas_port_add() fails, the allocated port is not freed before jumping to out_fail, leaking the sas_port structure. Call sas_port_free() to properly release it.
--- drivers/scsi/mpi3mr/mpi3mr_transport.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_transport.c +6 -0
@@ -1404,9 +1404,15 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc, } port =sas_port_alloc_num (mr_sas_node->parent_dev); +if (!port) { +ioc_err (mrioc,"failure at %s:%d/%s()!\n" , + __FILE__, __LINE__, __func__); + goto out_fail; + }if ((sas_port_add (port))) {ioc_err (mrioc,"failure at %s:%d/%s()!\n" , __FILE__, __LINE__, __func__); +sas_port_free (port); goto out_fail; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/1193 scsi: mpi3mr: Fix target device refcount leak in mpi3mr_sas_port_add()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milan P. Gandhi <[email protected]>
[ Upstream commit 419d129f970aaa6567dbac366b0c93784bf9ec97 ]
mpi3mr_get_tgtdev_by_addr() increments the target device kref when it returns a device. If a subsequent error triggers a goto out_fail after the tgtdev reference is acquired, the reference is never released because the out_fail path does not call mpi3mr_tgtdev_put(). This prevents the target device structure from ever being freed.
Add a tgtdev put in the out_fail path, guarded by a NULL check since tgtdev is only acquired for SAS_END_DEVICE types and the same cleanup path is shared by earlier error cases where tgtdev is still NULL.
--- drivers/scsi/mpi3mr/mpi3mr_transport.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_transport.c +2 -0
@@ -1483,6 +1483,8 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,list_for_each_entry_safe (mr_sas_phy, next, &mr_sas_port->phy_list, port_siblings)list_del (&mr_sas_phy->port_siblings); +if (tgtdev) +mpi3mr_tgtdev_put (tgtdev);kfree (mr_sas_port);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/1193 smb/client: mark file sparse before emulating insert range
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huiwen He <[email protected]>
[ Upstream commit cd03ce4950d80147ac8f20bc03c42b75b0352407 ]
The SMB client emulates FALLOC_FL_INSERT_RANGE with SET_EOF, COPYCHUNK and SET_ZERO_DATA.
SET_ZERO_DATA creates a hole only when the file is sparse. On a non-sparse file, it clears the inserted range but leaves its blocks allocated, causing the extent count check in xfstests generic/064 to fail.
Fix this by marking the file sparse before modifying it.
This patch produces the expected sparse extents in xfstests generic/064 only when the server-reported block size is compatible with the server's deallocation granularity.
For ksmbd, the reported block size follows the backing filesystem, and the test passes. For Samba, the test passes with a block size matching the backend granularity, for example, 4 KiB on Btrfs, but not with the default 1 KiB value. For Windows Server 2022, 4 KiB inserts do not generate holes, while aligned inserts of 64 KiB or larger do.
--- fs/smb/client/smb2ops.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/smb/client/smb2ops.c +5 -0
@@ -3715,6 +3715,11 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon, count = old_eof - off; new_eof = old_eof + len; +/* SET_ZERO_DATA creates a hole only in a sparse file. */ + rc =smb2_set_sparse (xid, tcon, cfile, inode, true); +if (rc) + goto out; +filemap_invalidate_lock (inode->i_mapping); rc =filemap_write_and_wait_range (inode->i_mapping, off, new_eof -1 );if (rc <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1193 smb: client: transport: Fix debug printing in __release_mid()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit d83a21bb26015bfdd79b0440fe816b271b8bbab3 ]
Long time ago during upgrading printk():s to the respective pr_<level>() calls one misconversion happened and nobody has noticed that. So, previously printk(KERN_DEBUG) + printk() worked as one long debug print since the trailing '\n' is only present in the followup printk() format string. The culprit change missed that and split the message to two on the different levels. Restore the original behaviour to make users be less confused in the most likely never happen cases of partially getting that message.
--- fs/smb/client/transport.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/smb/client/transport.c +5 -6
@@ -143,12 +143,11 @@ void __release_mid(struct kref *refcount)trace_smb3_slow_rsp (smb_cmd, midEntry->mid, midEntry->pid, midEntry->when_sent, midEntry->when_received);if (cifsFYI &CIFS_TIMER ) { -pr_debug ("slow rsp: cmd %d mid %llu" , - midEntry->command, midEntry->mid); -cifs_info ("A: 0x%lx S: 0x%lx R: 0x%lx\n" , - now - midEntry->when_alloc, - now - midEntry->when_sent, - now - midEntry->when_received); +pr_debug ("slow rsp: cmd %d mid %llu A: 0x%lx S: 0x%lx R: 0x%lx\n" , + midEntry->command, midEntry->mid, + now - midEntry->when_alloc, + now - midEntry->when_sent, + now - midEntry->when_received); } }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1193 sctp: fix soft lockup from unpadded ASCONF-ACK parameter iteration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 2cb0b0b1ed69430bf73740377ea0a1c44c50db63 ]
sctp_verify_asconf() walks ASCONF-ACK parameters with sctp_walk_params(), which advances by SCTP_PAD4(length), while the consumer sctp_get_asconf_response() iterates the same parameters advancing by the raw length, without padding. A single odd-length parameter desynchronises the two walks and makes the consumer interpret attacker-controlled bytes at a misaligned offset.
When those bytes yield a length of zero, the while loop over asconf_ack_len makes no progress, spinning forever in softirq context, and the watchdog reports a soft lockup. All reads stay within the received skb, so the lockup is a pure remote denial of service. A remote peer can trigger it with a crafted ASCONF-ACK on an ADD-IP enabled association with an outstanding ASCONF (RFC 5061 section 4.1.2 requires the chunk to be authenticated, but the predefined empty key id 0 allows the peer to compute the same association HMAC from publicly exchanged parameters, so the gate does not help).
The SCTP_PARAM_ERR_CAUSE case of sctp_verify_asconf() also performs no length check, letting a parameter without a complete error header reach the consumer, which reads errhdr.cause past the end of the parameter, an out-of-bounds read.
Reject SCTP_PARAM_ERR_CAUSE parameters shorter than sizeof(struct sctp_addip_param) + sizeof(struct sctp_errhdr) at the verifier, and advance the consumer iterator with the same padding rule as the verifier to keep the two walks in lockstep. The verifier change guarantees a complete error header in every ERR_CAUSE parameter the consumer can see, so the consumer's asconf_ack_len check is dropped and it returns err_param->cause directly. The consumer padding fix is still required because odd lengths remain valid for SCTP_PARAM_ERR_CAUSE per RFC 5061.
The issue was found by ZeroHive, a vulnerability hunting agent at Tencent Yunding Lab.
--- net/sctp/sm_make_chunk.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/sctp/sm_make_chunk.c +6 -8
@@ -3230,6 +3230,9 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, *errp = param.p;switch (param.p->type) {case SCTP_PARAM_ERR_CAUSE : +if (length <sizeof (struct sctp_addip_param ) + +sizeof (struct sctp_errhdr )) +return false;break ;case SCTP_PARAM_IPV4_ADDRESS :if (length !=sizeof (struct sctp_ipv4addr_param ))
@@ -3463,20 +3466,15 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,case SCTP_PARAM_ERR_CAUSE : length =sizeof (*asconf_ack_param); err_param = (void *)asconf_ack_param + length; - asconf_ack_len -= length; -if (asconf_ack_len >0 ) -return err_param->cause; -else -return SCTP_ERROR_INV_PARAM ; -break ; +return err_param->cause;default :return SCTP_ERROR_INV_PARAM ; } } length =ntohs (asconf_ack_param->param_hdr.length); - asconf_ack_param = (void *)asconf_ack_param + length; - asconf_ack_len -= length; + asconf_ack_param = (void *)asconf_ack_param +SCTP_PAD4 (length); + asconf_ack_len -=SCTP_PAD4 (length); }return err_code;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1193 raw: annotate disconnect-side IPv4 match writers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
[ Upstream commit ac08d183dac0441e41f77bbad50798fe609d90f1 ]
raw_v4_match() reads inet_daddr, inet_rcv_saddr and sk_bound_dev_if locklessly under RCU. Bind and connect writers are annotated, but __udp_disconnect() still clears the same fields using plain stores.
Commit 18f116931f52e ("raw: annotate lockless match fields in raw_v4_match()") added the lockless readers and annotated the raw bind and datagram connect writers. Its v4 revision intentionally left the shared disconnect-side IPv4 writers for follow-up cleanup.
Complete that follow-up by using WRITE_ONCE() for the disconnect-side stores, including the inet_rcv_saddr reset in inet_reset_saddr(), to pair with the lockless raw socket matcher.
--- include/net/ip.h | 3 ++- net/ipv4/udp.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
include/net/ip.h +2 -1
@@ -660,7 +660,8 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast,static __inline__void inet_reset_saddr (struct sock *sk) { -inet_sk (sk)->inet_rcv_saddr =inet_sk (sk)->inet_saddr =0 ; +inet_sk (sk)->inet_saddr =0 ; +WRITE_ONCE (inet_sk (sk)->inet_rcv_saddr,0 );#if IS_ENABLED (CONFIG_IPV6 )if (sk->sk_family ==PF_INET6 ) {struct ipv6_pinfo *np =inet6_sk (sk);
net/ipv4/udp.c +2 -2
@@ -1948,10 +1948,10 @@ int __udp_disconnect(struct sock *sk, int flags)*/ sk->sk_state =TCP_CLOSE ; - inet->inet_daddr =0 ; +WRITE_ONCE (inet->inet_daddr,0 ); inet->inet_dport =0 ;sock_rps_reset_rxhash (sk); - sk->sk_bound_dev_if =0 ; +WRITE_ONCE (sk->sk_bound_dev_if,0 );if (!(sk->sk_userlocks &SOCK_BINDADDR_LOCK )) {inet_reset_saddr (sk); if (sk->sk_prot->rehash &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1193 net: amd-xgbe: discard rx packets with bad FCS
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Nugraha <[email protected]>
[ Upstream commit ac8d6b28d48c5d951dcd923d33e461588e762a6d ]
amd-xgbe driver currently sets the MAC_RCR.DCRCC bit whenever RX is enabled. This disables hardware FCS validation, causing packets with bad FCS to be accepted unconditionally.
This change unsets DCRCC so that packets with bad FCS will be dropped, in-line with typical behaviours of many other network controllers.
Tests:
- Verified that packets with bad FCS are now dropped.
- Verified that receiving packets with bad FCS will increment the rx_crc_errors counter.
--- drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-dev.c +1 -2
@@ -3438,7 +3438,7 @@ static void xgbe_enable_rx(struct xgbe_prv_data *pdata)XGMAC_IOWRITE (pdata,MAC_RQC0R , reg_val);/* Enable MAC Rx */ -XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,DCRCC ,1 ); +XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,DCRCC ,0 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,CST ,1 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,ACS ,1 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,RE ,1 );
@@ -3449,7 +3449,6 @@ static void xgbe_disable_rx(struct xgbe_prv_data *pdata)unsigned int i;/* Disable MAC Rx */ -XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,DCRCC ,0 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,CST ,0 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,ACS ,0 );XGMAC_IOWRITE_BITS (pdata,MAC_RCR ,RE ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1193 vxlan: mdb: Fix use-after-free in vxlan_mdb_remote_src_del()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baul Lee <[email protected]>
[ Upstream commit 4aa61c88b4e292e10abdfd791334b8272108d68a ]
vxlan_mdb_is_valid_source(), which validates MDBE_ATTR_SOURCE and every MDBE_ATTR_SRC_LIST member, accepts the all-zeros address.
A source list is only accepted on a (*, G) entry, whose source is the all-zeros address, and for each member of the list an (S, G) entry is derived from it by substituting the source. Entries are keyed by a plain memcmp() of struct vxlan_mdb_entry_key, so if MDBE_ATTR_SOURCE is present and holds the all-zeros address and the source list holds it as well, the derived (S, G) key is byte-identical to the (*, G) key and resolves to the same entry. Omitting MDBE_ATTR_SOURCE is not equivalent, as the key is then left with a zero address family.
vxlan_mdb_remote_src_del() removes the forwarding entry of a source before freeing the source entry:
vxlan_mdb_remote_src_fwd_del(vxlan, group, remote, &ent->addr); vxlan_mdb_remote_src_entry_del(ent);
With the keys aliased, the first call deletes the remote of the entry that owns 'ent' instead of a separate (S, G) entry, and frees 'ent'. The second call then runs on the freed entry, and its hlist_del() reads ->pprev and ->next out of it and writes through them.
Adding the (*, G) entry with NLM_F_REPLACE and no source list marks the all-zeros source for deletion and reaches this from the sweep at the end of vxlan_mdb_remote_srcs_replace().
BUG: KASAN: slab-use-after-free in __vxlan_mdb_add+0x1cd/0xd70 Read of size 8 at addr ffff888102852500 by task poc/84 __vxlan_mdb_add+0x1cd/0xd70 vxlan_mdb_add+0xc0/0x140 rtnl_mdb_add+0x157/0x2a0 rtnetlink_rcv_msg+0x207/0x5a0 Allocated by task 84: __kmalloc_cache_noprof+0x153/0x360 vxlan_mdb_remote_srcs_add+0x2eb/0x440 __vxlan_mdb_add+0x803/0xd70 Freed by task 84: kfree+0x14c/0x3b0 vxlan_mdb_remote_del+0x129/0x1a0 __vxlan_mdb_del+0x4f/0xe0 vxlan_mdb_remote_src_fwd_del.isra.0+0x162/0x1b0 __vxlan_mdb_add+0x1c5/0xd70
The MDB operations are netns-scoped, so an unprivileged user can perform them in a new user and network namespace.
Reject the all-zeros address in vxlan_mdb_is_valid_source(), which covers both call sites. A (*, G) entry is expressed by omitting the source, so nothing legitimate is refused.
Discovered by XBOW, triaged by Baul Lee <[email protected]>
--- drivers/net/vxlan/vxlan_mdb.c | 8 ++++++++ tools/testing/selftests/net/test_vxlan_mdb.sh | 6 ++++++ 2 files changed, 14 insertions(+)
drivers/net/vxlan/vxlan_mdb.c +8 -0
@@ -354,6 +354,10 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto,NL_SET_ERR_MSG_MOD (extack,"IPv4 multicast source address is not allowed" );return false; } +if (ipv4_is_zeronet (nla_get_in_addr (attr))) { +NL_SET_ERR_MSG_MOD (extack,"IPv4 all-zeros source address is not allowed" ); +return false; + }break ;#if IS_ENABLED (CONFIG_IPV6 )case htons (ETH_P_IPV6 ): {
@@ -368,6 +372,10 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto,NL_SET_ERR_MSG_MOD (extack,"IPv6 multicast source address is not allowed" ); return false; } +if (ipv6_addr_any (&src)) { +NL_SET_ERR_MSG_MOD (extack,"IPv6 all-zeros source address is not allowed" ); +return false; + }break ; }#endif
tools/testing/selftests/net/test_vxlan_mdb.sh +6 -0
@@ -688,6 +688,9 @@ star_g_common() run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $grp dst $vtep_ip src_vni 10010" log_test $? 255 "Invalid source in source list" + run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $all_zeros_grp dst $vtep_ip src_vni 10010" + log_test $? 255 "All-zeros source in source list" + run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent source_list $src1 dst $vtep_ip src_vni 10010" log_test $? 255 "Source list without filter mode" }
@@ -787,6 +790,9 @@ sg_common() run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $grp permanent dst $vtep_ip src_vni 10010" log_test $? 255 "(S, G) with an invalid source list" + run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $all_zeros_grp permanent dst $vtep_ip src_vni 10010" + log_test $? 255 "(S, G) with an all-zeros source" + run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp src $src permanent dst $vtep_ip src_vni 10010" log_test $? 255 "All-zeros group with source" }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1193 watchdog: msc313e: Fix NULL pointer dereference in PM callbacks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
[ Upstream commit e3eceb76515910746e6268c4e4ac1c07516ebd7b ]
msc313e_wdt_probe() doesn't set the driver data for the platform device. As a result, dev_get_drvdata() in msc313e_wdt_suspend() and msc313e_wdt_resume() will return NULL, leading to a NULL pointer dereference afterward.
Set the platform device driver data in msc313e_wdt_probe().
--- drivers/watchdog/msc313e_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/msc313e_wdt.c +1 -0
@@ -125,6 +125,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev)set_bit (WDOG_HW_RUNNING , &priv->wdev.status);watchdog_set_drvdata (&priv->wdev, priv); +platform_set_drvdata (pdev, priv);watchdog_init_timeout (&priv->wdev, timeout, dev);watchdog_stop_on_reboot (&priv->wdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1193 OPP: of: Fix potential multiplication overflow when calculating freq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit e11811a552252740bd396ec38378e9570ee16578 ]
The multiplication be32_to_cpup(val++) * 1000 is performed using 32 bit unsigned integers and hence uses a 32 bit multiplication; this will overflow if be32_to_cpup(val++) is greater than 4294967 (which is very unlikely at present). The result is assigned to an unsigned long (which is a 64 bit value on 64 bit systems), so fix this potential overflow by casting the first operand of the multiplication to an unsigned int.
--- drivers/opp/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +1 -1
@@ -1080,7 +1080,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) val = prop->value;while (nr) { -unsigned long freq =be32_to_cpup (val++) *1000 ; +unsigned long freq = (unsigned long )be32_to_cpup (val++) *1000 ;unsigned long volt =be32_to_cpup (val++); ret =_opp_add_v1 (opp_table, dev, freq, volt, false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1193 ALSA: pcm: Serialize PCM mmap with buffer reallocation to fix page UAF
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yilin Zhang <[email protected]>
[ Upstream commit 9b110a9dcecc59516c77cb3c0caf1f492f75df2d ]
snd_pcm_hw_params() and snd_pcm_hw_free() guard buffer reallocation with an mmap_count check performed under the PCM stream lock, but the lock is released long before the buffer is actually freed:snd_pcm_sync_stop(), constraint refinement and do_free_pages() all happen in between. snd_pcm_mmap_data(), on the other hand, takes no lock at all: it validates against the old buffer's state and dma_bytes, remaps its pages into the VMA, and only then increments mmap_count.
A concurrent mmap() can therefore slip in between the check and the free. remap_pfn_range() installs writable PTEs for the old buffer's pages without taking page references, and the subsequent do_free_pages() returns those pages to the page allocator while the VMA still maps them. This leaves a stale, writable mapping of freed
pages: a page-level use-after-free that can be leveraged for local privilege escalation.
Make snd_pcm_mmap_data() participate in the buffer-access scheme introduced for hw_params/hw_free: acquire runtime->buffer_accessing before validating and remapping, and release it afterwards. Buffer reallocation already fails with -EBUSY while accessors are active, and the mmap side now fails with -EBUSY while a reallocation is in progress, so the validate/remap sequence and the check/free sequence can no longer interleave.
A reproducer that turns this race into a stale writable mapping of the freed DMA buffer pages is available on request.
--- sound/core/pcm_native.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
sound/core/pcm_native.c +25 -10
@@ -3939,20 +3939,33 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file,return -EINVAL ; } runtime = substream->runtime; -if (runtime->state ==SNDRV_PCM_STATE_OPEN ) -return -EBADFD ; -if (!(runtime->info &SNDRV_PCM_INFO_MMAP )) -return -ENXIO ; +/* don't race with buffer reallocation in hw_params/hw_free */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; +if (runtime->state ==SNDRV_PCM_STATE_OPEN ) { + err = -EBADFD ; + goto out; + } +if (!(runtime->info &SNDRV_PCM_INFO_MMAP )) { + err = -ENXIO ; + goto out; + }if (runtime->access ==SNDRV_PCM_ACCESS_RW_INTERLEAVED || - runtime->access ==SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ) -return -EINVAL ; + runtime->access ==SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ) { + err = -EINVAL ; + goto out; + } size = area->vm_end - area->vm_start; offset = area->vm_pgoff <<PAGE_SHIFT ; dma_bytes =PAGE_ALIGN (runtime->dma_bytes); -if ((size_t )size > dma_bytes) -return -EINVAL ; -if (offset > dma_bytes - size) -return -EINVAL ; +if ((size_t )size > dma_bytes) { + err = -EINVAL ; + goto out; + } +if (offset > dma_bytes - size) { + err = -EINVAL ; + goto out; + } area->vm_ops = &snd_pcm_vm_ops_data; area->vm_private_data = substream;
@@ -3962,6 +3975,8 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, err =snd_pcm_lib_default_mmap (substream, area);if (!err)atomic_inc (&substream->mmap_count); +out: +atomic_dec (&runtime->buffer_accessing);return err; }EXPORT_SYMBOL (snd_pcm_mmap_data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1193 ksmbd: rate limit unmapped SID errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit feca5e70fc963b088377b20879e8cd8237c2fd7d ]
A client can include many structurally valid but unmapped SIDs in a DACL. Logging every mapping failure lets one request generate hundreds of kernel error messages.
Rate limit the message to prevent an authenticated client from flooding the kernel log.
--- fs/smb/server/smbacl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/smbacl.c +2 -2
@@ -521,8 +521,8 @@ static void parse_dacl(struct mnt_idmap *idmap, temp_fattr.cf_uid =INVALID_UID ; ret =sid_to_id (idmap, &ppace[i]->sid,SIDOWNER , &temp_fattr);if (ret ||uid_eq (temp_fattr.cf_uid,INVALID_UID )) { -pr_err ("%s: Error %d mapping Owner SID to uid\n" , - __func__, ret); +pr_err_ratelimited ("%s: Error %d mapping Owner SID to uid\n" , + __func__, ret);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1193 s390/checksum: call instrument_read() instead of kasan_check_read()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 4ce69fcf17d067112f754414aa563e0cd74cc49d ]
Call instrument_read() from csum_partial() instead of kasan_check_read(). instrument_read() covers all memory access instrumentation methods.
Stable-dep-of: 7f918871112e ("s390/ipl: Fix NULL deref in kdump without re-IPL parm block")
--- arch/s390/include/asm/checksum.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/checksum.h +2 -2
@@ -12,7 +12,7 @@#ifndef _S390_CHECKSUM_H#define _S390_CHECKSUM_H -#include <linux/kasan-checks.h> +#include <linux/instrumented.h> #include <linux/in6.h> /*
@@ -34,7 +34,7 @@ static inline __wsum csum_partial(const void *buff, int len, __wsum sum) .odd = (unsigned long) len, }; -kasan_check_read (buff, len); +instrument_read (buff, len); asmvolatile ("0: cksm %[sum],%[rp]\n" " jo 0b\n"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1193 s390/checksum: provide and use cksm() inline assembly
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 3a74f44de2c901e1536d227d29257cae1a6ed18f ]
Convert those callers of csum_partial() to use the cksm instruction, which are either very early or in critical paths, like panic/dump, so they don't have to rely on a working kernel infrastructure, which will be introduced with a subsequent patch.
Stable-dep-of: 7f918871112e ("s390/ipl: Fix NULL deref in kdump without re-IPL parm block")
--- arch/s390/include/asm/checksum.h | 27 ++++++++++++++++----------- arch/s390/kernel/ipl.c | 3 +-- arch/s390/kernel/os_info.c | 6 +++--- 3 files changed, 20 insertions(+), 16 deletions(-)
arch/s390/include/asm/checksum.h +16 -11
@@ -15,6 +15,21 @@#include <linux/instrumented.h> #include <linux/in6.h> +static inline __wsum cksm (const void *buff,int len,__wsum sum) +{ +union register_pair rp = { + .even = (unsigned long )buff, + .odd = (unsigned long )len, + }; + +instrument_read (buff, len); + asmvolatile ("\n" +"0: cksm %[sum],%[rp]\n" +" jo 0b\n" + : [sum]"+&d" (sum), [rp]"+&d" (rp.pair) : :"cc" ,"memory" ); +return sum; +} +/* * Computes the checksum of a memory block at buff, length len, * and adds in "sum" (32-bit).
@@ -29,17 +44,7 @@*/ static inline __wsum csum_partial (const void *buff,int len,__wsum sum) { -union register_pair rp = { - .even = (unsigned long ) buff, - .odd = (unsigned long ) len, - }; - -instrument_read (buff, len); - asmvolatile ( -"0: cksm %[sum],%[rp]\n" -" jo 0b\n" - : [sum]"+&d" (sum), [rp]"+&d" (rp.pair) : :"cc" ,"memory" ); -return sum; +return cksm (buff, len, sum); }/*
arch/s390/kernel/ipl.c +1 -2
@@ -1965,8 +1965,7 @@ static void dump_reipl_run(struct shutdown_trigger *trigger) reipl_type == IPL_TYPE_UNKNOWN) os_info_flags |=OS_INFO_FLAG_REIPL_CLEAR ;os_info_entry_add (OS_INFO_FLAGS_ENTRY , &os_info_flags,sizeof (os_info_flags)); - csum = (__force unsigned int ) -csum_partial (reipl_block_actual, reipl_block_actual->hdr.len,0 ); + csum = (__force unsigned int )cksm (reipl_block_actual, reipl_block_actual->hdr.len,0 ); abs_lc =get_abs_lowcore (); abs_lc->ipib =__pa (reipl_block_actual); abs_lc->ipib_checksum = csum;
arch/s390/kernel/os_info.c +3 -3
@@ -29,7 +29,7 @@ static struct os_info os_info __page_aligned_data;u32 os_info_csum (struct os_info *os_info) {int size =sizeof (*os_info) - offsetof(struct os_info , version_major); -return (__force u32 )csum_partial (&os_info->version_major, size,0 ); +return (__force u32 )cksm (&os_info->version_major, size,0 ); }/*
@@ -49,7 +49,7 @@ void os_info_entry_add(int nr, void *ptr, u64 size) { os_info.entry[nr].addr =__pa (ptr); os_info.entry[nr].size = size; - os_info.entry[nr].csum = (__force u32 )csum_partial (ptr, size,0 ); + os_info.entry[nr].csum = (__force u32 )cksm (ptr, size,0 ); os_info.csum =os_info_csum (&os_info); }
@@ -98,7 +98,7 @@ static void os_info_old_alloc(int nr, int align) msg ="copy failed" ; goto fail_free; } - csum = (__force u32 )csum_partial (buf_align, size,0 ); + csum = (__force u32 )cksm (buf_align, size,0 );if (csum != os_info_old->entry[nr].csum) { msg ="checksum failed" ; goto fail_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1193 s390/os_info: Introduce value entries
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Gordeev <[email protected]>
[ Upstream commit 88702793c5b4ef127a1f57d76920a80f70d081a7 ]
Introduce entries that do not reference any data in memory, but rather provide values. Set the size of such entries to zero and do not compute checksum for them, since there is no data which integrity needs to be checked. The integrity of the value entries itself is still covered by the os_info checksum.
Reserve the lowest unused entry index OS_INFO_RESERVED for future use - presumably for the number of entries present. That could later be used by user level tools. The existing tools would not notice any difference.
Stable-dep-of: 7f918871112e ("s390/ipl: Fix NULL deref in kdump without re-IPL parm block")
--- arch/s390/include/asm/os_info.h | 19 +++++++++++++++---- arch/s390/kernel/ipl.c | 6 +++--- arch/s390/kernel/os_info.c | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-)
arch/s390/include/asm/os_info.h +15 -4
@@ -17,11 +17,15 @@#define OS_INFO_VMCOREINFO 0#define OS_INFO_REIPL_BLOCK 1#define OS_INFO_FLAGS_ENTRY 2 +#define OS_INFO_RESERVED 3#define OS_INFO_FLAG_REIPL_CLEAR (1UL << 0)struct os_info_entry { -u64 addr; +union { +u64 addr; +u64 val; + };u64 size;u32 csum; } __packed;
@@ -33,17 +37,24 @@ struct os_info {u16 version_minor;u64 crashkernel_addr;u64 crashkernel_size; -struct os_info_entry entry[3 ]; -u8 reserved[4004 ]; +struct os_info_entry entry[4 ]; +u8 reserved[3984 ]; } __packed;void os_info_init (void ); -void os_info_entry_add (int nr,void *ptr,u64 len); +void os_info_entry_add_data (int nr,void *ptr,u64 len); +void os_info_entry_add_val (int nr,u64 val);void os_info_crashkernel_add (unsigned long base,unsigned long size);u32 os_info_csum (struct os_info *os_info);#ifdef CONFIG_CRASH_DUMP void *os_info_old_entry (int nr,unsigned long *size); +static inline unsigned long os_info_old_value (int nr) +{ +unsigned long size; + +return (unsigned long )os_info_old_entry (nr, &size); +}#else static inline void *os_info_old_entry (int nr,unsigned long *size) {
arch/s390/kernel/ipl.c +3 -3
@@ -1230,8 +1230,8 @@ static struct attribute_group reipl_nss_attr_group = {void set_os_info_reipl_block (void ) { -os_info_entry_add (OS_INFO_REIPL_BLOCK , reipl_block_actual, - reipl_block_actual->hdr.len); +os_info_entry_add_data (OS_INFO_REIPL_BLOCK , reipl_block_actual, + reipl_block_actual->hdr.len); }/* reipl type */
@@ -1964,7 +1964,7 @@ static void dump_reipl_run(struct shutdown_trigger *trigger) reipl_type == IPL_TYPE_NSS || reipl_type == IPL_TYPE_UNKNOWN) os_info_flags |=OS_INFO_FLAG_REIPL_CLEAR ; -os_info_entry_add (OS_INFO_FLAGS_ENTRY , &os_info_flags,sizeof (os_info_flags)); +os_info_entry_add_data (OS_INFO_FLAGS_ENTRY , &os_info_flags,sizeof (os_info_flags)); csum = (__force unsigned int )cksm (reipl_block_actual, reipl_block_actual->hdr.len,0 ); abs_lc =get_abs_lowcore (); abs_lc->ipib =__pa (reipl_block_actual);
arch/s390/kernel/os_info.c +13 -2
@@ -43,9 +43,9 @@ void os_info_crashkernel_add(unsigned long base, unsigned long size) }/* -* Add OS info entry and update checksum +* Add OS info data entry and update checksum */ -void os_info_entry_add (int nr,void *ptr,u64 size) +void os_info_entry_add_data (int nr,void *ptr,u64 size) { os_info.entry[nr].addr =__pa (ptr); os_info.entry[nr].size = size;
@@ -53,6 +53,17 @@ void os_info_entry_add(int nr, void *ptr, u64 size) os_info.csum =os_info_csum (&os_info); } +/* +* Add OS info value entry and update checksum +*/ +void os_info_entry_add_val (int nr,u64 value) +{ + os_info.entry[nr].val = value; + os_info.entry[nr].size =0 ; + os_info.entry[nr].csum =0 ; + os_info.csum =os_info_csum (&os_info); +} +/* * Initialize OS info structure and set lowcore pointer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1193 s390/ipl: Fix NULL deref in kdump without re-IPL parm block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
[ Upstream commit 7f918871112e8e7c581e99eb8e545af4e59c8367 ]
Some IPL types, like HMC FTP boot or QEMU direct kernel boot, might not provide an IPL parameter block. In this case, reipl_type_init() selects IPL_TYPE_UNKNOWN, and reipl_block_actual remains NULL.
kdump passes the re-IPL parameter block to the dump kernel through os_info. Before commit 3b9678472bab ("s390/ipl: correct kdump reipl block checksum calculation"), the os_info entry was added only for IPL types which initialized reipl_block_actual. That commit moved the os_info update to machine_crash_shutdown(), making it unconditional. As a result, set_os_info_reipl_block() dereferences reipl_block_actual for IPL_TYPE_UNKNOWN. This may happen to work by chance when address zero contains readable lowcore data and the resulting empty os_info entry is ignored by the dump kernel.
Skip the os_info update when no re-IPL parameter block is available. Kdump then collect the dump and reboot without setting re-IPL parameter block.
--- arch/s390/kernel/ipl.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/kernel/ipl.c +2 -0
@@ -1230,6 +1230,8 @@ static struct attribute_group reipl_nss_attr_group = {void set_os_info_reipl_block (void ) { +if (!reipl_block_actual) +return ;os_info_entry_add_data (OS_INFO_REIPL_BLOCK , reipl_block_actual, reipl_block_actual->hdr.len); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1193 s390/ipl: Fix NULL deref in dump_reipl without re-IPL parm block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
[ Upstream commit 37f61b71cbc0caefc01022a19ee56fc2510e2e6e ]
Unlike kdump, which passes the re-IPL parameter block through os_info, the stand-alone dump passes it through the IPL parm block address and checksum in lowcore.
Some IPL types, like HMC FTP boot or QEMU direct kernel boot, might not provide an IPL parameter block. In this case reipl_type_init() selects IPL_TYPE_UNKNOWN and reipl_block_actual remains NULL. Nevertheless, dump_reipl_run() unconditionally dereferences it when preparing the lowcore fields. This may happen to work by chance when address zero contains readable lowcore data. A zero IPL parameter block address is then stored in lowcore, causing the stand-alone dumper to enter disabled wait after completing the dump.
Explicitly store a zero IPL parameter block address and checksum when no re-IPL parameter block is available. This does not change the behavior:
the stand-alone dumper completes the dump and halts, while valid re-IPL parameter blocks continue to be handled as before.
--- arch/s390/kernel/ipl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/s390/kernel/ipl.c +7 -3
@@ -1951,7 +1951,8 @@ static struct shutdown_action __refdata dump_action = {static void dump_reipl_run (struct shutdown_trigger *trigger) {struct lowcore *abs_lc; -unsigned int csum; +unsigned long ipib =0 ; +unsigned int csum =0 ;/* * Set REIPL_CLEAR flag in os_info flags entry indicating
@@ -1967,9 +1968,12 @@ static void dump_reipl_run(struct shutdown_trigger *trigger) reipl_type == IPL_TYPE_UNKNOWN) os_info_flags |=OS_INFO_FLAG_REIPL_CLEAR ;os_info_entry_add_data (OS_INFO_FLAGS_ENTRY , &os_info_flags,sizeof (os_info_flags)); - csum = (__force unsigned int )cksm (reipl_block_actual, reipl_block_actual->hdr.len,0 ); +if (reipl_block_actual) { + ipib =__pa (reipl_block_actual); + csum = (__force unsigned int )cksm (reipl_block_actual, reipl_block_actual->hdr.len,0 ); + } abs_lc =get_abs_lowcore (); - abs_lc->ipib =__pa (reipl_block_actual); + abs_lc->ipib = ipib; abs_lc->ipib_checksum = csum;put_abs_lowcore (abs_lc);dump_run (trigger);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1193 workqueue: replace use of system_wq with system_percpu_wq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Crivellari <[email protected]>
[ Upstream commit a2be943b46b4a7478ea8ddf9bb8e5251c59fceb7 ]
Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND.
This lack of consistentcy cannot be addressed without refactoring the API.
system_wq is a per-CPU worqueue, yet nothing in its name tells about that CPU affinity constraint, which is very often not required by users. Make it clear by adding a system_percpu_wq.
queue_work() / queue_delayed_work() mod_delayed_work() will now use the new per-cpu wq: whether the user still stick on the old name a warn will be printed along a wq redirect to the new one.
This patch add the new system_percpu_wq except for mm, fs and net subsystem, whom are handled in separated patches.
The old wq will be kept for a few release cylces.
Stable-dep-of: 068c35b5d054 ("workqueue: reject watchdog thresholds that overflow jiffies")
--- include/linux/workqueue.h | 22 +++++++++++----------- kernel/workqueue.c | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-)
include/linux/workqueue.h +11 -11
@@ -415,10 +415,10 @@ enum {* short queue flush time. Don't queue works which can run for too * long. * -* system_highpri_wq is similar to system_wq but for work items which +* system_highpri_wq is similar to system_percpu_wq but for work items which * require WQ_HIGHPRI. * -* system_long_wq is similar to system_wq but may host long running +* system_long_wq is similar to system_percpu_wq but may host long running * works. Queue flushing might take relatively long. * * system_dfl_wq is unbound workqueue. Workers are not bound to
@@ -426,13 +426,13 @@ enum {* executed immediately as long as max_active limit is not reached and * resources are available. * -* system_freezable_wq is equivalent to system_wq except that it's +* system_freezable_wq is equivalent to system_percpu_wq except that it's * freezable. * * *_power_efficient_wq are inclined towards saving power and converted * into WQ_UNBOUND variants if 'wq_power_efficient' is enabled; otherwise, * they are same as their non-power-efficient counterparts - e.g. -* system_power_efficient_wq is identical to system_wq if +* system_power_efficient_wq is identical to system_percpu_wq if * 'wq_power_efficient' is disabled. See WQ_POWER_EFFICIENT for more info. */ extern struct workqueue_struct *system_wq;/* use system_percpu_wq, this will be removed */
@@ -603,7 +603,7 @@ static inline bool mod_delayed_work(struct workqueue_struct *wq,*/ static inline bool schedule_work_on (int cpu,struct work_struct *work) { -return queue_work_on (cpu, system_wq, work); +return queue_work_on (cpu, system_percpu_wq, work); }/**
@@ -622,7 +622,7 @@ static inline bool schedule_work_on(int cpu, struct work_struct *work)*/ static inline bool schedule_work (struct work_struct *work) { -return queue_work (system_wq, work); +return queue_work (system_percpu_wq, work); }/*
@@ -639,15 +639,15 @@ extern void __warn_flushing_systemwide_wq(void)#define flush_scheduled_work () \ ({ \ __warn_flushing_systemwide_wq(); \ - __flush_workqueue(system_wq); \ + __flush_workqueue(system_percpu_wq); \ })#define flush_workqueue (wq) \ ({ \ struct workqueue_struct *_wq = (wq); \ \ - if ((__builtin_constant_p(_wq == system_wq) && \ - _wq == system_wq) || \ + if ((__builtin_constant_p(_wq == system_percpu_wq) && \ + _wq == system_percpu_wq) || \ (__builtin_constant_p(_wq == system_highpri_wq) && \ _wq == system_highpri_wq) || \ (__builtin_constant_p(_wq == system_long_wq) && \
@@ -676,7 +676,7 @@ extern void __warn_flushing_systemwide_wq(void)static inline bool schedule_delayed_work_on (int cpu,struct delayed_work *dwork,unsigned long delay) { -return queue_delayed_work_on (cpu, system_wq, dwork, delay); +return queue_delayed_work_on (cpu, system_percpu_wq, dwork, delay); }/**
@@ -690,7 +690,7 @@ static inline bool schedule_delayed_work_on(int cpu, struct delayed_work *dwork,static inline bool schedule_delayed_work (struct delayed_work *dwork,unsigned long delay) { -return queue_delayed_work (system_wq, dwork, delay); +return queue_delayed_work (system_percpu_wq, dwork, delay); }#ifndef CONFIG_SMP
kernel/workqueue.c +1 -1
@@ -6574,7 +6574,7 @@ static int wq_watchdog_param_set_thresh(const char *val,if (ret)return ret; -if (system_wq) +if (system_percpu_wq)wq_watchdog_set_thresh (thresh);else wq_watchdog_thresh = thresh;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1193 workqueue: reject watchdog thresholds that overflow jiffies
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiacheng Xu <[email protected]>
[ Upstream commit 068c35b5d0546c8625b3d7c61910f73775cf1216 ]
The watchdog threshold is supplied in seconds but is multiplied by HZ before being used as a jiffies interval. Reject values that exceed MAX_JIFFY_OFFSET / HZ so the multiplication cannot wrap and the time_after() comparisons remain within their supported range.
The check is performed before changing the threshold or watchdog timer. Zero remains the value used to disable the watchdog.
--- kernel/workqueue.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/workqueue.c +3 -0
@@ -6574,6 +6574,9 @@ static int wq_watchdog_param_set_thresh(const char *val,if (ret)return ret; +if (thresh >MAX_JIFFY_OFFSET /HZ ) +return -ERANGE ; +if (system_percpu_wq)wq_watchdog_set_thresh (thresh);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1193 Bluetooth: btintel: Print firmware SHA1
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit a2e7707bba21b373c7b429ad7f9030d63dfb4542 ]
Intel Read Version event contains a TLV(0x32) having firmware sha1 in operational image.
Stable-dep-of: a086c0892969 ("Bluetooth: btintel: validate version TLV value lengths")
--- drivers/bluetooth/btintel.c | 5 +++++ drivers/bluetooth/btintel.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/bluetooth/btintel.c +5 -0
@@ -530,6 +530,8 @@ static int btintel_version_info_tlv(struct hci_dev *hdev,bt_dev_info (hdev,"%s timestamp %u.%u buildtype %u build %u" , variant,2000 + (version->timestamp >>8 ), version->timestamp &0xff , version->build_type, version->build_num); +if (version->img_type ==0x03 ) +bt_dev_info (hdev,"Firmware SHA1: 0x%8.8x" , version->git_sha1);return 0 ; }
@@ -625,6 +627,9 @@ static int btintel_parse_version_tlv(struct hci_dev *hdev,memcpy (&version->otp_bd_addr, tlv->val,sizeof (bdaddr_t));break ; +case INTEL_TLV_GIT_SHA1 : + version->git_sha1 =get_unaligned_le32 (tlv->val); +break ;default :/* Ignore rest of information */ break ;
drivers/bluetooth/btintel.h +3 -1
@@ -41,7 +41,8 @@ enum {INTEL_TLV_LIMITED_CCE ,INTEL_TLV_SBE_TYPE ,INTEL_TLV_OTP_BDADDR , -INTEL_TLV_UNLOCKED_STATE +INTEL_TLV_UNLOCKED_STATE , +INTEL_TLV_GIT_SHA1 }; struct intel_tlv {
@@ -69,6 +70,7 @@ struct intel_version_tlv {u8 min_fw_build_yy;u8 limited_cce;u8 sbe_type; +u32 git_sha1;bdaddr_t otp_bd_addr; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1193 Bluetooth: btintel: Export few static functions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit 67d4dbac3b8c48ada784ae923f7cd68dfac509ec ]
Some of the functions used in btintel.c is made global so that they can be reused in other transport drivers apart from USB.
Stable-dep-of: a086c0892969 ("Bluetooth: btintel: validate version TLV value lengths")
--- drivers/bluetooth/btintel.c | 26 +++++++++++++--------- drivers/bluetooth/btintel.h | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 10 deletions(-)
drivers/bluetooth/btintel.c +16 -10
@@ -235,7 +235,7 @@ static int btintel_set_diag_combined(struct hci_dev *hdev, bool enable)return ret; } -static void btintel_hw_error (struct hci_dev *hdev,u8 code) +void btintel_hw_error (struct hci_dev *hdev,u8 code) {struct sk_buff *skb;u8 type =0x00 ;
@@ -272,6 +272,7 @@ static void btintel_hw_error(struct hci_dev *hdev, u8 code) unlock:hci_req_sync_unlock (hdev); } +EXPORT_SYMBOL_GPL (btintel_hw_error);int btintel_version_info (struct hci_dev *hdev,struct intel_version *ver) {
@@ -450,8 +451,8 @@ int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver) }EXPORT_SYMBOL_GPL (btintel_read_version); -static int btintel_version_info_tlv (struct hci_dev *hdev, -struct intel_version_tlv *version) +int btintel_version_info_tlv (struct hci_dev *hdev, +struct intel_version_tlv *version) {const char *variant;
@@ -535,10 +536,11 @@ static int btintel_version_info_tlv(struct hci_dev *hdev,return 0 ; } +EXPORT_SYMBOL_GPL (btintel_version_info_tlv); -static int btintel_parse_version_tlv (struct hci_dev *hdev, -struct intel_version_tlv *version, -struct sk_buff *skb) +int btintel_parse_version_tlv (struct hci_dev *hdev, +struct intel_version_tlv *version, +struct sk_buff *skb) {/* Consume Command Complete Status field */ skb_pull (skb,1 );
@@ -640,6 +642,7 @@ static int btintel_parse_version_tlv(struct hci_dev *hdev,return 0 ; } +EXPORT_SYMBOL_GPL (btintel_parse_version_tlv);static int btintel_read_version_tlv (struct hci_dev *hdev,struct intel_version_tlv *version)
@@ -2531,8 +2534,8 @@ static void btintel_set_dsm_reset_method(struct hci_dev *hdev, data->acpi_reset_method = btintel_acpi_reset_method; } -static int btintel_bootloader_setup_tlv (struct hci_dev *hdev, -struct intel_version_tlv *ver) +int btintel_bootloader_setup_tlv (struct hci_dev *hdev, +struct intel_version_tlv *ver) {u32 boot_param;char ddcname[64 ];
@@ -2599,8 +2602,9 @@ static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,return 0 ; } +EXPORT_SYMBOL_GPL (btintel_bootloader_setup_tlv); -static void btintel_set_msft_opcode (struct hci_dev *hdev,u8 hw_variant) +void btintel_set_msft_opcode (struct hci_dev *hdev,u8 hw_variant) {switch (hw_variant) {/* Legacy bootloader devices that supports MSFT Extension */
@@ -2623,6 +2627,7 @@ static void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant)break ; } } +EXPORT_SYMBOL_GPL (btintel_set_msft_opcode);static int btintel_setup_combined (struct hci_dev *hdev) {
@@ -2873,7 +2878,7 @@ static int btintel_setup_combined(struct hci_dev *hdev)return err; } -static int btintel_shutdown_combined (struct hci_dev *hdev) +int btintel_shutdown_combined (struct hci_dev *hdev) {struct sk_buff *skb;int ret;
@@ -2907,6 +2912,7 @@ static int btintel_shutdown_combined(struct hci_dev *hdev)return 0 ; } +EXPORT_SYMBOL_GPL (btintel_shutdown_combined);int btintel_configure_setup (struct hci_dev *hdev,const char *driver_name) {
drivers/bluetooth/btintel.h +43 -0
53 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1193 Bluetooth: btintel: validate version TLV value lengths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laxman Acharya Padhya <[email protected]>
[ Upstream commit a086c0892969bf8a0151b0f12bd14a68827c88b2 ]
btintel_parse_version_tlv() verifies that a complete TLV is present in the response, but it does not ensure that the value is long enough for the specific TLV type. A short value can therefore cause an out-of-bounds read through get_unaligned_le16(), get_unaligned_le32(), or memcpy().
Reject values shorter than the minimum required by each known TLV type. Also reject responses that do not contain the Command Complete Status field.
--- drivers/bluetooth/btintel.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/bluetooth/btintel.c +36 -1
@@ -538,12 +538,44 @@ int btintel_version_info_tlv(struct hci_dev *hdev, }EXPORT_SYMBOL_GPL (btintel_version_info_tlv); +static u8 btintel_version_tlv_min_len (u8 type) +{ +switch (type) { +case INTEL_TLV_CNVI_TOP : +case INTEL_TLV_CNVR_TOP : +case INTEL_TLV_CNVI_BT : +case INTEL_TLV_CNVR_BT : +case INTEL_TLV_BUILD_NUM : +case INTEL_TLV_GIT_SHA1 : +return sizeof (u32); +case INTEL_TLV_DEV_REV_ID : +case INTEL_TLV_TIME_STAMP : +return sizeof (u16); +case INTEL_TLV_IMAGE_TYPE : +case INTEL_TLV_BUILD_TYPE : +case INTEL_TLV_SECURE_BOOT : +case INTEL_TLV_OTP_LOCK : +case INTEL_TLV_API_LOCK : +case INTEL_TLV_DEBUG_LOCK : +case INTEL_TLV_LIMITED_CCE : +case INTEL_TLV_SBE_TYPE : +return sizeof (u8); +case INTEL_TLV_MIN_FW : +return 3 ; +case INTEL_TLV_OTP_BDADDR : +return sizeof (bdaddr_t); +default : +return 0 ; + } +} +int btintel_parse_version_tlv (struct hci_dev *hdev,struct intel_version_tlv *version,struct sk_buff *skb) {/* Consume Command Complete Status field */ -skb_pull (skb,1 ); +if (!skb_pull (skb,1 )) +return -EINVAL ;/* Event parameters contatin multiple TLVs. Read each of them * and only keep the required data. Also, it use existing legacy
@@ -563,6 +595,9 @@ int btintel_parse_version_tlv(struct hci_dev *hdev,if (skb->len < tlv->len +sizeof (*tlv))return -EINVAL ; +if (tlv->len <btintel_version_tlv_min_len (tlv->type)) +return -EINVAL ; +switch (tlv->type) {case INTEL_TLV_CNVI_TOP : version->cnvi_top =get_unaligned_le32 (tlv->val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1193 Bluetooth: hci_core: Fix race condition during device registration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit 57938bbdb9bf7fd41cbd5cd509ec10c4b22bec18 ]
In hci_register_dev(), the power_on work item is queued to hdev->req_workqueue before initializing hdev->adv_monitors_idr and registering the MSFT extension via msft_register(). For devices marked with quirks such as HCI_QUIRK_RAW_DEVICE, the HCI_UNCONFIGURED flag is set on the device. When the power_on work item runs concurrently on another CPU, hci_power_on() detects that the device is unconfigured and immediately invokes hci_dev_do_close(), which calls msft_do_close().
Concurrently, msft_register() allocates the msft structure and exposes it to hdev->msft_data prior to calling mutex_init(&msft->filter_lock). If msft_do_close() executes while hdev->msft_data is already assigned but the mutex has not yet been initialized, mutex_lock(&msft->filter_lock) operates on an uninitialized mutex, triggering a DEBUG_LOCKS warning:
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
WARNING: kernel/locking/mutex.c:625 at __mutex_lock_common kernel/locking/mutex.c:625 [inline] WARNING: kernel/locking/mutex.c:625 at __mutex_lock+0x12d8/0x1550 kernel/locking/mutex.c:821 ... Call Trace: <TASK> msft_do_close+0x308/0x7b0 net/bluetooth/msft.c:693 hci_dev_close_sync+0x86b/0x10a0 net/bluetooth/hci_sync.c:5522 hci_dev_do_close net/bluetooth/hci_core.c:499 [inline] hci_power_on+0x32c/0x750 net/bluetooth/hci_core.c:937 process_one_work kernel/workqueue.c:3322 [inline] process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405 worker_thread+0x92d/0xe10 kernel/workqueue.c:3486 kthread+0x388/0x470 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
Fix this by moving the queue_work() call in hci_register_dev() to after idr_init(&hdev->adv_monitors_idr) and msft_register(hdev) so that device structures and extensions are fully initialized before asynchronous tasks can access them. Additionally, assign hdev->msft_data in msft_register() only after mutex_init(&msft->filter_lock) has completed.
--- net/bluetooth/hci_core.c | 4 ++-- net/bluetooth/msft.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/hci_core.c +2 -2
@@ -2662,11 +2662,11 @@ int hci_register_dev(struct hci_dev *hdev)if (error)BT_WARN ("register suspend notifier failed error:%d\n" , error); -queue_work (hdev->req_workqueue, &hdev->power_on); -idr_init (&hdev->adv_monitors_idr);msft_register (hdev); +queue_work (hdev->req_workqueue, &hdev->power_on); +return id; err_wqueue:
net/bluetooth/msft.c +1 -1
@@ -770,8 +770,8 @@ void msft_register(struct hci_dev *hdev)INIT_LIST_HEAD (&msft->handle_map);INIT_LIST_HEAD (&msft->address_filters); - hdev->msft_data = msft;mutex_init (&msft->filter_lock); + hdev->msft_data = msft; }void msft_release (struct hci_dev *hdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1193 Bluetooth: L2CAP: fix chan mode for LE_CONN_REQ + EXT_FLOWCTL pchan
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 4ef05db5b08b176a551b4a6287372045998806b0 ]
l2cap_new_connection() sets default value of channel mode to match the parent channel. l2cap_le_connect_req() left this at the default, and created L2CAP_MODE_EXT_FLOWCTL channels if listening pchan has that mode. This causes FLAG_DEFER_SETUP channels to reply to L2CAP_LE_CONN_REQ with L2CAP_ECRED_CONN_RSP, which is incorrect.
It can also result to stack OOB write (of l2cap_alloc_cid determined values) in l2cap_ecred_rsp_defer(), as l2cap_le_connect_req() does not limit maximum number of deferred channels or check for duplicate ident.
Fix by setting chan->mode correctly in l2cap_le_connect_req().
Also check channel mode in l2cap_ecred_rsp_defer(), and do WARN_ON_ONCE instead of OOB write to make it less brittle.
--- net/bluetooth/l2cap_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/l2cap_core.c +8 -0
@@ -3841,6 +3841,9 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data) {struct l2cap_ecred_rsp_data *rsp = data; +if (chan->mode !=L2CAP_MODE_EXT_FLOWCTL ) +return ; +/* Check if channel for outgoing connection or if it wasn't deferred * since in those cases it must be skipped. */
@@ -3851,6 +3854,10 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data)/* Reset ident so only one response is sent */ chan->ident =0 ; +/* Unreachable, check in l2cap_ecred_conn_req. If reached, drop rest */ +if (WARN_ON_ONCE (rsp->count >=ARRAY_SIZE (rsp->pdu.scid))) + rsp->pdu.rsp.result =cpu_to_le16 (L2CAP_CR_LE_NO_MEM ); +/* Include all channels pending with the same ident */ if (!rsp->pdu.rsp.result) rsp->pdu.rsp.dcid[rsp->count++] =cpu_to_le16 (chan->scid);
@@ -4995,6 +5002,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,__set_chan_timer (chan, chan->ops->get_sndtimeo (chan)); chan->ident = cmd->ident; + chan->mode =L2CAP_MODE_LE_FLOWCTL ;if (test_bit (FLAG_DEFER_SETUP , &chan->flags)) {l2cap_state_change (chan,BT_CONNECT2 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1193 Bluetooth: L2CAP: clear FLAG_DEFER_SETUP only for same PID/PSM
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 0d77683237270702fa93489ca759c89b4e970554 ]
l2cap_ecred_defer_connect() clears FLAG_DEFER_SETUP also for channels with different PID/PSM, which will not be added to the same ECRED_CONN_REQ in any case. Consequently, only one ECRED connection group can work at a time although it appears intended they would be separate for each PID/PSM combination.
Fix by clearing FLAG_DEFER_SETUP only for the connections that could be added in the request. Retain test_bit(FLAG_DEFER_SETUP) before calling get_peer_pid as it may be NULL otherwise.
--- net/bluetooth/l2cap_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +4 -1
@@ -1340,7 +1340,7 @@ static void l2cap_ecred_defer_connect(struct l2cap_chan *chan, void *data)if (chan == conn->chan)return ; -if (!test_and_clear_bit (FLAG_DEFER_SETUP , &chan->flags)) +if (!test_bit (FLAG_DEFER_SETUP , &chan->flags))return ; pid = chan->ops->get_peer_pid (chan);
@@ -1350,6 +1350,9 @@ static void l2cap_ecred_defer_connect(struct l2cap_chan *chan, void *data) chan->mode != L2CAP_MODE_EXT_FLOWCTL || chan->state != BT_CONNECT)return ; +if (!test_and_clear_bit (FLAG_DEFER_SETUP , &chan->flags)) +return ; +if (test_and_set_bit (FLAG_ECRED_CONN_REQ_SENT , &chan->flags))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1193 Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gongwei Li <[email protected]>
[ Upstream commit 2deb76c21b81e42b3282224f7dd2046fe73fd1e0 ]
wait_on_bit_timeout() returns 0 if the bit was cleared, -EINTR if the process received a signal and the mode permitted wake up on that signal, or -EAGAIN if the timeout elapsed. It never returns 1.
Hence the check "err == 1" in mrvl_load_firmware() is dead code: when the waiting task is interrupted by a signal (-EINTR), the code falls into the "else if (err)" branch and misreports it as "Firmware request timeout" with -ETIMEDOUT instead of propagating -EINTR.
Fix this by testing for -EINTR so that an interrupted firmware load is properly detected and reported.
--- drivers/bluetooth/hci_mrvl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/bluetooth/hci_mrvl.c +1 -2
@@ -307,9 +307,8 @@ static int mrvl_load_firmware(struct hci_dev *hdev, const char *name) err =wait_on_bit_timeout (&mrvl->flags,STATE_FW_REQ_PENDING ,TASK_INTERRUPTIBLE ,msecs_to_jiffies (2000 )); -if (err ==1 ) { +if (err == -EINTR ) {bt_dev_err (hdev,"Firmware load interrupted" ); - err = -EINTR ;break ; }else if (err) {bt_dev_err (hdev,"Firmware request timeout" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1193 ASoC: ab8500: Reset the audio block before configuring it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 8e839bca7793a0b03c005f4b2b0825464290d425 ]
ResetAudn is active low, but the codec probe only deasserts it. It also clears Clk32kOut2Dis despite claiming to disable that output, and writes codec registers before releasing reset.
Pulse ResetAudn before the first audio-bank access and leave the unused 32 kHz output disabled.
--- sound/soc/codecs/ab8500-codec.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
sound/soc/codecs/ab8500-codec.c +13 -13
@@ -1917,18 +1917,18 @@ enum ab8500_filter {static int ab8500_audio_init_audioblock (struct snd_soc_component *component) {int status; +u8 mask =AB8500_STW4500CTRL3_CLK32KOUT2DIS | +AB8500_STW4500CTRL3_RESETAUDN ;dev_dbg (component->dev,"%s: Enter.\n" , __func__); -/* Reset audio-registers and disable 32kHz-clock output 2 */ - status =ab8500_sysctrl_write (AB8500_STW4500CTRL3 , -AB8500_STW4500CTRL3_CLK32KOUT2DIS | -AB8500_STW4500CTRL3_RESETAUDN , -AB8500_STW4500CTRL3_RESETAUDN ); +/* Reset the audio registers and disable the unused 32 kHz output. */ + status =ab8500_sysctrl_write (AB8500_STW4500CTRL3 , mask, +AB8500_STW4500CTRL3_CLK32KOUT2DIS );if (status <0 )return status; -return 0 ; +return ab8500_sysctrl_write (AB8500_STW4500CTRL3 , mask, mask); } static int ab8500_audio_setup_mics(struct snd_soc_component *component,
@@ -2461,6 +2461,13 @@ static int ab8500_codec_probe(struct snd_soc_component *component)ab8500_codec_of_probe (dev, np, &codec_pdata); + status =ab8500_audio_init_audioblock (component); +if (status <0 ) { +dev_err (dev,"%s: failed to init audio-block (%d)!\n" , + __func__, status); +return status; + } + status =ab8500_audio_setup_mics (component, &codec_pdata.amics);if (status <0 ) {pr_err ("%s: Failed to setup mics (%d)!\n" , __func__, status);
@@ -2473,13 +2480,6 @@ static int ab8500_codec_probe(struct snd_soc_component *component)return status; } - status =ab8500_audio_init_audioblock (component); -if (status <0 ) { -dev_err (dev,"%s: failed to init audio-block (%d)!\n" , - __func__, status); -return status; - } -/* Override HW-defaults */ snd_soc_component_write (component,AB8500_ANACONF5 ,BIT (AB8500_ANACONF5_HSAUTOEN ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1193 ASoC: ab8500: Repair the DAPM capture graph
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 103fe1a37f040ef6ac9ed1cf33be786149d2bb15 ]
The capture stream routes point away from the stream widget. Digital microphone mux routes are unconditional and bypass their enable bits, and several widgets independently own shared AD path enable bits. The dummy ADC and DAC widgets hide the resulting power graph errors.
Connect each real AIF widget to the stream and main supply, use the mux item names on digital microphone routes, and model shared AD enables as supplies. Also make the ANC DAPM switch writable.
--- sound/soc/codecs/ab8500-codec.c | 120 +++++++++++++++----------------- 1 file changed, 56 insertions(+), 64 deletions(-)
sound/soc/codecs/ab8500-codec.c +56 -64
@@ -303,7 +303,7 @@ static const struct snd_kcontrol_new dapm_anc_in_select[] = {/* ANC - Enable/Disable */ static const struct snd_kcontrol_new dapm_anc_enable[] = {SOC_DAPM_SINGLE ("Switch" ,AB8500_ANCCONF1 , -AB8500_ANCCONF1_ENANC ,0 ,0 ), +AB8500_ANCCONF1_ENANC ,1 ,0 ), };/* ANC to Earpiece - Mute */
@@ -385,12 +385,6 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {/* DA/AD */ -SND_SOC_DAPM_INPUT ("ADC Input" ), -SND_SOC_DAPM_ADC ("ADC" ,"ab8500_0c" ,SND_SOC_NOPM ,0 ,0 ), - -SND_SOC_DAPM_DAC ("DAC" ,NULL ,SND_SOC_NOPM ,0 ,0 ), -SND_SOC_DAPM_OUTPUT ("DAC Output" ), -SND_SOC_DAPM_AIF_IN ("DA_IN1" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_AIF_IN ("DA_IN2" ,NULL ,0 ,SND_SOC_NOPM ,0 ,0 ), SND_SOC_DAPM_AIF_IN("DA_IN3", NULL, 0, SND_SOC_NOPM, 0, 0),
@@ -582,9 +576,8 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("AD3 Channel Volume" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ), -SND_SOC_DAPM_MIXER ("AD3 Enable" , -AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD34 ,0 , - NULL, 0), +SND_SOC_DAPM_SUPPLY ("AD34 Enable" ,AB8500_ADPATHENA , + AB8500_ADPATHENA_ENAD34, 0, NULL, 0),/* Mic 2 */
@@ -643,9 +636,8 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = { SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_MIXER ("AD12 Enable" , -AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD12 ,0 , - NULL, 0), +SND_SOC_DAPM_SUPPLY ("AD12 Enable" ,AB8500_ADPATHENA , + AB8500_ADPATHENA_ENAD12, 0, NULL, 0),/* HD Capture path */
@@ -659,12 +651,8 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("AD6 Channel Volume" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ), -SND_SOC_DAPM_MIXER ("AD57 Enable" , -AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD5768 ,0 , -NULL ,0 ), -SND_SOC_DAPM_MIXER ("AD68 Enable" , -AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD5768 ,0 , - NULL, 0), +SND_SOC_DAPM_SUPPLY ("AD5768 Enable" ,AB8500_ADPATHENA , + AB8500_ADPATHENA_ENAD5768, 0, NULL, 0),/* Digital Microphone path */
@@ -696,10 +684,6 @@ static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {SND_SOC_DAPM_MIXER ("AD4 Channel Volume" ,SND_SOC_NOPM ,0 ,0 ,NULL ,0 ), -SND_SOC_DAPM_MIXER ("AD4 Enable" , -AB8500_ADPATHENA ,AB8500_ADPATHENA_ENAD34 , -0 ,NULL ,0 ), -/* Acoustical Noise Cancellation path */ SND_SOC_DAPM_INPUT("ANC Configure Input"),
@@ -747,24 +731,17 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"Main Supply", NULL, "Audio Power"}, {"Main Supply", NULL, "Audio Analog Power"}, - {"DAC", NULL, "ab8500_0p"}, - {"DAC", NULL, "Main Supply"}, - {"ADC", NULL, "ab8500_0c"}, - {"ADC", NULL, "Main Supply"}, -/* ANC Configure */ {"ANC Configure Input", NULL, "Main Supply"}, {"ANC Configure Output", NULL, "ANC Configure Input"}, -/* AD/DA */ - {"ADC", NULL, "ADC Input"}, - {"DAC Output", NULL, "DAC"}, -/* Powerup charge pump if DA1/2 is in use */ {"DA_IN1", NULL, "ab8500_0p"}, + {"DA_IN1", NULL, "Main Supply"}, {"DA_IN1", NULL, "Charge Pump"}, {"DA_IN2", NULL, "ab8500_0p"}, + {"DA_IN2", NULL, "Main Supply"}, {"DA_IN2", NULL, "Charge Pump"}, /* Headset path */
@@ -799,8 +776,10 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = {/* HF or LineOut path */ {"DA_IN3", NULL, "ab8500_0p"}, + {"DA_IN3", NULL, "Main Supply"}, {"DA3 Channel Volume", NULL, "DA_IN3"}, {"DA_IN4", NULL, "ab8500_0p"}, + {"DA_IN4", NULL, "Main Supply"}, {"DA4 Channel Volume", NULL, "DA_IN4"}, {"Speaker Left Source", "Audio Path", "DA3 Channel Volume"},
@@ -858,8 +837,10 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = {/* Vibrator path */ {"DA_IN5", NULL, "ab8500_0p"}, + {"DA_IN5", NULL, "Main Supply"}, {"DA5 Channel Volume", NULL, "DA_IN5"}, {"DA_IN6", NULL, "ab8500_0p"}, + {"DA_IN6", NULL, "Main Supply"}, {"DA6 Channel Volume", NULL, "DA_IN6"}, {"VIB1 DAC", NULL, "DA5 Channel Volume"},
@@ -901,13 +882,15 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"AD1 Channel Volume", NULL, "AD1 Source Select"}, {"AD2 Channel Volume", NULL, "AD2 Source Select"}, - {"AD12 Enable", NULL, "AD1 Channel Volume"}, - {"AD12 Enable", NULL, "AD2 Channel Volume"}, + {"AD1 Channel Volume", NULL, "AD12 Enable"}, + {"AD2 Channel Volume", NULL, "AD12 Enable"}, - {"AD_OUT1", NULL, "ab8500_0c"}, - {"AD_OUT1", NULL, "AD12 Enable"}, - {"AD_OUT2", NULL, "ab8500_0c"}, - {"AD_OUT2", NULL, "AD12 Enable"}, + {"ab8500_0c", NULL, "AD_OUT1"}, + {"AD_OUT1", NULL, "Main Supply"}, + {"AD_OUT1", NULL, "AD1 Channel Volume"}, + {"ab8500_0c", NULL, "AD_OUT2"}, + {"AD_OUT2", NULL, "Main Supply"}, + {"AD_OUT2", NULL, "AD2 Channel Volume"}, /* Mic 1 */
@@ -924,11 +907,11 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"AD3 Source Select", "Mic 1", "MIC1 ADC"}, {"AD3 Channel Volume", NULL, "AD3 Source Select"}, + {"AD3 Channel Volume", NULL, "AD34 Enable"}, - {"AD3 Enable", NULL, "AD3 Channel Volume"}, - - {"AD_OUT3", NULL, "ab8500_0c"}, - {"AD_OUT3", NULL, "AD3 Enable"}, + {"ab8500_0c", NULL, "AD_OUT3"}, + {"AD_OUT3", NULL, "Main Supply"}, + {"AD_OUT3", NULL, "AD3 Channel Volume"}, /* HD Capture path */
@@ -937,14 +920,15 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"AD5 Channel Volume", NULL, "AD5 Source Select"}, {"AD6 Channel Volume", NULL, "AD6 Source Select"}, + {"AD5 Channel Volume", NULL, "AD5768 Enable"}, + {"AD6 Channel Volume", NULL, "AD5768 Enable"}, - {"AD57 Enable", NULL, "AD5 Channel Volume"}, - {"AD68 Enable", NULL, "AD6 Channel Volume"}, - - {"AD_OUT57", NULL, "ab8500_0c"}, - {"AD_OUT57", NULL, "AD57 Enable"}, - {"AD_OUT68", NULL, "ab8500_0c"}, - {"AD_OUT68", NULL, "AD68 Enable"}, + {"ab8500_0c", NULL, "AD_OUT57"}, + {"AD_OUT57", NULL, "Main Supply"}, + {"AD_OUT57", NULL, "AD5 Channel Volume"}, + {"ab8500_0c", NULL, "AD_OUT68"}, + {"AD_OUT68", NULL, "Main Supply"}, + {"AD_OUT68", NULL, "AD6 Channel Volume"}, /* Digital Microphone path */
@@ -955,17 +939,25 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = { {"DMic 5", NULL, "V-DMIC"}, {"DMic 6", NULL, "V-DMIC"}, - {"AD1 Source Select", NULL, "DMic 1"}, - {"AD2 Source Select", NULL, "DMic 2"}, - {"AD3 Source Select", NULL, "DMic 3"}, - {"AD5 Source Select", NULL, "DMic 5"}, - {"AD6 Source Select", NULL, "DMic 6"}, + {"DMIC1", NULL, "DMic 1"}, + {"DMIC2", NULL, "DMic 2"}, + {"DMIC3", NULL, "DMic 3"}, + {"DMIC4", NULL, "DMic 4"}, + {"DMIC5", NULL, "DMic 5"}, + {"DMIC6", NULL, "DMic 6"}, + + {"AD1 Source Select", "DMic 1", "DMIC1"}, + {"AD2 Source Select", "DMic 2", "DMIC2"}, + {"AD3 Source Select", "DMic 3", "DMIC3"}, + {"AD5 Source Select", "DMic 5", "DMIC5"}, + {"AD6 Source Select", "DMic 6", "DMIC6"}, - {"AD4 Channel Volume", NULL, "DMic 4"}, - {"AD4 Enable", NULL, "AD4 Channel Volume"}, + {"AD4 Channel Volume", NULL, "DMIC4"}, + {"AD4 Channel Volume", NULL, "AD34 Enable"}, - {"AD_OUT4", NULL, "ab8500_0c"}, - {"AD_OUT4", NULL, "AD4 Enable"}, + {"ab8500_0c", NULL, "AD_OUT4"}, + {"AD_OUT4", NULL, "Main Supply"}, + {"AD_OUT4", NULL, "AD4 Channel Volume"}, /* LineIn Bypass path */
@@ -990,13 +982,13 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes[] = {/* Sidetone Filter path */ - {"Sidetone Left Source", "LineIn Left", "AD12 Enable"}, - {"Sidetone Left Source", "LineIn Right", "AD12 Enable"}, - {"Sidetone Left Source", "Mic 1", "AD3 Enable"}, + {"Sidetone Left Source", "LineIn Left", "AD1 Channel Volume"}, + {"Sidetone Left Source", "LineIn Right", "AD2 Channel Volume"}, + {"Sidetone Left Source", "Mic 1", "AD3 Channel Volume"}, {"Sidetone Left Source", "Headset Left", "DA_IN1"}, - {"Sidetone Right Source", "LineIn Right", "AD12 Enable"}, - {"Sidetone Right Source", "Mic 1", "AD3 Enable"}, - {"Sidetone Right Source", "DMic 4", "AD4 Enable"}, + {"Sidetone Right Source", "LineIn Right", "AD2 Channel Volume"}, + {"Sidetone Right Source", "Mic 1", "AD3 Channel Volume"}, + {"Sidetone Right Source", "DMic 4", "AD4 Channel Volume"}, {"Sidetone Right Source", "Headset Right", "DA_IN2"}, {"STFIR1 Control", NULL, "Sidetone Left Source"},
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1193 ASoC: ab8500: Correct digital interface format setup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit f98785adf004db6b1c9f4cea9dadae7b800db72f ]
The codec programs I2S as an undelayed left-aligned format, although the hardware manual defines delayed left-aligned as I2S compatible. It also enables the master generator when the codec is a clock consumer, changes registers before the complete format has been validated, and discards register I/O errors.
Build all three interface register values before writing them, use the required one-bit I2S delay, only run the master generator for a provider configuration, and propagate write failures.
--- sound/soc/codecs/ab8500-codec.c | 175 ++++++++++++-------------------- 1 file changed, 64 insertions(+), 111 deletions(-)
sound/soc/codecs/ab8500-codec.c +64 -111
@@ -2016,149 +2016,91 @@ static int ab8500_audio_set_ear_cmv(struct snd_soc_component *component,return 0 ; } -static int ab8500_audio_set_bit_delay (struct snd_soc_dai *dai, -unsigned int delay) -{ -unsigned int mask, val; -struct snd_soc_component *component = dai->component; - - mask =BIT (AB8500_DIGIFCONF2_IF0DEL ); - val =0 ; - -switch (delay) { -case 0 : -break ; -case 1 : - val |=BIT (AB8500_DIGIFCONF2_IF0DEL ); -break ; -default : -dev_err (dai->component->dev, -"%s: ERROR: Unsupported bit-delay (0x%x)!\n" , - __func__, delay); -return -EINVAL ; - } - -dev_dbg (dai->component->dev,"%s: IF0 Bit-delay: %d bits.\n" , - __func__, delay); -snd_soc_component_update_bits (component,AB8500_DIGIFCONF2 , mask, val); - -return 0 ; -} - -/* Gates clocking according format mask */ -static int ab8500_codec_set_dai_clock_gate (struct snd_soc_component *component, -unsigned int fmt) -{ -unsigned int mask; -unsigned int val; - - mask =BIT (AB8500_DIGIFCONF1_ENMASTGEN ) | -BIT (AB8500_DIGIFCONF1_ENFSBITCLK0 ); - - val =BIT (AB8500_DIGIFCONF1_ENMASTGEN ); - -switch (fmt &SND_SOC_DAIFMT_CLOCK_MASK ) { -case SND_SOC_DAIFMT_CONT :/* continuous clock */ -dev_dbg (component->dev,"%s: IF0 Clock is continuous.\n" , - __func__); - val |=BIT (AB8500_DIGIFCONF1_ENFSBITCLK0 ); -break ; -case SND_SOC_DAIFMT_GATED :/* clock is gated */ -dev_dbg (component->dev,"%s: IF0 Clock is gated.\n" , - __func__); -break ; -default : -dev_err (component->dev, -"%s: ERROR: Unsupported clock mask (0x%x)!\n" , - __func__, fmt &SND_SOC_DAIFMT_CLOCK_MASK ); -return -EINVAL ; - } - -snd_soc_component_update_bits (component,AB8500_DIGIFCONF1 , mask, val); - -return 0 ; -} -static int ab8500_codec_set_dai_fmt (struct snd_soc_dai *dai,unsigned int fmt) { -unsigned int mask; -unsigned int val;struct snd_soc_component *component = dai->component; -int status; +unsigned int conf1_mask, conf1_val =0 ; +unsigned int conf2_mask, conf2_val =0 ; +unsigned int conf3_mask, conf3_val =0 ; +bool provider = false; +int ret;dev_dbg (component->dev,"%s: Enter (fmt = 0x%x)\n" , __func__, fmt); - mask =BIT (AB8500_DIGIFCONF3_IF1DATOIF0AD ) | + conf3_mask =BIT (AB8500_DIGIFCONF3_IF1DATOIF0AD ) |BIT (AB8500_DIGIFCONF3_IF1CLKTOIF0CLK ) |BIT (AB8500_DIGIFCONF3_IF0BFIFOEN ) |BIT (AB8500_DIGIFCONF3_IF0MASTER ); - val =0 ;switch (fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK ) {case SND_SOC_DAIFMT_CBP_CFP : -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0 Master-mode: AB8500 provider.\n" , __func__); - val |=BIT (AB8500_DIGIFCONF3_IF0MASTER ); + conf3_val |=BIT (AB8500_DIGIFCONF3_IF0MASTER ); + provider = true;break ;case SND_SOC_DAIFMT_CBC_CFC : -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0 Master-mode: AB8500 consumer.\n" , __func__);break ;case SND_SOC_DAIFMT_CBC_CFP :case SND_SOC_DAIFMT_CBP_CFC : -dev_err (dai->component->dev, +dev_err (component->dev,"%s: ERROR: The device is either a provider or a consumer.\n" , __func__); fallthrough;default : -dev_err (dai->component->dev, -"%s: ERROR: Unsupporter clocking mask 0x%x\n" , +dev_err (component->dev, +"%s: ERROR: Unsupported clocking mask 0x%x\n" , __func__, fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK );return -EINVAL ; } -snd_soc_component_update_bits (component,AB8500_DIGIFCONF3 , mask, val); - -/* Set clock gating */ - status =ab8500_codec_set_dai_clock_gate (component, fmt); -if (status) { -dev_err (dai->component->dev, -"%s: ERROR: Failed to set clock gate (%d).\n" , - __func__, status); -return status; + conf1_mask =BIT (AB8500_DIGIFCONF1_ENMASTGEN ) | +BIT (AB8500_DIGIFCONF1_ENFSBITCLK0 ); +switch (fmt &SND_SOC_DAIFMT_CLOCK_MASK ) { +case SND_SOC_DAIFMT_CONT : +if (provider) + conf1_val = conf1_mask; +break ; +case SND_SOC_DAIFMT_GATED : +if (provider) + conf1_val =BIT (AB8500_DIGIFCONF1_ENMASTGEN ); +break ; +default : +dev_err (component->dev,"%s: Unsupported clock mask 0x%x\n" , + __func__, fmt &SND_SOC_DAIFMT_CLOCK_MASK ); +return -EINVAL ; } -/* Setting data transfer format */ - - mask =BIT (AB8500_DIGIFCONF2_IF0FORMAT0 ) | -BIT (AB8500_DIGIFCONF2_IF0FORMAT1 ) | -BIT (AB8500_DIGIFCONF2_FSYNC0P ) | -BIT (AB8500_DIGIFCONF2_BITCLK0P ); - val =0 ; + conf2_mask =BIT (AB8500_DIGIFCONF2_IF0FORMAT0 ) | +BIT (AB8500_DIGIFCONF2_IF0FORMAT1 ) | +BIT (AB8500_DIGIFCONF2_IF0DEL ) | +BIT (AB8500_DIGIFCONF2_FSYNC0P ) | +BIT (AB8500_DIGIFCONF2_BITCLK0P );switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S :/* I2S mode */ -dev_dbg (dai->component->dev,"%s: IF0 Protocol: I2S\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT1 ); -ab8500_audio_set_bit_delay (dai,0 ); +dev_dbg (component->dev,"%s: IF0 Protocol: I2S\n" , __func__); + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT1 ) | +BIT (AB8500_DIGIFCONF2_IF0DEL );break ;case SND_SOC_DAIFMT_DSP_A :/* L data MSB after FRM LRC */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0 Protocol: DSP A (TDM)\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT0 ); -ab8500_audio_set_bit_delay (dai,1 ); + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT0 ) | +BIT (AB8500_DIGIFCONF2_IF0DEL );break ;case SND_SOC_DAIFMT_DSP_B :/* L data MSB during FRM LRC */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0 Protocol: DSP B (TDM)\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT0 ); -ab8500_audio_set_bit_delay (dai,0 ); + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0FORMAT0 );break ;default : -dev_err (dai->component->dev, +dev_err (component->dev,"%s: ERROR: Unsupported format (0x%x)!\n" , __func__, fmt &SND_SOC_DAIFMT_FORMAT_MASK );return -EINVAL ;
@@ -2166,39 +2108,50 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)switch (fmt &SND_SOC_DAIFMT_INV_MASK ) {case SND_SOC_DAIFMT_NB_NF :/* normal bit clock + frame */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0: Normal bit clock, normal frame\n" , __func__);break ;case SND_SOC_DAIFMT_NB_IF :/* normal BCLK + inv FRM */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0: Normal bit clock, inverted frame\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_FSYNC0P ); + conf2_val |=BIT (AB8500_DIGIFCONF2_FSYNC0P );break ;case SND_SOC_DAIFMT_IB_NF :/* invert BCLK + nor FRM */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0: Inverted bit clock, normal frame\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_BITCLK0P ); + conf2_val |=BIT (AB8500_DIGIFCONF2_BITCLK0P );break ;case SND_SOC_DAIFMT_IB_IF :/* invert BCLK + FRM */ -dev_dbg (dai->component->dev, +dev_dbg (component->dev,"%s: IF0: Inverted bit clock, inverted frame\n" , __func__); - val |=BIT (AB8500_DIGIFCONF2_FSYNC0P ); - val |=BIT (AB8500_DIGIFCONF2_BITCLK0P ); + conf2_val |=BIT (AB8500_DIGIFCONF2_FSYNC0P ) | +BIT (AB8500_DIGIFCONF2_BITCLK0P );break ;default : -dev_err (dai->component->dev, +dev_err (component->dev,"%s: ERROR: Unsupported INV mask 0x%x\n" , __func__, fmt &SND_SOC_DAIFMT_INV_MASK );return -EINVAL ; } -snd_soc_component_update_bits (component,AB8500_DIGIFCONF2 , mask, val); + ret =snd_soc_component_update_bits (component,AB8500_DIGIFCONF3 , + conf3_mask, conf3_val); +if (ret <0 ) +return ret; -return 0 ; + ret =snd_soc_component_update_bits (component,AB8500_DIGIFCONF1 , + conf1_mask, conf1_val); +if (ret <0 ) +return ret; + + ret =snd_soc_component_update_bits (component,AB8500_DIGIFCONF2 , + conf2_mask, conf2_val); + +return ret <0 ? ret :0 ; } static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1193 ASoC: ab8500: Validate and program TDM slots correctly
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 85cef7e2004ef5c1a715feaddb55d3f3d27bac0a ]
The interface clock ratio is selected from the slot count alone, ffs() and fls() produce one-based hardware slot numbers, eight-channel mode does not program any mappings, and all register errors are ignored. Invalid masks can also leave a partially programmed interface.
Validate the complete configuration first, derive the supported BCLK ratio from slots times slot width, use zero-based slot indices, program deterministic eight-channel maps, and propagate register failures.
--- sound/soc/codecs/ab8500-codec.c | 216 ++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 93 deletions(-)
sound/soc/codecs/ab8500-codec.c +123 -93
@@ -2159,23 +2159,27 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, int slots, int slot_width) {struct snd_soc_component *component = dai->component; -unsigned int val, mask, slot, slots_active; +unsigned int active_mask, clock_ratio, slot, value, ad_out, reg; +unsigned int tx_active, rx_active; +unsigned int conf1_val, conf2_val; +unsigned int mask; +int channel, ret; mask =BIT (AB8500_DIGIFCONF2_IF0WL0 ) |BIT (AB8500_DIGIFCONF2_IF0WL1 ); - val =0 ; + conf2_val =0 ;switch (slot_width) {case 16 :break ;case 20 : - val |=BIT (AB8500_DIGIFCONF2_IF0WL0 ); + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0WL0 );break ;case 24 : - val |=BIT (AB8500_DIGIFCONF2_IF0WL1 ); + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0WL1 );break ;case 32 : - val |=BIT (AB8500_DIGIFCONF2_IF0WL1 ) | + conf2_val |=BIT (AB8500_DIGIFCONF2_IF0WL1 ) |BIT (AB8500_DIGIFCONF2_IF0WL0 );break ;default :
@@ -2184,27 +2188,11 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,return -EINVAL ; } -dev_dbg (dai->component->dev,"%s: IF0 slot-width: %d bits.\n" , - __func__, slot_width); -snd_soc_component_update_bits (component,AB8500_DIGIFCONF2 , mask, val); - -/* Setup TDM clocking according to slot count */ -dev_dbg (dai->component->dev,"%s: Slots, total: %d\n" , __func__, slots); - mask =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 ) | -BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 );switch (slots) {case 2 : - val =AB8500_MASK_NONE ; -break ;case 4 : - val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 ); -break ;case 8 : - val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 ); -break ;case 16 : - val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 ) | -BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 );break ;default : dev_err(dai->component->dev,
@@ -2212,92 +2200,134 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, __func__, slots);return -EINVAL ; } -snd_soc_component_update_bits (component,AB8500_DIGIFCONF1 , mask, val); - -/* Setup TDM DA according to active tx slots */ -if (tx_mask & ~0xff ) -return -EINVAL ; - - mask =AB8500_DASLOTCONFX_SLTODAX_MASK ; - tx_mask = tx_mask <<AB8500_DA_DATA0_OFFSET ; - slots_active =hweight32 (tx_mask); - -dev_dbg (dai->component->dev,"%s: Slots, active, TX: %d\n" , __func__, - slots_active); - -switch (slots_active) { -case 0 : + clock_ratio = slots * slot_width; +switch (clock_ratio) { +case 32 : + conf1_val =0 ;break ; -case 1 : - slot =ffs (tx_mask); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF1 , mask, slot); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF3 , mask, slot); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF2 , mask, slot); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF4 , mask, slot); +case 64 : + conf1_val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 );break ; -case 2 : - slot =ffs (tx_mask); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF1 , mask, slot); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF3 , mask, slot); - slot =fls (tx_mask); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF2 , mask, slot); -snd_soc_component_update_bits (component,AB8500_DASLOTCONF4 , mask, slot); +case 128 : + conf1_val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 );break ; -case 8 : -dev_dbg (dai->component->dev, -"%s: In 8-channel mode DA-from-slot mapping is set manually." , - __func__); +case 256 : + conf1_val =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 ) | +BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 );break ;default : -dev_err (dai->component->dev, -"%s: Unsupported number of active TX-slots (%d)!\n" , - __func__, slots_active); +dev_err (component->dev,"%s: Unsupported BCLK ratio (%u)!\n" , + __func__, clock_ratio);return -EINVAL ; } -/* Setup TDM AD according to active RX-slots */ + active_mask =GENMASK (min (slots,8 ) -1 ,0 ); +if ((tx_mask | rx_mask) & ~active_mask) { +dev_err (component->dev,"%s: Slot mask exceeds slot count\n" , + __func__); +return -EINVAL ; + } -if (rx_mask & ~0xff ) + tx_active =hweight32 (tx_mask); + rx_active =hweight32 (rx_mask); +if (tx_active !=0 && tx_active !=1 && tx_active !=2 && + tx_active !=8 ) { +dev_err (component->dev,"%s: Unsupported active TX slots (%u)!\n" , + __func__, tx_active); +return -EINVAL ; + } +if (rx_active !=0 && rx_active !=1 && rx_active !=2 && + rx_active !=8 ) { +dev_err (component->dev,"%s: Unsupported active RX slots (%u)!\n" , + __func__, rx_active);return -EINVAL ; + } + +dev_dbg (component->dev, +"%s: %d slots of %d bits, TX active: %u, RX active: %u\n" , + __func__, slots, slot_width, tx_active, rx_active); - rx_mask = rx_mask <<AB8500_AD_DATA0_OFFSET ; - slots_active =hweight32 (rx_mask); + ret =snd_soc_component_update_bits (component,AB8500_DIGIFCONF2 , + mask, conf2_val); +if (ret <0 ) +return ret; -dev_dbg (dai->component->dev,"%s: Slots, active, RX: %d\n" , __func__, - slots_active); + mask =BIT (AB8500_DIGIFCONF1_IF0BITCLKOS0 ) | +BIT (AB8500_DIGIFCONF1_IF0BITCLKOS1 ); + ret =snd_soc_component_update_bits (component,AB8500_DIGIFCONF1 , + mask, conf1_val); +if (ret <0 ) +return ret; -switch (slots_active) { -case 0 : -break ; -case 1 : - slot =ffs (rx_mask); -snd_soc_component_update_bits (component,AB8500_ADSLOTSEL (slot), -AB8500_MASK_SLOT (slot), -AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (AB8500_AD_OUT3 , slot)); -break ; -case 2 : - slot =ffs (rx_mask); -snd_soc_component_update_bits (component, -AB8500_ADSLOTSEL (slot), -AB8500_MASK_SLOT (slot), -AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (AB8500_AD_OUT3 , slot)); - slot =fls (rx_mask); -snd_soc_component_update_bits (component, -AB8500_ADSLOTSEL (slot), -AB8500_MASK_SLOT (slot), -AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (AB8500_AD_OUT2 , slot)); -break ; -case 8 : -dev_dbg (dai->component->dev, -"%s: In 8-channel mode AD-to-slot mapping is set manually." , - __func__); -break ; -default : -dev_err (dai->component->dev, -"%s: Unsupported number of active RX-slots (%d)!\n" , - __func__, slots_active); -return -EINVAL ; + mask =AB8500_DASLOTCONFX_SLTODAX_MASK ; +if (tx_active ==1 || tx_active ==2 ) { + slot =__ffs (tx_mask) +AB8500_DA_DATA0_OFFSET ; + reg =AB8500_DASLOTCONF1 ; + ret =snd_soc_component_update_bits (component, reg, mask, slot); +if (ret <0 ) +return ret; + reg =AB8500_DASLOTCONF3 ; + ret =snd_soc_component_update_bits (component, reg, mask, slot); +if (ret <0 ) +return ret; + +if (tx_active ==2 ) + slot =__fls (tx_mask) +AB8500_DA_DATA0_OFFSET ; + reg =AB8500_DASLOTCONF2 ; + ret =snd_soc_component_update_bits (component, reg, mask, slot); +if (ret <0 ) +return ret; + reg =AB8500_DASLOTCONF4 ; + ret =snd_soc_component_update_bits (component, reg, mask, slot); +if (ret <0 ) +return ret; + }else if (tx_active ==8 ) { + channel =0 ; +for (slot =0 ; slot <8 ; slot++) { +if (!(tx_mask &BIT (slot))) +continue ; + reg =AB8500_DASLOTCONF1 + channel++; + value = slot +AB8500_DA_DATA0_OFFSET ; + ret =snd_soc_component_update_bits (component, reg, mask, value); +if (ret <0 ) +return ret; + } + } + +if (rx_active ==1 || rx_active ==2 ) { + slot =__ffs (rx_mask) +AB8500_AD_DATA0_OFFSET ; + value =AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (AB8500_AD_OUT3 , + slot); + reg =AB8500_ADSLOTSEL (slot); + mask =AB8500_MASK_SLOT (slot); + ret =snd_soc_component_update_bits (component, reg, mask, value); +if (ret <0 ) +return ret; + +if (rx_active ==2 ) { + slot =__fls (rx_mask) +AB8500_AD_DATA0_OFFSET ; + value =AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (AB8500_AD_OUT2 , + slot); + reg =AB8500_ADSLOTSEL (slot); + mask =AB8500_MASK_SLOT (slot); + ret =snd_soc_component_update_bits (component, reg, mask, value); +if (ret <0 ) +return ret; + } + }else if (rx_active ==8 ) { + channel =0 ; +for (slot =0 ; slot <8 ; slot++) { +if (!(rx_mask &BIT (slot))) +continue ; + ad_out =AB8500_AD_OUT1 + channel++; + value =AB8500_ADSLOTSELX_AD_OUT_TO_SLOT (ad_out, slot); + reg =AB8500_ADSLOTSEL (slot); + mask =AB8500_MASK_SLOT (slot); + ret =snd_soc_component_update_bits (component, reg, mask, value); +if (ret <0 ) +return ret; + } }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1193 net/sched: cls_u32: fix duplicate handle when node ID pool is exhausted
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d7e7e98d23f42a92d9ab7e36302bd96bd9b33b5f ]
gen_new_kid() falls back to returning max (htid | 0xFFF) when both idr_alloc_u32() ranges are full, instead of reporting an error. u32_change() trusts that value and inserts a new knode with a handle that is already live in the hash table, breaking handle uniqueness within the table's node ID space.
The handle was never reserved in ht->handle_idr, so every later error path that does idr_remove(&ht->handle_idr, handle) removes the reservation of a different, live knode, which is then reused — one failed add compounds into further duplicates.
The 4095 limit is per (table, bucket) — ht->handle_idr is per hash table and the range is derived from htid (bucketid), so a table with divisor 256 can legitimately hold 256*4095 knodes.
The sibling helper gen_new_htid() has the same silent in-band failure:
it returns 0 when the tp_c handle pool (1..0x7FF) is full, and u32_init() publishes the root hash table with handle 0 without checking. Two root tables with handle 0 alias in u32_lookup_ht(), allowing cross-tcf_proto knode add/lookup/delete. Add the same exhaustion check that the divisor path already has.
Return an error so u32_change() fails with ENOSPC/ENOMEM when the node ID space is exhausted, and so u32_init() fails with -ENOMEM when the hash table ID space is exhausted. The extack message distinguishes pool exhaustion (-ENOSPC) from a transient allocation failure (-ENOMEM).
Conditions to recreate the bug:
- CONFIG_NET_SCHED=y, CONFIG_CLS_U32=y (or =m with module loaded)
- Create a clsact qdisc on a device, then add 4095 u32 filters with auto-generated handles to fill the node ID space for the root hash table (single bucket). The 4096th auto-handle filter add triggers the duplicate handle (fh 800::fff reused). Reachable at Level 2 (unshare -Urn, namespace-local CAP_NET_ADMIN).
- For gen_new_htid: create 2047 u32 proto entries on the same block to fill the tp_c handle pool, then create one more. The root table gets handle 0 and aliases with other handle-0 root tables.
--- net/sched/cls_u32.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-)
net/sched/cls_u32.c +26 -6
@@ -370,6 +370,10 @@ static int u32_init(struct tcf_proto *tp)refcount_set (&root_ht->refcnt,1 ); root_ht->handle = tp_c ?gen_new_htid (tp_c, root_ht) :id2handle (0 ); +if (root_ht->handle ==0 ) { +kfree (root_ht); +return -ENOMEM ; + } root_ht->prio = tp->prio; root_ht->is_root = true;idr_init (&root_ht->handle_idr);
@@ -695,21 +699,33 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last,return ret; } -static u32 gen_new_kid (struct tc_u_hnode *ht,u32 htid) +static u32 gen_new_kid (struct tc_u_hnode *ht,u32 htid,int *err) {u32 index = htid |0x800 ;u32 max = htid |0xFFF ; + *err =0 ; +if (idr_alloc_u32 (&ht->handle_idr,NULL , &index, max,GFP_KERNEL )) { index = htid +1 ; -if (idr_alloc_u32 (&ht->handle_idr,NULL , &index, max, -GFP_KERNEL )) - index = max; + *err =idr_alloc_u32 (&ht->handle_idr,NULL , &index, max, +GFP_KERNEL ); +if (*err) +return 0 ; }return index; } +static int u32_kid_extack (int err,struct netlink_ext_ack *extack) +{ +if (err == -ENOSPC ) +NL_SET_ERR_MSG_MOD (extack,"Hash table node ID pool exhausted" ); +else +NL_SET_ERR_MSG_MOD (extack,"Failed to allocate node ID" ); +return err; +} +static const struct nla_policy u32_policy[TCA_U32_MAX +1 ] = { [TCA_U32_CLASSID ] = { .type =NLA_U32 }, [TCA_U32_HASH ] = { .type =NLA_U32 },
@@ -1076,7 +1092,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,* handle which is used to uniquely identify the match entry. */ if (!TC_U32_NODE (handle)) { - handle =gen_new_kid (ht, htid); + handle =gen_new_kid (ht, htid, &err); +if (err) +return u32_kid_extack (err, extack); }else { handle = htid |TC_U32_NODE (handle); err = idr_alloc_u32(&ht->handle_idr, NULL, &handle,
@@ -1088,7 +1106,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,/* The user did not give us a handle; lets just generate one * from the table's pool of nodeids. */ - handle =gen_new_kid (ht, htid); + handle =gen_new_kid (ht, htid, &err); +if (err) +return u32_kid_extack (err, extack); }if (tb[TCA_U32_SEL ] ==NULL ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1193 ppp: ppp_async: simplify tty disc_data access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 9feb069e5ed03582fbf6272539f1caa2a17dc6d5 ]
tty_ldisc_hangup() invokes the hangup callback while holding only a read lock on tty->ldisc_sem, so it can run concurrently with other line discipline callbacks. This currently forces async PPP to maintain separate lifetime protection around tty->disc_data.
Line discipline close is called under the write lock during hangup processing. Remove the hangup callback and rely on close for teardown, as done for SLIP by commit 23c53269f2ba ("slip: remove slip_hangup() to fix use-after-free in slip_receive_buf()"). This serializes teardown with all other line discipline operations.
disc_data_lock, refcount and completion are redundant with that serialization. Remove them and access tty->disc_data directly.
This also eliminates a lockdep warning reported by syzbot. The warning does not indicate a real deadlock because the write side runs only in process context with hardirqs disabled.
--- drivers/net/ppp/ppp_async.c | 82 ++++--------------------------------- 1 file changed, 7 insertions(+), 75 deletions(-)
drivers/net/ppp/ppp_async.c +7 -75
@@ -65,8 +65,6 @@ struct asyncppp {struct tasklet_struct tsk; -refcount_t refcnt; -struct completion dead;struct ppp_channel chan;/* interface to generic ppp layer */ unsigned char obuf[OBUFSIZE ]; };
@@ -115,38 +113,6 @@ static const struct ppp_channel_ops async_ops = {* Routines implementing the PPP line discipline. */ -/* -* We have a potential race on dereferencing tty->disc_data, -* because the tty layer provides no locking at all - thus one -* cpu could be running ppp_asynctty_receive while another -* calls ppp_asynctty_close, which zeroes tty->disc_data and -* frees the memory that ppp_asynctty_receive is using. The best -* way to fix this is to use a rwlock in the tty struct, but for now -* we use a single global rwlock for all ttys in ppp line discipline. -* -* FIXME: this is no longer true. The _close path for the ldisc is -* now guaranteed to be sane. -*/ -static DEFINE_RWLOCK (disc_data_lock); - -static struct asyncppp *ap_get (struct tty_struct *tty) -{ -struct asyncppp *ap; - -read_lock (&disc_data_lock); - ap = tty->disc_data; -if (ap !=NULL ) -refcount_inc (&ap->refcnt); -read_unlock (&disc_data_lock); -return ap; -} - -static void ap_put (struct asyncppp *ap) -{ -if (refcount_dec_and_test (&ap->refcnt)) -complete (&ap->dead); -} -/* * Called when a tty is put into PPP line discipline. Called in process * context.
@@ -181,9 +147,6 @@ ppp_asynctty_open(struct tty_struct *tty)skb_queue_head_init (&ap->rqueue);tasklet_setup (&ap->tsk, ppp_async_process); -refcount_set (&ap->refcnt,1 ); -init_completion (&ap->dead); - ap->chan.private = ap; ap->chan.ops = &async_ops; ap->chan.mtu =PPP_MRU ;
@@ -204,34 +167,18 @@ ppp_asynctty_open(struct tty_struct *tty) }/* -* Called when the tty is put into another line discipline -* or it hangs up. We have to wait for any cpu currently -* executing in any of the other ppp_asynctty_* routines to -* finish before we can call ppp_unregister_channel and free -* the asyncppp struct. This routine must be called from -* process context, not interrupt or softirq context. +* Called when the tty is put into another line discipline or it hangs up. +* This call is serialized against other ldisc functions. */ static void ppp_asynctty_close (struct tty_struct *tty) { -struct asyncppp *ap; +struct asyncppp *ap = tty->disc_data; -write_lock_irq (&disc_data_lock); - ap = tty->disc_data; - tty->disc_data =NULL ; -write_unlock_irq (&disc_data_lock);if (!ap)return ; -/* -* We have now ensured that nobody can start using ap from now -* on, but we have to wait for all existing users to finish. -* Note that ppp_unregister_channel ensures that no calls to -* our channel ops (i.e. ppp_async_send/ioctl) are in progress -* by the time it returns. -*/ -if (!refcount_dec_and_test (&ap->refcnt)) -wait_for_completion (&ap->dead); + tty->disc_data =NULL ;tasklet_kill (&ap->tsk);ppp_unregister_channel (&ap->chan);
@@ -241,17 +188,6 @@ ppp_asynctty_close(struct tty_struct *tty)kfree (ap); } -/* -* Called on tty hangup in process context. -* -* Wait for I/O to driver to complete and unregister PPP channel. -* This is already done by the close routine, so just call that. -*/ -static void ppp_asynctty_hangup (struct tty_struct *tty) -{ -ppp_asynctty_close (tty); -} -/* * Read does nothing - no data is ever available this way. * Pppd reads and writes packets via /dev/ppp instead.
@@ -282,7 +218,7 @@ ppp_asynctty_write(struct tty_struct *tty, struct file *file, const u8 *buf,static int ppp_asynctty_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) { -struct asyncppp *ap =ap_get (tty); +struct asyncppp *ap = tty->disc_data;int err, val;int __user *p = (int __user *)arg;
@@ -323,7 +259,6 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) err =tty_mode_ioctl (tty, cmd, arg); } -ap_put (ap);return err; }
@@ -332,7 +267,7 @@ static void ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, size_t count) { - struct asyncppp *ap = ap_get(tty); + struct asyncppp *ap = tty->disc_data;unsigned long flags;if (!ap)
@@ -342,21 +277,19 @@ ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags,spin_unlock_irqrestore (&ap->recv_lock, flags);if (!skb_queue_empty (&ap->rqueue))tasklet_schedule (&ap->tsk); -ap_put (ap);tty_unthrottle (tty); }static void ppp_asynctty_wakeup (struct tty_struct *tty) { -struct asyncppp *ap =ap_get (tty); +struct asyncppp *ap = tty->disc_data;clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags);if (!ap)return ;set_bit (XMIT_WAKEUP , &ap->xmit_flags);tasklet_schedule (&ap->tsk); -ap_put (ap); }
@@ -366,7 +299,6 @@ static struct tty_ldisc_ops ppp_ldisc = { .name = "ppp", .open = ppp_asynctty_open, .close = ppp_asynctty_close, - .hangup = ppp_asynctty_hangup, .read = ppp_asynctty_read, .write = ppp_asynctty_write, .ioctl = ppp_asynctty_ioctl,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1193 ip6_gre: check tunnel info before xmit in ip6gre_tunnel_xmit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 97cc84dad1d7f68a36b71b69b361d88482707673 ]
Shuangpeng Bai reported a KASAN slab-use-after-free in ip6gre_tunnel_xmit().
The precise KASAN bug was caused by ip6_tnl_xmit() consuming the skb during headroom expansion and returning an error, while ip6gre_tunnel_xmit() still held the stale pointer and called skb_tunnel_info_txcheck(skb) at tx_err. That specific bug was fixed by commit 87f21b59ddc6 ("ip6_tunnel: use skb_cow_head() in ip6_tnl_xmit()").
However, calling skb_tunnel_info_txcheck(skb) at the tx_err label after the transmission attempt remains problematic:
Downstream helpers like ip6_tnl_xmit() call skb_scrub_packet(), which drops the skb's metadata_dst before transmission. If an error occurs later during transmit, inspecting skb at tx_err sees a scrubbed dst and misclassifies tx_errors vs tx_dropped.
Commit e5f7e211b6aa ("ip6gre: avoid tx_error when sending MLD/DAD on external tunnels") already handled this correctly in ip6erspan_tunnel_xmit() by checking and caching tun_info before transmit.
Align ip6gre_tunnel_xmit() with ip6erspan_tunnel_xmit() by caching tun_info before xmit and checking it at tx_err.
--- net/ipv6/ip6_gre.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/ip6_gre.c +5 -1
@@ -897,6 +897,7 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)static netdev_tx_t ip6gre_tunnel_xmit (struct sk_buff *skb,struct net_device *dev) { +struct ip_tunnel_info *tun_info =NULL ;struct ip6_tnl *t =netdev_priv (dev);__be16 payload_protocol;int ret;
@@ -907,6 +908,9 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,if (!ip6_tnl_xmit_ctl (t, &t->parms.laddr, &t->parms.raddr)) goto tx_err; +if (t->parms.collect_md) + tun_info =skb_tunnel_info_txcheck (skb); + payload_protocol =skb_protocol (skb, true);switch (payload_protocol) {case htons (ETH_P_IP ):
@@ -926,7 +930,7 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; tx_err: -if (!t->parms.collect_md || !IS_ERR (skb_tunnel_info_txcheck (skb))) +if (!IS_ERR (tun_info))DEV_STATS_INC (dev, tx_errors);DEV_STATS_INC (dev, tx_dropped);kfree_skb (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/1193 tipc: fix NULL deref in tipc_named_node_up() on empty publication list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tung Nguyen <[email protected]>
[ Upstream commit b3b76e9f4f2476f1135b2ba7743a821db4a0df4b ]
User-space applications can bind a large number of service addresses to one or more sockets. Each binding of a local-scope service address inserts one entry (publication) into the TIPC name table. If the number of these publications exceeds TIPC_MAX_PUBL (65535), protocol service types (such as node state and link state) are no longer inserted into the name table. This causes two issues:
1. User-space applications subscribing to node or link up/down events stop receiving notifications.
2. A NULL pointer dereference can occur:
BUG: kernel NULL pointer dereference, address: 00000000000000d0 ... CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.2.0-rc4-default+ #5 PREEMPT(full) ... RIP: 0010:tipc_named_node_up (./include/linux/skbuff.h:2251 net/tipc/name_distr.c:195 net/tipc/name_distr.c:221) ... Call Trace: <IRQ> tipc_node_write_unlock (net/tipc/node.c:428) tipc_rcv (net/tipc/node.c:934 net/tipc/node.c:2189) tipc_udp_recv (net/tipc/udp_media.c:389)
Thread 1 (tipc_net_finalize) | Thread 2 (named_distribute)
-----------------------------|-----------------------------
| ...
| list_for_each_entry(publ, pls, binding_node) {
| ...
| __skb_queue_tail(list, skb);
| ...
| }
| ...
| hdr = buf_msg(skb_peek_tail(list));
... |
tipc_nametbl_publish(); | If 'tipc_nametbl_publish()' (Thread 1) fails because the number of local publications reaches TIPC_MAX_PUBL, list (Thread 2) will be empty. As a result, NULL is passed to 'buf_msg()', leading to a NULL pointer dereference.
Fix these issues by allowing protocol service types (node state, link state, and topology server) to be inserted into the name table unconditionally. This ensures that users subscribing to these types always receive notifications. In addition, the maximum number of local user publications is reduced to (TIPC_MAX_PUBL - 1). This ensures that the maximum bulk size calculated in tipc_link_set_queue_limits() remains valid.
--- net/tipc/name_table.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
net/tipc/name_table.c +26 -4
@@ -763,21 +763,40 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk, u32 key) {struct name_table *nt =tipc_name_table (net); +u32 max_user_pub =TIPC_MAX_PUBL -1 ;struct tipc_net *tn =tipc_net (net);struct publication *p =NULL ;struct sk_buff *skb =NULL ; +bool protocol_type = false;u32 rc_dests; +if (ua->sr.type ==TIPC_NODE_STATE || ua->sr.type ==TIPC_LINK_STATE || + ua->sr.type ==TIPC_TOP_SRV ) + protocol_type = true; +spin_lock_bh (&tn->nametbl_lock); +if (protocol_type) + goto insert; -if (nt->local_publ_count >=TIPC_MAX_PUBL ) { -pr_warn ("Bind failed, max limit %u reached\n" ,TIPC_MAX_PUBL ); +/* Reserve one entry for node state service type because it has cluster +* scope and it is distributed in bulk. So, the maximum number of user's +* publications is (TIPC_MAX_PUBL - 1). +*/ +if (nt->local_publ_count >= max_user_pub) { +pr_warn ("Bind failed, max limit %u reached\n" , max_user_pub); goto exit; } +insert: p =tipc_nametbl_insert_publ (net, ua, sk, key);if (p) { - nt->local_publ_count++; +/* Not count node state, link state and topology server types +* so that maximum nt->local_publ_count does not prevent +* protocol service types from being inserted into the name +* table. +*/ +if (!protocol_type) + nt->local_publ_count++; skb =tipc_named_publish (net, p); } rc_dests = nt->rc_dests;
@@ -810,7 +829,10 @@ void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua, p =tipc_nametbl_remove_publ (net, ua, sk, key);if (p) { - nt->local_publ_count--; +if (p->sr.type !=TIPC_NODE_STATE && + p->sr.type !=TIPC_LINK_STATE && + p->sr.type !=TIPC_TOP_SRV ) + nt->local_publ_count--; skb =tipc_named_withdraw (net, p);list_del_init (&p->binding_sock);kfree_rcu (p, rcu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/1193 ipv6: sr: restore network header before routing and forwarding
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 975b5b067f525a1b1338c4a3bee1c46545801518 ]
ipv6_srh_rcv() runs with skb->data at the Segment Routing Header (SRH) while skb_network_header() points at the IPv6 header.
When segments_left > 0, ipv6_srh_rcv() previously restored the skb->data position by pushing sizeof(struct ipv6hdr), assuming the SRH immediately followed the fixed IPv6 header. If another extension header (such as a Hop-by-Hop options header) precedes the SRH, skb_network_offset() remained negative.
This led to two problems:
1. During ip6_route_input(), fib6_rules_early_flow_dissect() invokes __skb_flow_dissect() which passes the negative skb_network_offset() to flow dissection, breaking BPF and C flow dissector logic.
2. If forwarded via ip6_forward() or redirected via act_mirred, downstream handlers (like sch_fragment() or neighbour output) pass the negative offset as an unsigned length, triggering OOB memcpy or buffer overflows.
Fix this by pushing -skb_network_offset(skb) before routing, ensuring skb_network_offset(skb) is 0 for route lookup / flow dissection as well as downstream forwarding. On the loopback path, pull skb_transport_offset(skb) to restore skb->data to the SRH before looping back.
--- net/ipv6/exthdrs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/exthdrs.c +2 -2
@@ -454,7 +454,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb) hdr->segments_left--; addr = hdr->segments + hdr->segments_left; -skb_push (skb,sizeof (struct ipv6hdr )); +skb_push (skb, -skb_network_offset (skb));if (skb->ip_summed ==CHECKSUM_COMPLETE )seg6_update_csum (skb);
@@ -478,7 +478,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb) }ipv6_hdr (skb)->hop_limit--; -skb_pull (skb,sizeof (struct ipv6hdr )); +skb_pull (skb,skb_transport_offset (skb)); goto looped_back; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/1193 af_packet: Dont cast tpacket_hdr.tp_len to int in tpacket_parse_header().
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 73e594c19b4f815d8343461cec7074c4713bbde7 ]
syzbot reported BUG() in sock_sendmsg_nosec(). [0]
The problem is that tpacket_parse_header() casts user-provided tpacket_hdr.tp_len, which is u32, to int.
If the length is larger than INT_MAX, the following condition in tpacket_parse_header() passes,
if (unlikely(tp_len > size_max))
and any negative value can be returned to the caller, up to sock_sendmsg_nosec().
The repro set tpacket_hdr.tp_len to 0xfffffdef, which is cast to -EIOCBQUEUED (-529), triggering BUG() in sock_sendmsg_nosec().
*(uint64_t*)0x200000000008 = 0xfffffdef; ... syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x200000000000ul, /*count=*/1ul);
Let's define the local tp_len as u32 in tpacket_parse_header().
[0]:
kernel BUG at net/socket.c:803!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 0 UID: 0 PID: 5628 Comm: syz-executor176 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026 RIP: 0010:sock_sendmsg_nosec+0x145/0x180 net/socket.c:803 Code: 06 67 48 0f b9 3a eb 95 e8 e8 3a 22 f8 48 89 df 4c 89 f6 4c 89 e2 4d 89 fb 2e e8 32 a5 5c 16 e9 51 ff ff ff e8 cc 3a 22 f8 90 <0f> 0b e8 c4 3a 22 f8 48 83 c3 18 48 89 d8 48 c1 e8 03 42 80 3c 28 RSP: 0018:ffffc90003aefb48 EFLAGS: 00010293 RAX: ffffffff89a578d4 RBX: ffff8880764c67c0 RCX: ffff88807fb23e80 RDX: 0000000000000000 RSI: 00000000fffffdef RDI: 00000000fffffdef RBP: 00000000fffffdef R08: ffffc90003aef747 R09: 1ffff9200075dee8 R10: dffffc0000000000 R11: fffff5200075dee9 R12: 0000000000000001 R13: dffffc0000000000 R14: ffffc90003aefbc0 R15: ffffffff8aac4310 FS: 000055559101b400(0000) GS:ffff888124ce0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000200000000210 CR3: 0000000073dca000 CR4: 00000000003526f0 Call Trace: <TASK> __sock_sendmsg net/socket.c:815 [inline] sock_write_iter+0x2de/0x3e0 net/socket.c:1266 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x612/0xba0 fs/read_write.c:687 ksys_write+0x150/0x270 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f173130ecb9 Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 d8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd67e44248 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000200000000000 RCX: 00007f173130ecb9 RDX: 0000000000000001 RSI: 0000200000000000 RDI: 0000000000000003 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd67e44388 R13: 0000000000000002 R14: 00002000000000c0 R15: 0000000000000002 </TASK>
--- net/packet/af_packet.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/packet/af_packet.c +3 -2
@@ -2725,7 +2725,8 @@ static int tpacket_parse_header(struct packet_sock *po, void *frame, int size_max, void **data) { union tpacket_uhdr ph; -int tp_len, off; +u32 tp_len; +int off; ph.raw = frame;
@@ -2745,7 +2746,7 @@ static int tpacket_parse_header(struct packet_sock *po, void *frame,break ; }if (unlikely (tp_len > size_max)) { -pr_err ("packet size is too long (%d > %d)\n" , tp_len, size_max); +pr_err ("packet size is too long (%u > %d)\n" , tp_len, size_max);return -EMSGSIZE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/1193 staging: fbtft: make dirty_lock IRQ-safe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Su <[email protected]>
[ Upstream commit f576944a59f31bcffff121117ebf452c5dd162b7 ]
fbtft_mkdirty() can be reached from the fbcon rendering path while processing printk() in hardirq context. Meanwhile, dirty_lock is also taken by fbtft_deferred_io() in workqueue context with local interrupts enabled.
Lockdep reports a possible IRQ lock inversion involving dirty_lock and console_owner. A hardirq can interrupt a CPU holding dirty_lock and enter the console rendering path, which can attempt to acquire dirty_lock again.
The following lockdep report was observed on an RK3566 system with CONFIG_PROVE_LOCKING enabled:
WARNING: possible irq lock inversion dependency detected swapper/2/0 just changed the state of lock:
(console_owner){-...}-{0:0}
but this lock took another, HARDIRQ-unsafe lock in the past:
(&par->dirty_lock){+.+.}-{2:2}
CPU0 CPU1
---- ----
lock(&par->dirty_lock);
local_irq_disable();
lock(console_owner);
lock(&par->dirty_lock);
<Interrupt>
lock(console_owner);*** DEADLOCK ***
Use spin_lock_irqsave() for fbtft_mkdirty() and spin_lock_irq() for fbtft_deferred_io(). They only access the dirty line range, so the IRQ-off regions remain short.
--- drivers/staging/fbtft/fbtft-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/fbtft/fbtft-core.c +5 -4
@@ -302,6 +302,7 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height) {struct fbtft_par *par = info->par;struct fb_deferred_io *fbdefio = info->fbdefio; +unsigned long flags;/* special case, needed ? */ if (y ==-1 ) {
@@ -310,12 +311,12 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height) }/* Mark display lines/area as dirty */ -spin_lock (&par->dirty_lock); +spin_lock_irqsave (&par->dirty_lock, flags);if (y < par->dirty_lines_start) par->dirty_lines_start = y;if (y + height -1 > par->dirty_lines_end) par->dirty_lines_end = y + height -1 ; -spin_unlock (&par->dirty_lock); +spin_unlock_irqrestore (&par->dirty_lock, flags);/* Schedule deferred_io to update display (no-op if already on queue)*/ schedule_delayed_work (&info->deferred_work, fbdefio->delay);
@@ -329,13 +330,13 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflisunsigned int y_low =0 , y_high =0 ;int count =0 ; -spin_lock (&par->dirty_lock); +spin_lock_irq (&par->dirty_lock); dirty_lines_start = par->dirty_lines_start; dirty_lines_end = par->dirty_lines_end;/* set display line markers as clean */ par->dirty_lines_start = par->info->var.yres -1 ; par->dirty_lines_end =0 ; -spin_unlock (&par->dirty_lock); +spin_unlock_irq (&par->dirty_lock);/* Mark display lines as dirty */ list_for_each_entry (pageref, pagereflist, list) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/1193 ALSA: hda/core: Use guard() for mutex locks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 0a930d8732fc076600c4b346a83d9b0a190aeaf0 ]
Replace the manual mutex lock/unlock pairs with guard().
Only code refactoring, and no behavior change.
Stable-dep-of: 32d7226e6105 ("ALSA: hda: restore MFG widget enumeration after core split")
--- sound/hda/ext/hdac_ext_controller.c | 6 ++--- sound/hda/hdac_bus.c | 8 ++----- sound/hda/hdac_component.c | 6 ++--- sound/hda/hdac_device.c | 23 +++++++++---------- sound/hda/hdac_regmap.c | 35 +++++++++-------------------- 5 files changed, 27 insertions(+), 51 deletions(-)
sound/hda/ext/hdac_ext_controller.c +2 -4
@@ -281,7 +281,7 @@ int snd_hdac_ext_bus_link_get(struct hdac_bus *bus,unsigned long codec_mask;int ret =0 ; -mutex_lock (&bus->lock); +guard (mutex)(&bus->lock);/* * if we move from 0 to 1, count will be 1 so power up this link
@@ -312,7 +312,6 @@ int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, bus->codec_mask = codec_mask; } -mutex_unlock (&bus->lock);return ret; }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_link_get);
@@ -324,7 +323,7 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus,struct hdac_ext_link *hlink_tmp;bool link_up = false; -mutex_lock (&bus->lock); +guard (mutex)(&bus->lock);/* * if we move from 1 to 0, count will be 0
@@ -350,7 +349,6 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, } } -mutex_unlock (&bus->lock);return ret; }EXPORT_SYMBOL_GPL (snd_hdac_ext_bus_link_put);
sound/hda/hdac_bus.c +2 -6
@@ -87,12 +87,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_exit);int snd_hdac_bus_exec_verb (struct hdac_bus *bus,unsigned int addr,unsigned int cmd,unsigned int *res) { -int err; - -mutex_lock (&bus->cmd_mutex); - err =snd_hdac_bus_exec_verb_unlocked (bus, addr, cmd, res); -mutex_unlock (&bus->cmd_mutex); -return err; +guard (mutex)(&bus->cmd_mutex); +return snd_hdac_bus_exec_verb_unlocked (bus, addr, cmd, res); }/**
sound/hda/hdac_component.c +2 -4
@@ -70,14 +70,14 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)dev_dbg (bus->dev,"display power %s\n" , enable ?"enable" :"disable" ); -mutex_lock (&bus->lock); +guard (mutex)(&bus->lock);if (enable)set_bit (idx, &bus->display_power_status);else clear_bit (idx, &bus->display_power_status);if (!acomp || !acomp->ops) - goto unlock; +return ;if (bus->display_power_status) {if (!bus->display_power_active) {
@@ -100,8 +100,6 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable) bus->display_power_active =0 ; } } - unlock: -mutex_unlock (&bus->lock); }EXPORT_SYMBOL_GPL (snd_hdac_display_power);
sound/hda/hdac_device.c +10 -13
@@ -146,9 +146,9 @@ int snd_hdac_device_register(struct hdac_device *codec) err =device_add (&codec->dev);if (err <0 )return err; -mutex_lock (&codec->widget_lock); - err =hda_widget_sysfs_init (codec); -mutex_unlock (&codec->widget_lock); + scoped_guard(mutex, &codec->widget_lock) { + err =hda_widget_sysfs_init (codec); + }if (err <0 ) {device_del (&codec->dev);return err;
@@ -165,9 +165,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_register);void snd_hdac_device_unregister (struct hdac_device *codec) {if (device_is_registered (&codec->dev)) { -mutex_lock (&codec->widget_lock); -hda_widget_sysfs_exit (codec); -mutex_unlock (&codec->widget_lock); + scoped_guard(mutex, &codec->widget_lock) { +hda_widget_sysfs_exit (codec); + }device_del (&codec->dev);snd_hdac_bus_remove_device (codec->bus, codec); }
@@ -410,25 +410,22 @@ int snd_hdac_refresh_widgets(struct hdac_device *codec)* Serialize against multiple threads trying to update the sysfs * widgets array. */ -mutex_lock (&codec->widget_lock); +guard (mutex)(&codec->widget_lock); nums =snd_hdac_get_sub_nodes (codec, codec->afg, &start_nid);if (!start_nid || nums <=0 || nums >=0xff ) {dev_err (&codec->dev,"cannot read sub nodes for FG 0x%02x\n" , codec->afg); - err = -EINVAL ; - goto unlock; +return -EINVAL ; } err =hda_widget_sysfs_reinit (codec, start_nid, nums);if (err <0 ) - goto unlock; +return err; codec->num_nodes = nums; codec->start_nid = start_nid; codec->end_nid = start_nid + nums; -unlock: -mutex_unlock (&codec->widget_lock); -return err; +return 0 ; }EXPORT_SYMBOL_GPL (snd_hdac_refresh_widgets);
sound/hda/hdac_regmap.c +11 -24
@@ -425,15 +425,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_add_vendor_verb);static int reg_raw_write (struct hdac_device *codec,unsigned int reg,unsigned int val) { -int err; - -mutex_lock (&codec->regmap_lock); +guard (mutex)(&codec->regmap_lock);if (!codec->regmap) - err =hda_reg_write (codec, reg, val); +return hda_reg_write (codec, reg, val);else - err =regmap_write (codec->regmap, reg, val); -mutex_unlock (&codec->regmap_lock); -return err; +return regmap_write (codec->regmap, reg, val); }/* a helper macro to call @func_call; retry with power-up if failed */
@@ -466,15 +462,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_write_raw);static int reg_raw_read (struct hdac_device *codec,unsigned int reg,unsigned int *val,bool uncached) { -int err; - -mutex_lock (&codec->regmap_lock); +guard (mutex)(&codec->regmap_lock);if (uncached || !codec->regmap) - err =hda_reg_read (codec, reg, val); +return hda_reg_read (codec, reg, val);else - err =regmap_read (codec->regmap, reg, val); -mutex_unlock (&codec->regmap_lock); -return err; +return regmap_read (codec->regmap, reg, val); } static int __snd_hdac_regmap_read_raw(struct hdac_device *codec,
@@ -515,7 +507,7 @@ static int reg_raw_update(struct hdac_device *codec, unsigned int reg,bool change;int err; -mutex_lock (&codec->regmap_lock); +guard (mutex)(&codec->regmap_lock);if (codec->regmap) { err =regmap_update_bits_check (codec->regmap, reg, mask, val, &change);
@@ -533,7 +525,6 @@ static int reg_raw_update(struct hdac_device *codec, unsigned int reg, } } } -mutex_unlock (&codec->regmap_lock);return err; }
@@ -556,17 +547,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw);static int reg_raw_update_once (struct hdac_device *codec,unsigned int reg,unsigned int mask,unsigned int val) { -int err =0 ; -if (!codec->regmap)return reg_raw_update (codec, reg, mask, val); -mutex_lock (&codec->regmap_lock); +guard (mutex)(&codec->regmap_lock);/* Discard any updates to already initialised registers. */ if (!regcache_reg_cached (codec->regmap, reg)) - err =regmap_update_bits (codec->regmap, reg, mask, val); -mutex_unlock (&codec->regmap_lock); -return err; +return regmap_update_bits (codec->regmap, reg, mask, val); +return 0 ; }/**
@@ -593,9 +581,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once);*/ void snd_hdac_regmap_sync (struct hdac_device *codec) { -mutex_lock (&codec->regmap_lock); +guard (mutex)(&codec->regmap_lock);if (codec->regmap)regcache_sync (codec->regmap); -mutex_unlock (&codec->regmap_lock); }EXPORT_SYMBOL_GPL (snd_hdac_regmap_sync);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/1193 ALSA: hda: restore MFG widget enumeration after core split
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <[email protected]>
[ Upstream commit 32d7226e6105c257ef7b3d0ec819f11a81f53b6d ]
Before commit 7639a06c23c7 ("ALSA: hda - Move a part of hda_codec stuff into hdac_device"), widget enumeration selected the function group with
codec->afg ? codec->afg : codec->mfg
and read subordinate nodes from that group.
The core split moved this logic into snd_hdac_refresh_widgets(), but hard-coded codec->afg there. For an MFG-only codec, codec->afg is zero, so the Root Node is queried and codec->start_nid/num_nodes are populated from the function-group range instead of the MFG's subordinate nodes.
Restore the pre-split AFG-or-MFG selection.
--- sound/hda/hdac_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/hda/hdac_device.c +3 -2
@@ -403,6 +403,7 @@ static void setup_fg_nodes(struct hdac_device *codec)*/ int snd_hdac_refresh_widgets (struct hdac_device *codec) { +hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;hda_nid_t start_nid;int nums, err =0 ;
@@ -411,10 +412,10 @@ int snd_hdac_refresh_widgets(struct hdac_device *codec)* widgets array. */ guard (mutex)(&codec->widget_lock); - nums =snd_hdac_get_sub_nodes (codec, codec->afg, &start_nid); + nums =snd_hdac_get_sub_nodes (codec, fg, &start_nid);if (!start_nid || nums <=0 || nums >=0xff ) {dev_err (&codec->dev,"cannot read sub nodes for FG 0x%02x\n" , - codec->afg); + fg);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/1193 s390/boot: Fix physical memory search range
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
[ Upstream commit a0c798ed4103316c23938bdf625af364fbd38016 ]
search_mem_end() calculates the number of 1MB blocks with a signed int literal. CONFIG_MAX_PHYSMEM_BITS values of 51 and above either overflow the signed int or shift beyond its width. This produces an invalid search range when the binary-search memory detection fallback is used.
Use an unsigned long literal so the full supported physical address range is represented.
--- arch/s390/boot/physmem_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/boot/physmem_info.c +1 -1
@@ -140,7 +140,7 @@ static int tprot(unsigned long addr)static unsigned long search_mem_end (void ) { -unsigned long range =1 << (MAX_PHYSMEM_BITS -20 );/* in 1MB blocks */ +unsigned long range =1UL << (MAX_PHYSMEM_BITS -20 );/* in 1MB blocks */ unsigned long offset =0 ;unsigned long pivot;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/1193 ASoC: amd: renoir: fix disable_pdm_interrupts() to clear mask bits
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
[ Upstream commit 0c06c4ce0206290c9a934a1e7196aaa86adfe018 ]
disable_pdm_interrupts() uses |= ~PDM_DMA_INTR_MASK which sets all bits except the PDM DMA interrupt bit instead of clearing only the PDM DMA interrupt bit. Use &= ~PDM_DMA_INTR_MASK to clear only the target bit.
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +1 -1
@@ -104,7 +104,7 @@ static void disable_pdm_interrupts(void __iomem *acp_base)u32 ext_int_ctrl; ext_int_ctrl =rn_readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); - ext_int_ctrl |= ~PDM_DMA_INTR_MASK ; + ext_int_ctrl &= ~PDM_DMA_INTR_MASK ;rn_writel (ext_int_ctrl, acp_base +ACP_EXTERNAL_INTR_CNTL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/1193 ASoC: amd: yc: fix memory leak in acp6x_pdm_dma_close()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
[ Upstream commit 1b67e0d3b9691d7b6b74e18960ddd2be24f9dc9d ]
acp6x_pdm_dma_close() does not free the runtime->private_data buffer allocated in acp6x_pdm_dma_open(). Add the missing kfree.
--- sound/soc/amd/yc/acp6x-pdm-dma.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/amd/yc/acp6x-pdm-dma.c +2 -0
@@ -275,9 +275,11 @@ static int acp6x_pdm_dma_close(struct snd_soc_component *component, struct snd_pcm_substream *substream) {struct pdm_dev_data *adata =dev_get_drvdata (component->dev); +struct snd_pcm_runtime *runtime = substream->runtime;acp6x_disable_pdm_interrupts (adata->acp6x_base); adata->capture_stream =NULL ; +kfree (runtime->private_data);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/1193 btrfs: detach failed sprout device from transaction update list
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit c93b3c43df561cd9f592cee20ae058b563f9e5b6 ]
When creating the first metadata chunk for a sprout filesystem, create_chunk() adds the new device to the transaction dev_update_list through device->post_commit_list.
If the subsequent system chunk creation fails, btrfs_init_new_device() aborts the transaction and releases the device while post_commit_list is still linked. This triggers a warning in btrfs_free_device() and leaves the transaction list referencing freed memory.
Detach the device while holding chunk_mutex before releasing it.
--- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/volumes.c +2 -0
@@ -2865,6 +2865,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathbtrfs_sysfs_remove_device (device);mutex_lock (&fs_info->fs_devices->device_list_mutex);mutex_lock (&fs_info->chunk_mutex); +if (!list_empty (&device->post_commit_list)) +list_del_init (&device->post_commit_list);list_del_rcu (&device->dev_list);list_del (&device->dev_alloc_list); fs_info->fs_devices->num_devices--;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/1193 btrfs: restore active device pointers after failed sprout
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit e0b54613aabeb8e9da597f23b90c6a03d0981986 ]
btrfs_init_new_device() switches latest_dev and possibly s_bdev from the seed device to the new sprout device before creating the first writable chunks.
If chunk creation or the subsequent sprout setup fails, the error path releases the new device without switching those pointers back. btrfs_show_devname() can then dereference the freed latest_dev and crash.
Restore the active device pointers to the latest seed device before removing and releasing the failed sprout device.
--- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/volumes.c +2 -0
@@ -2864,6 +2864,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path error_sysfs:btrfs_sysfs_remove_device (device);mutex_lock (&fs_info->fs_devices->device_list_mutex); +if (seeding_dev) +btrfs_assign_next_active_device (device, seed_devices->latest_dev);mutex_lock (&fs_info->chunk_mutex);if (!list_empty (&device->post_commit_list))list_del_init (&device->post_commit_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/1193 bonding: alb: fix uninitialized transport header access in alb_determine_nd()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 70f3995830d3f1e79faa14eb0605914f778feca9 ]
alb_determine_nd() uses icmp6_hdr(skb) to inspect ICMPv6 headers. However, in xmit paths (e.g. packets sent via AF_PACKET / raw sockets or forwarded packets), skb->transport_header is not guaranteed to be initialized. While pskb_network_may_pull() ensures the packet data is linear starting from the network header, it does not set or adjust the transport header offset.
Dereferencing icmp6_hdr(skb) can therefore access out-of-bounds memory.
Fetch the icmp6hdr directly after ipv6hdr following pskb_network_may_pull(), and reload ipv6hdr in case pskb_may_pull() reallocated skb->head. Also remove the unused bond argument from alb_determine_nd().
--- drivers/net/bonding/bond_alb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/bonding/bond_alb.c +7 -6
@@ -1282,10 +1282,10 @@ static int alb_set_mac_address(struct bonding *bond, void *addr) }/* determine if the packet is NA or NS */ -static bool alb_determine_nd (struct sk_buff *skb,struct bonding *bond) +static bool alb_determine_nd (struct sk_buff *skb) { -struct ipv6hdr *ip6hdr; -struct icmp6hdr *hdr; +const struct ipv6hdr *ip6hdr; +const struct icmp6hdr *hdr;if (!pskb_network_may_pull (skb,sizeof (*ip6hdr)))return true;
@@ -1297,7 +1297,8 @@ static bool alb_determine_nd(struct sk_buff *skb, struct bonding *bond)if (!pskb_network_may_pull (skb,sizeof (*ip6hdr) +sizeof (*hdr)))return true; - hdr =icmp6_hdr (skb); + ip6hdr =ipv6_hdr (skb); + hdr = (const struct icmp6hdr *)(ip6hdr +1 );return hdr->icmp6_type ==NDISC_NEIGHBOUR_ADVERTISEMENT || hdr->icmp6_type ==NDISC_NEIGHBOUR_SOLICITATION ; }
@@ -1382,7 +1383,7 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,if (!is_multicast_ether_addr (eth_data->h_dest)) {switch (skb->protocol) {case htons (ETH_P_IPV6 ): -if (alb_determine_nd (skb, bond)) +if (alb_determine_nd (skb))break ; fallthrough;case htons (ETH_P_IP ):
@@ -1468,7 +1469,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,break ; } -if (alb_determine_nd (skb, bond)) { +if (alb_determine_nd (skb)) { do_tx_balance = false;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/1193 scsi: mpt3sas: Avoid out-of-bounds cpumask_of_node() call in _base_assign_reply_queues()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivy Lopez <[email protected]>
[ Upstream commit e0d26fe176a8db6ccad4ab38c5bab29391c1946b ]
dev_to_node() can return NUMA_NO_NODE (-1) on systems without NUMA topology information for the PCI device, such as single-socket boards that don't expose device-to-node affinity. Passing -1 directly into cpumask_of_node() indexes node_to_cpumask_map[-1], an out-of-bounds array read caught by UBSAN:
UBSAN: array-index-out-of-bounds in arch/x86/include/asm/topology.h:72:28 index -1 is out of range for type 'cpumask *[1024]'
Fall back to cpu_online_mask when no NUMA node is available, rather than assuming dev_to_node() always returns a valid node index.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +4 -1
@@ -3227,7 +3227,10 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)* corresponding to high iops queues. */ if (ioc->high_iops_queues) { - mask =cpumask_of_node (dev_to_node (&ioc->pdev->dev)); +int node =dev_to_node (&ioc->pdev->dev); + + mask = (node ==NUMA_NO_NODE ) ? + cpu_online_mask :cpumask_of_node (node);for (index =0 ; index < ioc->high_iops_queues; index++) { irq =pci_irq_vector (ioc->pdev, index);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/1193 perf/core: Skip empty AUX records with only format flags
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 8a7f5b5e860b5c113ca99acd5b1e9074f5c5af3c ]
perf_aux_output_end() emits a PERF_RECORD_AUX when the recorded size is nonzero or when any flag other than PERF_AUX_FLAG_OVERWRITE is set.
PMU format flags describe how an AUX payload is encoded. TRBE driver sets PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW for raw trace buffers, causing an AUX record to be emitted even when no trace data.
This is noticeable when tracing a task with strace. Ptrace stops repeatedly end empty AUX transactions, producing many zero-sized PERF_RECORD_AUX records. For example:
perf record -e cs_etm//u -m,128M -- strace ls
perf script -D 2>&1 |
awk '/PERF_RECORD_AUX offset/ {
for (i = 1; i <= NF; i++)
if ($i == "size:" && $(i + 1) == "0")
count++
}
END { print count }'
165This recording contains 165 zero-sized AUX records which provide no useful information to userspace.
Ignore PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK, together with PERF_AUX_FLAG_OVERWRITE, when deciding whether an empty AUX record is useful. Zero-sized records carrying TRUNCATED, PARTIAL or COLLISION are still emitted.
--- kernel/events/ring_buffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/events/ring_buffer.c +7 -2
@@ -503,7 +503,10 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)/* * Only send RECORD_AUX if we have something useful to communicate * -* Note: the OVERWRITE records by themselves are not considered +* PMU_FORMAT bits identify the PMU type rather than an AUX event +* has occurred, so ignore them for zero-sized records. +* +* The OVERWRITE records by themselves are not considered * useful, as they don't communicate any *new* information, * aside from the short-lived offset, that becomes history at * the next event sched-in and therefore isn't useful.
@@ -512,7 +515,9 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)* offset. So, from now on we don't output AUX records that * have *only* OVERWRITE flag set. */ -if (size || (handle->aux_flags & ~(u64 )PERF_AUX_FLAG_OVERWRITE )) +if (size || + (handle->aux_flags & ~(u64)(PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK | +PERF_AUX_FLAG_OVERWRITE )))perf_event_aux_event (handle->event, aux_head, size, handle->aux_flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/1193 locking/lockdep: Invalidate stale class_cache entries for zapped classes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 02c6be7d675b21d81f0ba3a524346850a8c0e3bf ]
syzbot reported a lockdep splat hitting DEBUG_LOCKS_WARN_ON(1) in hlock_class() due to an invalid class_idx:
WARNING: kernel/locking/lockdep.c:238 at __lock_acquire+0x382/0x2cf0 kernel/locking/lockdep.c:5203 Workqueue: wg-crypt-wg0 wg_packet_tx_worker RIP: 0010:hlock_class kernel/locking/lockdep.c:238 [inline] RIP: 0010:check_wait_context kernel/locking/lockdep.c:4870 [inline] RIP: 0010:__lock_acquire+0x389/0x2cf0 kernel/locking/lockdep.c:5203 Call Trace: <IRQ> lock_acquire+0x106/0x350 kernel/locking/lockdep.c:5886 _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:173 tcp_tsq_handler+0x29/0x200 net/ipv4/tcp_output.c:1291 tcp_tsq_workfn+0x384/0x410 net/ipv4/tcp_output.c:1325 ...
When a lock class is zapped (e.g. during module unload or key unregistration), zap_class() clears the class's bit in lock_classes_in_use and removes it from the class hash table. However, existing lockdep_map instances embedded in data structures may still retain a pointer to the zapped class in their class_cache[] array.
When __lock_acquire() subsequently runs on such a lock, it finds lock->class_cache[subclass] != NULL, skipping register_lock_class() and assigning hlock->class_idx to the index of the zapped class. When check_wait_context() or hlock_class() inspects the held_lock, it finds !test_bit(class_idx, lock_classes_in_use) and warns. Furthermore, if the zapped slot is subsequently re-allocated to an unrelated lock key, the stale class_cache entry would erroneously match the unrelated class (ABA issue).
Add lock_class_cache_is_valid() to validate that the cached class is within lock_classes bounds, still allocated in lock_classes_in_use (using uninstrumented arch_test_bit() in __always_inline context so it is safe in noinstr contexts like match_held_lock()), and that class->key matches the expected subkey (taking lockdep_set_subclass() overrides into account). Also use READ_ONCE()/WRITE_ONCE() when accessing class_cache[]. If the entry is invalid or stale, fall back to register_lock_class() / look_up_lock_class().
--- kernel/locking/lockdep.c | 50 +++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-)
kernel/locking/lockdep.c +42 -8
@@ -940,6 +940,34 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)return NULL ; } +static __always_inline bool lock_class_cache_is_valid(const struct lockdep_map *lock, +const struct lock_class *class, +unsigned int subclass) +{ +unsigned int class_subclass; + +if (!class) +return false; + +if (unlikely (class < lock_classes || class >= lock_classes +MAX_LOCKDEP_KEYS )) +return false; + +if (unlikely (!arch_test_bit (class - lock_classes, lock_classes_in_use))) +return false; + +if (unlikely (!lock->key)) +return false; + + class_subclass = subclass ? subclass : class->subclass; +if (unlikely (class_subclass >=MAX_LOCKDEP_SUBCLASSES )) +return false; + +if (unlikely (READ_ONCE (class->key) != lock->key->subkeys + class_subclass)) +return false; + +return true; +} +/* * Static locks do not have their class-keys yet - for them the key is * the lock object itself. If the lock is in the per cpu area, the
@@ -1365,9 +1393,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force) out_set_class_cache:if (!subclass || force) - lock->class_cache[0 ] = class; +WRITE_ONCE (lock->class_cache[0 ], class);else if (subclass <NR_LOCKDEP_CACHING_CLASSES ) - lock->class_cache[subclass] = class; +WRITE_ONCE (lock->class_cache[subclass], class);/* * Hash collision, did we smoke some? We found a class with a matching
@@ -4860,7 +4888,7 @@ void lockdep_init_map_type(struct lockdep_map *lock, const char *name,int i;for (i =0 ; i <NR_LOCKDEP_CACHING_CLASSES ; i++) - lock->class_cache[i] =NULL ; +WRITE_ONCE (lock->class_cache[i],NULL );#ifdef CONFIG_LOCK_STAT lock->cpu =raw_smp_processor_id ();
@@ -4922,12 +4950,15 @@ EXPORT_SYMBOL_GPL(__lockdep_no_validate__);void lockdep_set_lock_cmp_fn (struct lockdep_map *lock,lock_cmp_fn cmp_fn,lock_print_fn print_fn) { -struct lock_class *class = lock->class_cache[0 ]; +struct lock_class *class =READ_ONCE (lock->class_cache[0 ]);unsigned long flags;raw_local_irq_save (flags);lockdep_recursion_inc (); +if (!lock_class_cache_is_valid (lock, class,0 )) + class =NULL ; +if (!class) class =register_lock_class (lock,0 ,0 );
@@ -5005,8 +5036,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,if (!prove_locking || lock->key == &__lockdep_no_validate__) check =0 ; -if (subclass <NR_LOCKDEP_CACHING_CLASSES ) - class = lock->class_cache[subclass]; +if (subclass <NR_LOCKDEP_CACHING_CLASSES ) { + class =READ_ONCE (lock->class_cache[subclass]); +if (!lock_class_cache_is_valid (lock, class, subclass)) + class =NULL ; + }/* * Not cached? */
@@ -5201,9 +5235,9 @@ static noinstr int match_held_lock(const struct held_lock *hlock,return 1 ;if (hlock->references) { -const struct lock_class *class = lock->class_cache[0 ]; +const struct lock_class *class =READ_ONCE (lock->class_cache[0 ]); -if (!class) +if (!lock_class_cache_is_valid (lock, class,0 )) class =look_up_lock_class (lock,0 );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/1193 ALSA: rawmidi: Expose the tied device number in info ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit bdf46443f350dd5d226fd528a5a5954ff762f591 ]
The UMP legacy rawmidi is derived from the UMP rawmidi, but currently there is no way to know which device is involved in other side.
This patch extends the rawmidi info ioctl to show the tied device number. As default it stores -1, indicating that no tied device.
Stable-dep-of: adeee7187694 ("ALSA: ump: do not touch legacy_rmidi before it exists")
--- Documentation/sound/designs/midi-2.0.rst | 5 +++++ include/sound/rawmidi.h | 1 + include/uapi/sound/asound.h | 5 ++++- sound/core/rawmidi.c | 2 ++ sound/core/ump.c | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-)
Documentation/sound/designs/midi-2.0.rst +5 -0
@@ -293,6 +293,11 @@ Rawmidi API Extensions status 0x05). When UMP core receives such a message, it updates the UMP EP info and the corresponding sequencer clients as well. +* The legacy rawmidi device number is found in the new `tied_device` + field of the rawmidi info. + On the other hand, the UMP rawmidi device number is found in + `tied_device` field of the legacy rawmidi info, too. + Control API Extensions ======================
include/sound/rawmidi.h +1 -0
@@ -118,6 +118,7 @@ struct snd_rawmidi {struct list_head list;unsigned int device;/* device number */ unsigned int info_flags;/* SNDRV_RAWMIDI_INFO_XXXX */ +unsigned int tied_device;char id[64 ];char name[80 ];
include/uapi/sound/asound.h +4 -1
@@ -725,6 +725,8 @@ enum {#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004#define SNDRV_RAWMIDI_INFO_UMP 0x00000008 +#define SNDRV_RAWMIDI_DEVICE_UNKNOWN -1 +struct snd_rawmidi_info {unsigned int device;/* RO/WR (control): device number */ unsigned int subdevice;/* RO/WR (control): subdevice number */
@@ -736,7 +738,8 @@ struct snd_rawmidi_info {unsigned char subname[32 ];/* name of active or selected subdevice */ unsigned int subdevices_count;unsigned int subdevices_avail; -unsigned char reserved[64 ];/* reserved for future use */ +int tied_device;/* R: tied rawmidi device (UMP/legacy) */ +unsigned char reserved[60 ];/* reserved for future use */ };#define SNDRV_RAWMIDI_MODE_FRAMING_MASK (7<<0)
sound/core/rawmidi.c +2 -0
@@ -651,6 +651,7 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, info->subdevices_count = substream->pstr->substream_count; info->subdevices_avail = (substream->pstr->substream_count - substream->pstr->substream_opened); + info->tied_device = rmidi->tied_device;return 0 ; }
@@ -1897,6 +1898,7 @@ int snd_rawmidi_init(struct snd_rawmidi *rmidi,INIT_LIST_HEAD (&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT ].substreams);INIT_LIST_HEAD (&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT ].substreams); rmidi->info_flags = info_flags; + rmidi->tied_device =SNDRV_RAWMIDI_DEVICE_UNKNOWN ;if (id !=NULL )strscpy (rmidi->id, id,sizeof (rmidi->id));
sound/core/ump.c +3 -0
@@ -1304,6 +1304,9 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump, ump->legacy_rmidi = rmidi;update_legacy_names (ump); + rmidi->tied_device = ump->core.device; + ump->core.tied_device = rmidi->device; +ump_dbg (ump,"Created a legacy rawmidi #%d (%s)\n" , device, id);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/1193 ALSA: rawmidi: Show substream activity in info ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b8fefed73a952a33521ad416fb39683abd87454b ]
The UMP legacy rawmidi may turn on/off the substream dynamically depending on the UMP Function Block information. So far, there was no direct way to know whether the substream is disabled (inactive) or not; at most one can take a look at the substream name string or try to open and get -ENODEV.
This patch extends the rawmidi info ioctl to show the current inactive state of the given substream. When the selected substream is inactive, info flags field contains the new bit flag SNDRV_RAWMIDI_INFO_STREAM_INACTIVE.
Stable-dep-of: adeee7187694 ("ALSA: ump: do not touch legacy_rmidi before it exists")
--- Documentation/sound/designs/midi-2.0.rst | 6 ++++++ include/sound/rawmidi.h | 1 + include/uapi/sound/asound.h | 1 + sound/core/rawmidi.c | 2 ++ sound/core/ump.c | 9 +++++---- 5 files changed, 15 insertions(+), 4 deletions(-)
Documentation/sound/designs/midi-2.0.rst +6 -0
@@ -298,6 +298,12 @@ Rawmidi API Extensions On the other hand, the UMP rawmidi device number is found in `tied_device` field of the legacy rawmidi info, too. +* Each substream of the legacy rawmidi may be enabled / disabled + dynamically depending on the UMP FB state. + When the selected substream is inactive, it's indicated by the bit + 0x10 (`SNDRV_RAWMIDI_INFO_STREAM_INACTIVE`) in the `flags` field of + the legacy rawmidi info. + Control API Extensions ======================
include/sound/rawmidi.h +1 -0
@@ -89,6 +89,7 @@ struct snd_rawmidi_substream {unsigned int framing;/* whether to frame input data */ unsigned int clock_type;/* clock source to use for input framing */ int use_count;/* use counter (for output) */ +bool inactive;/* inactive substream (for UMP legacy) */ size_t bytes;spinlock_t lock;struct snd_rawmidi *rmidi;
include/uapi/sound/asound.h +1 -0
@@ -724,6 +724,7 @@ enum {#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004#define SNDRV_RAWMIDI_INFO_UMP 0x00000008 +#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010#define SNDRV_RAWMIDI_DEVICE_UNKNOWN -1
sound/core/rawmidi.c +2 -0
@@ -645,6 +645,8 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, info->subdevice = substream->number; info->stream = substream->stream; info->flags = rmidi->info_flags; +if (substream->inactive) + info->flags |=SNDRV_RAWMIDI_INFO_STREAM_INACTIVE ;strcpy (info->id, rmidi->id);strcpy (info->name, rmidi->name);strcpy (info->subname, substream->name);
sound/core/ump.c +5 -4
@@ -1239,8 +1239,8 @@ static int fill_legacy_mapping(struct snd_ump_endpoint *ump)return num; } -static void fill_substream_names (struct snd_ump_endpoint *ump, -struct snd_rawmidi *rmidi,int dir) +static void update_legacy_substreams (struct snd_ump_endpoint *ump, +struct snd_rawmidi *rmidi,int dir) {struct snd_rawmidi_substream *s;const char *name;
@@ -1254,6 +1254,7 @@ static void fill_substream_names(struct snd_ump_endpoint *ump,scnprintf (s->name,sizeof (s->name),"Group %d (%.16s)%s" , idx +1 , name, ump->groups[idx].active ?"" :" [Inactive]" ); + s->inactive = !ump->groups[idx].active; } }
@@ -1261,8 +1262,8 @@ static void update_legacy_names(struct snd_ump_endpoint *ump) {struct snd_rawmidi *rmidi = ump->legacy_rmidi; -fill_substream_names (ump, rmidi,SNDRV_RAWMIDI_STREAM_INPUT ); -fill_substream_names (ump, rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT ); +update_legacy_substreams (ump, rmidi,SNDRV_RAWMIDI_STREAM_INPUT ); +update_legacy_substreams (ump, rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT ); } int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/1193 ALSA: ump: Copy FB name string more safely
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e3f035edadcc1c5901311c03d098bc3dedc5c525 ]
The UMP group names are referred as the corresponding sequencer port names, hence they should be proper ASCII strings. OTOH, the UMP group names are composed from the UMP FB strings that are received from the device; i.e. a device may give some bogus letters and we can't trust them fully.
To assure that the group names consist of the proper ASCII strings, replace the normal string copy and append operations with special ones that strip the non-printable letters.
Stable-dep-of: adeee7187694 ("ALSA: ump: do not touch legacy_rmidi before it exists")
--- sound/core/ump.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-)
sound/core/ump.c +31 -9
@@ -53,6 +53,34 @@ static inline void update_legacy_names(struct snd_ump_endpoint *ump) }#endif +/* copy a string safely with stripping non-printable letters */ +static void safe_copy_string (void *dst,size_t max_dst_size, +const void *src,size_t max_src_size) +{ +const unsigned char *s = src; +unsigned char *d = dst; + +if (!max_dst_size--) +return ; +for (s = src; max_dst_size && *s && max_src_size--; s++) { +if (!isascii (*s) || !isprint (*s)) +continue ; + *d++ = *s; + max_dst_size--; + } + *d =0 ; +} + +/* append a string safely with stripping non-printable letters */ +static void safe_append_string (void *dst,size_t max_dst_size, +const void *src,size_t max_src_size) +{ +unsigned char *d = dst; +size_t len =strlen (d); + +safe_copy_string (d + len, max_dst_size - len, src, max_src_size); +} +static const struct snd_rawmidi_global_ops snd_ump_rawmidi_ops = { .dev_register = snd_ump_dev_register, .dev_unregister = snd_ump_dev_unregister,
@@ -566,16 +594,10 @@ void snd_ump_update_group_attrs(struct snd_ump_endpoint *ump) }if (!*fb->info.name)continue ; -if (!*group->name) { -/* store the first matching name */ -strscpy (group->name, fb->info.name, -sizeof (group->name)); - }else { -/* when overlapping, concat names */ +if (*group->name)strlcat (group->name,", " ,sizeof (group->name)); -strlcat (group->name, fb->info.name, -sizeof (group->name)); - } +safe_append_string (group->name,sizeof (group->name), + fb->info.name,sizeof (fb->info.name)); } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/1193 ALSA: ump: Copy safe string name to rawmidi
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 85e8d66f30f967cda91b3ee6dfcb0a0c2391e612 ]
The UMP helper didn't set up the rawmidi name string by itself but left it to the driver. But since the only user (USB MIDI2 driver) picks up the UMP info name string to the rawmidi name as default, it's better to set up in the UMP core side.
Meanwhile, UMP receives the EP name string from the device, and it might contain garbage letters. We should purify the string to be usable for the kernel as done previously for UMP Group names.
This implements the copy of the UMP info name string into the rawmidi name at the creation of UMP EP object in a safe way to strip the non-ASCII or non-printable characters. Also, change the reference from the legacy rawmidi and other places to rawmidi name field instead of ump info; this assures the sane strings.
Stable-dep-of: adeee7187694 ("ALSA: ump: do not touch legacy_rmidi before it exists")
--- sound/core/ump.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
sound/core/ump.c +11 -2
@@ -729,6 +729,13 @@ static int ump_handle_device_info_msg(struct snd_ump_endpoint *ump,return 1 ;/* finished */ } +/* set up the core rawmidi name from UMP EP name string */ +static void ump_set_rawmidi_name (struct snd_ump_endpoint *ump) +{ +safe_copy_string (ump->core.name,sizeof (ump->core.name), + ump->info.name,sizeof (ump->info.name)); +} +/* handle EP name stream message; update the UMP name string */ static int ump_handle_ep_name_msg (struct snd_ump_endpoint *ump,const union snd_ump_stream_msg *buf)
@@ -1056,6 +1063,8 @@ int snd_ump_parse_endpoint(struct snd_ump_endpoint *ump)if (err <0 )ump_dbg (ump,"Unable to get UMP EP name string\n" ); +ump_set_rawmidi_name (ump); +/* Request Endpoint Product ID */ err =ump_req_msg (ump, msg,UMP_STREAM_MSG_REQUEST_PRODUCT_ID ,UMP_STREAM_MSG_STATUS_PRODUCT_ID );
@@ -1272,7 +1281,7 @@ static void update_legacy_substreams(struct snd_ump_endpoint *ump, idx = ump->legacy_mapping[s->number]; name = ump->groups[idx].name;if (!*name) - name = ump->info.name; + name = ump->core.name;scnprintf (s->name,sizeof (s->name),"Group %d (%.16s)%s" , idx +1 , name, ump->groups[idx].active ?"" :" [Inactive]" );
@@ -1320,7 +1329,7 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_ump_legacy_output_ops);snprintf (rmidi->name,sizeof (rmidi->name),"%.68s (MIDI 1.0)" , - ump->info.name); + ump->core.name); rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP ; rmidi->ops = &snd_ump_legacy_ops; rmidi->private_data = ump;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/1193 ALSA: ump: Update rawmidi name per EP name update
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit aca565359596c5998cab1cc72f61aa83b3ccd152 ]
The rawmidi name string should be updated dynamically when the device receives the UMP EP name update, too. Both the core and legacy rawmidi names are updated.
Stable-dep-of: adeee7187694 ("ALSA: ump: do not touch legacy_rmidi before it exists")
--- sound/core/ump.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
sound/core/ump.c +23 -4
@@ -37,6 +37,7 @@ static int process_legacy_output(struct snd_ump_endpoint *ump, u32 *buffer, int count);static void process_legacy_input (struct snd_ump_endpoint *ump,const u32 *src,int words); +static void ump_legacy_set_rawmidi_name (struct snd_ump_endpoint *ump);static void update_legacy_names (struct snd_ump_endpoint *ump);#else static inline int process_legacy_output(struct snd_ump_endpoint *ump,
@@ -48,6 +49,9 @@ static inline void process_legacy_input(struct snd_ump_endpoint *ump, const u32 *src, int words) { } +static inline void ump_legacy_set_rawmidi_name (struct snd_ump_endpoint *ump) +{ +}static inline void update_legacy_names (struct snd_ump_endpoint *ump) { }
@@ -740,8 +744,16 @@ static void ump_set_rawmidi_name(struct snd_ump_endpoint *ump)static int ump_handle_ep_name_msg (struct snd_ump_endpoint *ump,const union snd_ump_stream_msg *buf) { -return ump_append_string (ump, ump->info.name,sizeof (ump->info.name), - buf->raw,2 ); +int ret; + + ret =ump_append_string (ump, ump->info.name,sizeof (ump->info.name), + buf->raw,2 ); +if (ret && ump->parsed) { +ump_set_rawmidi_name (ump); +ump_legacy_set_rawmidi_name (ump); + } + +return ret; }/* handle EP product id stream message; update the UMP product_id string */
@@ -1297,6 +1309,14 @@ static void update_legacy_names(struct snd_ump_endpoint *ump)update_legacy_substreams (ump, rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT ); } +static void ump_legacy_set_rawmidi_name (struct snd_ump_endpoint *ump) +{ +struct snd_rawmidi *rmidi = ump->legacy_rmidi; + +snprintf (rmidi->name,sizeof (rmidi->name),"%.68s (MIDI 1.0)" , + ump->core.name); +} +int snd_ump_attach_legacy_rawmidi (struct snd_ump_endpoint *ump,char *id,int device) {
@@ -1328,12 +1348,11 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,if (output)snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_ump_legacy_output_ops); -snprintf (rmidi->name,sizeof (rmidi->name),"%.68s (MIDI 1.0)" , - ump->core.name); rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP ; rmidi->ops = &snd_ump_legacy_ops; rmidi->private_data = ump; ump->legacy_rmidi = rmidi; +ump_legacy_set_rawmidi_name (ump);update_legacy_names (ump); rmidi->tied_device = ump->core.device;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/1193 ALSA: ump: do not touch legacy_rmidi before it exists
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingyu Zhang <[email protected]>
[ Upstream commit adeee7187694719890aaffdc14b7e89cfd736f1d ]
snd_ump_parse_endpoint() sets ump->parsed on every exit, including error, before the caller attaches the legacy rawmidi device. ump_handle_ep_name_msg() then treats parsed as "legacy_rmidi is live" and calls ump_legacy_set_rawmidi_name(), which snprintf()s into ump->legacy_rmidi->name. If a UMP packet arrives in that window (IRQ path from snd_ump_receive), legacy_rmidi is still NULL (KASAN null-ptr-deref in snprintf).
Guard the legacy helpers. parsed only means endpoint info was parsed, not that legacy_rmidi exists.
--- sound/core/ump.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/ump.c +4 -0
@@ -1305,6 +1305,8 @@ static void update_legacy_names(struct snd_ump_endpoint *ump) {struct snd_rawmidi *rmidi = ump->legacy_rmidi; +if (!rmidi) +return ;update_legacy_substreams (ump, rmidi,SNDRV_RAWMIDI_STREAM_INPUT );update_legacy_substreams (ump, rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT ); }
@@ -1313,6 +1315,8 @@ static void ump_legacy_set_rawmidi_name(struct snd_ump_endpoint *ump) {struct snd_rawmidi *rmidi = ump->legacy_rmidi; +if (!rmidi) +return ;snprintf (rmidi->name,sizeof (rmidi->name),"%.68s (MIDI 1.0)" , ump->core.name); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/1193 ASoC: ux500: Fix MSP stream lifecycle handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c37ba8fe00f264eee2fd18b0bff7c5f188136c51 ]
The trigger stop path drops the direction busy flag even though ALSA still owns the stream until shutdown. A later trigger cannot reliably restart it, shutdown may leave the block configured, and a second stream may overwrite shared duplex configuration.
Keep configured and running directions as separate state. Program shared settings only for the first direction, require a compatible configuration for the other half of a duplex stream, and enable the frame generator only while a provider stream is running. Also fix the RX-disable direction test and preserve the other direction multichannel setup.
--- sound/soc/ux500/ux500_msp_dai.c | 8 +- sound/soc/ux500/ux500_msp_i2s.c | 183 ++++++++++++++++++++++++-------- sound/soc/ux500/ux500_msp_i2s.h | 4 + 3 files changed, 149 insertions(+), 46 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +6 -2
@@ -34,8 +34,10 @@ static int setup_pcm_multichan(struct snd_soc_dai *dai,if (drvdata->slots >1 ) { msp_config->multichannel_configured =1 ; - multi->tx_multichannel_enable = true; - multi->rx_multichannel_enable = true; + multi->tx_multichannel_enable = + msp_config->direction &MSP_DIR_TX ; + multi->rx_multichannel_enable = + msp_config->direction &MSP_DIR_RX ; multi->rx_comparison_enable_mode =MSP_COMPARISON_DISABLED ; multi->tx_channel_0_enable = drvdata->tx_mask;
@@ -192,6 +194,7 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_BC_FC :dev_dbg (dai->dev,"%s: Codec is master.\n" , __func__); + msp_config->clock_provider = false; msp_config->iodelay =0x20 ; msp_config->rx_fsync_sel =0 ; msp_config->tx_fsync_sel =1 <<TFSSEL_SHIFT ;
@@ -204,6 +207,7 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_BP_FP :dev_dbg (dai->dev,"%s: Codec is slave.\n" , __func__); + msp_config->clock_provider = true; msp_config->tx_clk_sel =TX_CLK_SEL_SRG ; msp_config->tx_fsync_sel =TX_SYNC_SRG_PROG ; msp_config->rx_clk_sel =RX_CLK_SEL_SRG ;
sound/soc/ux500/ux500_msp_i2s.c +139 -44
284 lines not on this page · raw message
sound/soc/ux500/ux500_msp_i2s.h +4 -0
@@ -460,6 +460,7 @@ struct ux500_msp_config {enum msp_data_size data_size;unsigned int def_elem_len;unsigned int iodelay; +bool clock_provider; };struct ux500_msp {
@@ -470,8 +471,11 @@ struct ux500_msp {enum msp_state msp_state;int def_elem_len;unsigned int dir_busy; +unsigned int dir_running;int loopback_enable;unsigned int f_bitclk; +bool clock_provider; +struct ux500_msp_config config; }; int ux500_msp_i2s_init_msp(struct platform_device *pdev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/1193 ASoC: ux500: Propagate MSP setup errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3415421a2b0bc4e32bb5a9df24ed7863512d47a7 ]
The prepare callback continues with a partly initialized configuration when format setup fails. Probe likewise tests the allocated pointer instead of the return value, so an MMIO resource or mapping failure can be ignored after allocation succeeds.
Return configuration failures from prepare and test the MSP initialization result directly.
--- sound/soc/ux500/ux500_msp_dai.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +4 -2
@@ -468,7 +468,9 @@ static int ux500_msp_dai_prepare(struct snd_pcm_substream *substream,dev_dbg (dai->dev,"%s: MSP %d (%s): Enter (rate = %d).\n" , __func__, dai->id,snd_pcm_stream_str (substream), runtime->rate); -setup_msp_config (substream, dai, &msp_config); + ret =setup_msp_config (substream, dai, &msp_config); +if (ret) +return ret; ret =ux500_msp_i2s_open (drvdata->msp, &msp_config);if (ret <0 ) {
@@ -764,7 +766,7 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) } ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp); -if (!drvdata->msp) { +if (ret) {dev_err (&pdev->dev,"%s: ERROR: Failed to init MSP-struct (%d)!" , __func__, ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/1193 ASoC: ux500: Correct MSP frame and bit clock setup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 94c18cea657c48680e4ee20b635b6c01f3eb352e ]
FRPER plus one is the number of bit clocks in a frame. It must follow the configured slot count and width. The legacy rate-dependent constants produce malformed frames; notably, a 16-slot, 16-bit frame is programmed as 278 rather than 256 clocks.
Derive the frame period from the TDM geometry and use the real functional clock rate. Validate that the requested bit clock has an exact, representable divider, program SCKDIV as divider minus one, and report the resulting bit clock using that same divisor.
--- sound/soc/ux500/ux500_msp_dai.c | 75 +++++++-------------------------- sound/soc/ux500/ux500_msp_dai.h | 11 ----- sound/soc/ux500/ux500_msp_i2s.c | 54 ++++++++++++++---------- sound/soc/ux500/ux500_msp_i2s.h | 2 - 4 files changed, 46 insertions(+), 96 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +15 -60
@@ -59,72 +59,21 @@ static int setup_pcm_multichan(struct snd_soc_dai *dai,return 0 ; } -static int setup_frameper (struct snd_soc_dai *dai,unsigned int rate, -struct msp_protdesc *prot_desc) +static void setup_frameper (struct snd_soc_dai *dai, +struct msp_protdesc *prot_desc) {struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev); -switch (drvdata->slots) { -case 1 : -switch (rate) { -case 8000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_8_KHZ ; -break ; - -case 16000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_16_KHZ ; -break ; - -case 44100 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_44_1_KHZ ; -break ; - -case 48000 : - prot_desc->frame_period = -FRAME_PER_SINGLE_SLOT_48_KHZ ; -break ; - -default : -dev_err (dai->dev, -"%s: Error: Unsupported sample-rate (freq = %d)!\n" , - __func__, rate); -return -EINVAL ; - } -break ; - -case 2 : - prot_desc->frame_period =FRAME_PER_2_SLOTS ; -break ; - -case 8 : - prot_desc->frame_period =FRAME_PER_8_SLOTS ; -break ; - -case 16 : - prot_desc->frame_period =FRAME_PER_16_SLOTS ; -break ; -default : -dev_err (dai->dev, -"%s: Error: Unsupported slot-count (slots = %d)!\n" , - __func__, drvdata->slots); -return -EINVAL ; - } - - prot_desc->clocks_per_frame = - prot_desc->frame_period+1 ; + prot_desc->clocks_per_frame = drvdata->slots * drvdata->slot_width; + prot_desc->frame_period = prot_desc->clocks_per_frame -1 ;dev_dbg (dai->dev,"%s: Clocks per frame: %u\n" , __func__, prot_desc->clocks_per_frame); - -return 0 ; } -static int setup_pcm_framing (struct snd_soc_dai *dai,unsigned int rate, -struct msp_protdesc *prot_desc) +static int setup_pcm_framing (struct snd_soc_dai *dai, +struct msp_protdesc *prot_desc) {struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev);
@@ -165,7 +114,9 @@ static int setup_pcm_framing(struct snd_soc_dai *dai, unsigned int rate, prot_desc->tx_elem_len_2 =MSP_ELEM_LEN_16 ; prot_desc->rx_elem_len_2 =MSP_ELEM_LEN_16 ; -return setup_frameper (dai, rate, prot_desc); +setup_frameper (dai, prot_desc); + +return 0 ; } static int setup_clocking(struct snd_soc_dai *dai,
@@ -366,7 +317,7 @@ static int setup_msp_config(struct snd_pcm_substream *substream,if (ret <0 )return ret; - ret =setup_pcm_framing (dai, runtime->rate, prot_desc); + ret =setup_pcm_framing (dai, prot_desc);if (ret <0 )return ret;
@@ -735,7 +686,6 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) drvdata->tx_mask =0x01 ; drvdata->rx_mask =0x01 ; drvdata->slot_width =16 ; - drvdata->master_clk =MSP_INPUT_FREQ_APB ; drvdata->reg_vape =devm_regulator_get (&pdev->dev,"v-ape" );if (IS_ERR (drvdata->reg_vape)) {
@@ -764,6 +714,11 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) __func__, ret);return ret; } + drvdata->master_clk =clk_get_rate (drvdata->clk); +if (!drvdata->master_clk) { +dev_err (&pdev->dev,"MSP clock has no rate\n" ); +return -EINVAL ; + } ret =ux500_msp_i2s_init_msp (pdev, &drvdata->msp);if (ret) {
sound/soc/ux500/ux500_msp_dai.h +0 -11
@@ -22,17 +22,6 @@#define UX500_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) -#define FRAME_PER_SINGLE_SLOT_8_KHZ 31 -#define FRAME_PER_SINGLE_SLOT_16_KHZ 124 -#define FRAME_PER_SINGLE_SLOT_44_1_KHZ 63 -#define FRAME_PER_SINGLE_SLOT_48_KHZ 49 -#define FRAME_PER_2_SLOTS 31 -#define FRAME_PER_8_SLOTS 138 -#define FRAME_PER_16_SLOTS 277 - -#define UX500_MSP_INTERNAL_CLOCK_FREQ 40000000 -#define UX500_MSP1_INTERNAL_CLOCK_FREQ UX500_MSP_INTERNAL_CLOCK_FREQ -#define UX500_MSP_MIN_CHANNELS 1#define UX500_MSP_MAX_CHANNELS 8
sound/soc/ux500/ux500_msp_i2s.c +31 -23
78 lines not on this page · raw message
sound/soc/ux500/ux500_msp_i2s.h +0 -2
@@ -12,8 +12,6 @@#include <linux/platform_device.h> -#define MSP_INPUT_FREQ_APB 48000000 -/*** Stereo mode. Used for APB data accesses as 16 bits accesses (mono), * 32 bits accesses (stereo). ***/
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/1193 ASoC: ux500: Validate MSP DAI configuration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9ccbacf5a0120964fc1ffacb8151e3347bee9287 ]
Installing channel constraints from hw_params is too late to affect the parameters being committed. The driver consequently accepts channel counts which disagree with the I2S or TDM setup. It also silently truncates out-of-range slot masks and accepts inverted bit clock formats which prepare then rejects.
Validate the selected channel count directly, reject invalid masks before changing cached TDM state, and implement all four standard clock and frame inversion combinations. Use the requested format in validation diagnostics.
--- sound/soc/ux500/ux500_msp_dai.c | 41 ++++++++++++++++++++++----------- sound/soc/ux500/ux500_msp_i2s.c | 7 ++++-- sound/soc/ux500/ux500_msp_i2s.h | 1 + 3 files changed, 33 insertions(+), 16 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +27 -14
@@ -130,7 +130,16 @@ static int setup_clocking(struct snd_soc_dai *dai,case SND_SOC_DAIFMT_NB_IF : msp_config->tx_fsync_pol ^=1 <<TFSPOL_SHIFT ; msp_config->rx_fsync_pol ^=1 <<RFSPOL_SHIFT ; +break ; + +case SND_SOC_DAIFMT_IB_NF : + msp_config->bclk_inverted = true; +break ; +case SND_SOC_DAIFMT_IB_IF : + msp_config->bclk_inverted = true; + msp_config->tx_fsync_pol ^=1 <<TFSPOL_SHIFT ; + msp_config->rx_fsync_pol ^=1 <<RFSPOL_SHIFT ;break ;default :
@@ -453,7 +462,6 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {unsigned int mask, slots_active; -struct snd_pcm_runtime *runtime = substream->runtime;struct ux500_msp_i2s_drvdata *drvdata =dev_get_drvdata (dai->dev); dev_dbg(dai->dev, "%s: MSP %d (%s): Enter.\n",
@@ -461,9 +469,8 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream,switch (drvdata->fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S : -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS , -1 ,2 ); +if (params_channels (params) <1 ||params_channels (params) >2 ) +return -EINVAL ;break ;case SND_SOC_DAIFMT_DSP_B :
@@ -475,9 +482,8 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream, slots_active =hweight32 (mask);dev_dbg (dai->dev,"TDM-slots active: %d" , slots_active); -snd_pcm_hw_constraint_single (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS , - slots_active); +if (!slots_active ||params_channels (params) != slots_active) +return -EINVAL ;break ;default :
@@ -510,20 +516,21 @@ static int ux500_msp_dai_set_dai_fmt(struct snd_soc_dai *dai,default :dev_err (dai->dev,"%s: Error: Unsupported protocol/master (fmt = 0x%x)!\n" , - __func__, drvdata->fmt); + __func__, fmt);return -EINVAL ; }switch (fmt &SND_SOC_DAIFMT_INV_MASK ) {case SND_SOC_DAIFMT_NB_NF :case SND_SOC_DAIFMT_NB_IF : +case SND_SOC_DAIFMT_IB_NF :case SND_SOC_DAIFMT_IB_IF :break ;default :dev_err (dai->dev,"%s: Error: Unsupported inversion (fmt = 0x%x)!\n" , - __func__, drvdata->fmt); + __func__, fmt);return -EINVAL ; }
@@ -557,17 +564,23 @@ static int ux500_msp_dai_set_tdm_slot(struct snd_soc_dai *dai, __func__, slots);return -EINVAL ; } - drvdata->slots = slots; -if (!(slot_width ==16 )) { +if (slot_width !=16 ) {dev_err (dai->dev,"%s: Error: Unsupported slot-width (%d)!\n" , __func__, slot_width);return -EINVAL ; } - drvdata->slot_width = slot_width; - drvdata->tx_mask = tx_mask & cap; - drvdata->rx_mask = rx_mask & cap; +if ((tx_mask | rx_mask) & ~cap) { +dev_err (dai->dev,"%s: Slot mask exceeds %d slots\n" , + __func__, slots); +return -EINVAL ; + } + + drvdata->slots = slots; + drvdata->slot_width = slot_width; + drvdata->tx_mask = tx_mask; + drvdata->rx_mask = rx_mask;return 0 ; }
sound/soc/ux500/ux500_msp_i2s.c +5 -2
@@ -201,10 +201,12 @@ static int configure_protocol(struct ux500_msp *msp,/* The code below should not be separated. */ temp_reg =readl (msp->registers +MSP_GCR ) & ~TX_CLK_POL_RISING ; - temp_reg |=MSP_TX_CLKPOL_BIT (~protdesc->tx_clk_pol); + temp_reg |=MSP_TX_CLKPOL_BIT (!protdesc->tx_clk_pol ^ + config->bclk_inverted);writel (temp_reg, msp->registers +MSP_GCR ); temp_reg =readl (msp->registers +MSP_GCR ) & ~RX_CLK_POL_RISING ; - temp_reg |=MSP_RX_CLKPOL_BIT (protdesc->rx_clk_pol); + temp_reg |=MSP_RX_CLKPOL_BIT (protdesc->rx_clk_pol ^ + config->bclk_inverted);writel (temp_reg, msp->registers +MSP_GCR );return 0 ;
@@ -441,6 +443,7 @@ static bool ux500_msp_config_compatible(struct ux500_msp *msp, active->data_size == config->data_size && active->def_elem_len == config->def_elem_len && active->clock_provider == config->clock_provider && + active->bclk_inverted == config->bclk_inverted && !memcmp (&active->protdesc, &config->protdesc,sizeof (active->protdesc)); }
sound/soc/ux500/ux500_msp_i2s.h +1 -0
@@ -459,6 +459,7 @@ struct ux500_msp_config {unsigned int def_elem_len;unsigned int iodelay;bool clock_provider; +bool bclk_inverted; };struct ux500_msp {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/1193 mfd: db8500-prcmu: Remove needless return in three void APIs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit c105c555f8b4fd57b09439806b43b97ebc240ee2 ]
Remove needless 'return' in the following void APIs:
prcmu_early_init()
prcmu_system_reset()
prcmu_modem_reset()
Since both the API and callee involved are void functions.
Stable-dep-of: 66ec63e7a90b ("ASoC: ux500: Deassert the MSP reset during probe")
--- include/linux/mfd/dbx500-prcmu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/mfd/dbx500-prcmu.h +3 -3
@@ -215,7 +215,7 @@ struct prcmu_fw_version {static inline void prcmu_early_init (void ) { -return db8500_prcmu_early_init (); +db8500_prcmu_early_init (); } static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
@@ -302,7 +302,7 @@ static inline int prcmu_request_ape_opp_100_voltage(bool enable)static inline void prcmu_system_reset (u16 reset_code) { -return db8500_prcmu_system_reset (reset_code); +db8500_prcmu_system_reset (reset_code); }static inline u16 prcmu_get_reset_code (void )
@@ -314,7 +314,7 @@ int prcmu_ac_wake_req(void);void prcmu_ac_sleep_req (void );static inline void prcmu_modem_reset (void ) { -return db8500_prcmu_modem_reset (); +db8500_prcmu_modem_reset (); }static inline bool prcmu_is_ac_wake_requested (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/1193 arm: Handle KCOV __init vs inline mismatches
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 2424fe1cac4fc8ea0520ba22ede7544c3ddc8dd1 ]
When KCOV is enabled all functions get instrumented, unless the __no_sanitize_coverage attribute is used. To prepare for __no_sanitize_coverage being applied to __init functions, we have to handle differences in how GCC's inline optimizations get resolved. For arm this exposed several places where __init annotations were missing but ended up being "accidentally correct". Fix these cases and force several functions to be inline with __always_inline.
Stable-dep-of: 66ec63e7a90b ("ASoC: ux500: Deassert the MSP reset during probe")
--- arch/arm/mm/cache-feroceon-l2.c | 2 +- arch/arm/mm/cache-tauros2.c | 2 +- drivers/clocksource/timer-orion.c | 2 +- drivers/soc/ti/pm33xx.c | 2 +- include/linux/mfd/dbx500-prcmu.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mm/cache-feroceon-l2.c +1 -1
@@ -295,7 +295,7 @@ static inline u32 read_extra_features(void)return u; } -static inline void write_extra_features (u32 u) +static inline void __init write_extra_features (u32 u) { __asm__("mcr p15, 1, %0, c15, c1, 0" : :"r" (u)); }
arch/arm/mm/cache-tauros2.c +1 -1
@@ -177,7 +177,7 @@ static inline void __init write_actlr(u32 actlr) __asm__("mcr p15, 0, %0, c1, c0, 1\n" : :"r" (actlr)); } -static void enable_extra_feature (unsigned int features) +static void __init enable_extra_feature (unsigned int features) {u32 u;
drivers/clocksource/timer-orion.c +1 -1
@@ -43,7 +43,7 @@ static struct delay_timer orion_delay_timer = { .read_current_timer = orion_read_timer, }; -static void orion_delay_timer_init (unsigned long rate) +static void __init orion_delay_timer_init (unsigned long rate) { orion_delay_timer.freq = rate;register_current_timer_delay (&orion_delay_timer);
drivers/soc/ti/pm33xx.c +1 -1
@@ -145,7 +145,7 @@ static int am33xx_do_sram_idle(u32 wfi_flags)return pm_ops->cpu_suspend (am33xx_do_wfi_sram, wfi_flags); } -static int __init am43xx_map_gic (void ) +static int am43xx_map_gic (void ) { gic_dist_base =ioremap (AM43XX_GIC_DIST_BASE ,SZ_4K );
include/linux/mfd/dbx500-prcmu.h +1 -1
@@ -213,7 +213,7 @@ struct prcmu_fw_version {#if defined(CONFIG_UX500_SOC_DB8500 ) -static inline void prcmu_early_init (void ) +static inline void __init prcmu_early_init (void ) {db8500_prcmu_early_init (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/1193 mfd: db8500-prcmu: Fold dbx500 header into db8500
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b8bc38bcecb77880a802d0430862b023c0aa7392 ]
Move the DBx500 PRCMU definitions into the DB8500 PRCMU header and delete the wrapper header.
Convert users of simple PRCMU wrappers to call the DB8500 helpers directly.
The dbx500-prcmu.h header was the result of an earlier attempt to abstract several DBx5x SoC PRCMU units to use the same abstract header. They are deleted from the kernel and this is not just causing maintenance burden and build errors.
The stub code is using -ENOSYS in a way checkpatch complains about so replace these with -EINVAL while we're at it.
Stable-dep-of: 66ec63e7a90b ("ASoC: ux500: Deassert the MSP reset during probe")
--- arch/arm/mach-ux500/cpu-db8500.c | 6 +- drivers/clk/ux500/clk-prcmu.c | 20 +- drivers/clk/ux500/u8500_of_clk.c | 2 +- drivers/cpuidle/cpuidle-ux500.c | 6 +- drivers/mfd/ab8500-core.c | 2 +- drivers/mfd/db8500-prcmu.c | 6 +- drivers/regulator/db8500-prcmu.c | 12 +- drivers/thermal/db8500_thermal.c | 10 +- drivers/watchdog/db8500_wdt.c | 22 +- include/linux/mfd/db8500-prcmu.h | 252 +++++++++++++- include/linux/mfd/dbx500-prcmu.h | 575 ------------------------------- sound/soc/ux500/ux500_msp_dai.c | 2 +- 12 files changed, 294 insertions(+), 621 deletions(-) delete mode 100644 include/linux/mfd/dbx500-prcmu.h
arch/arm/mach-ux500/cpu-db8500.c +3 -3
@@ -12,7 +12,7 @@#include <linux/irq.h> #include <linux/irqchip.h> #include <linux/irqchip/arm-gic.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/platform_data/arm-ux500-pm.h> #include <linux/platform_device.h> #include <linux/io.h>
@@ -81,7 +81,7 @@ static void __init ux500_init_irq(void)struct resource r;irqchip_init (); -prcmu_early_init (); +db8500_prcmu_early_init (); np =of_find_compatible_node (NULL ,NULL ,"stericsson,db8500-prcmu" );of_address_to_resource (np,0 , &r);of_node_put (np);
@@ -101,7 +101,7 @@ static void ux500_restart(enum reboot_mode mode, const char *cmd)local_irq_disable ();local_fiq_disable (); -prcmu_system_reset (0 ); +db8500_prcmu_system_reset (0 ); }static const struct of_device_id u8500_local_bus_nodes[] = {
drivers/clk/ux500/clk-prcmu.c +10 -10
@@ -7,7 +7,7 @@*/ #include <linux/clk-provider.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/slab.h> #include <linux/io.h> #include <linux/err.h>
@@ -35,13 +35,13 @@ static int clk_prcmu_prepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -return prcmu_request_clock (clk->cg_sel, true); +return db8500_prcmu_request_clock (clk->cg_sel, true); }static void clk_prcmu_unprepare (struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (prcmu_request_clock (clk->cg_sel, false)) +if (db8500_prcmu_request_clock (clk->cg_sel, false))pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw)); }
@@ -84,7 +84,7 @@ static int clk_prcmu_opp_prepare(struct clk_hw *hw) clk->opp_requested =1 ; } - err =prcmu_request_clock (clk->cg_sel, true); + err =db8500_prcmu_request_clock (clk->cg_sel, true);if (err) {prcmu_qos_remove_requirement (PRCMU_QOS_APE_OPP , (char *)clk_hw_get_name (hw));
@@ -99,7 +99,7 @@ static void clk_prcmu_opp_unprepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (prcmu_request_clock (clk->cg_sel, false)) { +if (db8500_prcmu_request_clock (clk->cg_sel, false)) {pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw));return ;
@@ -118,7 +118,7 @@ static int clk_prcmu_opp_volt_prepare(struct clk_hw *hw)struct clk_prcmu *clk =to_clk_prcmu (hw);if (!clk->opp_requested) { - err =prcmu_request_ape_opp_100_voltage (true); + err =db8500_prcmu_request_ape_opp_100_voltage (true);if (err) {pr_err ("clk_prcmu: %s fail req APE OPP VOLT for %s.\n" , __func__,clk_hw_get_name (hw));
@@ -127,9 +127,9 @@ static int clk_prcmu_opp_volt_prepare(struct clk_hw *hw) clk->opp_requested =1 ; } - err =prcmu_request_clock (clk->cg_sel, true); + err =db8500_prcmu_request_clock (clk->cg_sel, true);if (err) { -prcmu_request_ape_opp_100_voltage (false); +db8500_prcmu_request_ape_opp_100_voltage (false); clk->opp_requested =0 ;return err; }
@@ -141,14 +141,14 @@ static void clk_prcmu_opp_volt_unprepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (prcmu_request_clock (clk->cg_sel, false)) { +if (db8500_prcmu_request_clock (clk->cg_sel, false)) {pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw));return ; }if (clk->opp_requested) { -prcmu_request_ape_opp_100_voltage (false); +db8500_prcmu_request_ape_opp_100_voltage (false); clk->opp_requested =0 ; } }
drivers/clk/ux500/u8500_of_clk.c +1 -1
@@ -9,7 +9,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/clk-provider.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include "clk.h" #include "prcc.h"
drivers/cpuidle/cpuidle-ux500.c +3 -3
@@ -11,7 +11,7 @@#include <linux/spinlock.h> #include <linux/atomic.h> #include <linux/smp.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/platform_data/arm-ux500-pm.h> #include <linux/platform_device.h>
@@ -66,7 +66,7 @@ static inline int ux500_enter_idle(struct cpuidle_device *dev,/* Go to the retention state, the prcmu will wait for the * cpu to go WFI and this is what happens after exiting this * 'master' critical section */ -if (prcmu_set_power_state (PRCMU_AP_IDLE , true, true)) +if (db8500_prcmu_set_power_state (PRCMU_AP_IDLE , true, true)) goto out;/* When we switch to retention, the prcmu is in charge
@@ -109,7 +109,7 @@ static struct cpuidle_driver ux500_idle_driver = {static int dbx500_cpuidle_probe (struct platform_device *pdev) {/* Configure wake up reasons */ -prcmu_enable_wakeups (PRCMU_WAKEUP (ARM ) |PRCMU_WAKEUP (RTC ) | +db8500_prcmu_enable_wakeups (PRCMU_WAKEUP (ARM ) |PRCMU_WAKEUP (RTC ) |PRCMU_WAKEUP (ABB ));return cpuidle_register (&ux500_idle_driver,NULL );
drivers/mfd/ab8500-core.c +1 -1
@@ -19,7 +19,7 @@#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/of.h> /*
drivers/mfd/db8500-prcmu.c +3 -3
@@ -32,7 +32,7 @@#include <linux/platform_device.h> #include <linux/uaccess.h> #include <linux/mfd/core.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/mfd/abx500/ab8500.h> #include <linux/regulator/db8500-prcmu.h> #include <linux/regulator/machine.h>
@@ -2285,7 +2285,7 @@ void db8500_prcmu_system_reset(u16 reset_code)/** * db8500_prcmu_get_reset_code - Retrieve SW reset reason code * -* Retrieves the reset reason code stored by prcmu_system_reset() before +* Retrieves the reset reason code stored by db8500_prcmu_system_reset() before * last restart. */ u16 db8500_prcmu_get_reset_code (void )
@@ -3041,7 +3041,7 @@ static int db8500_prcmu_probe(struct platform_device *pdev)db8500_irq_init (np); -prcmu_config_esram0_deep_sleep (ESRAM0_DEEP_SLEEP_STATE_RET ); +db8500_prcmu_config_esram0_deep_sleep (ESRAM0_DEEP_SLEEP_STATE_RET ); err =mfd_add_devices (&pdev->dev,0 , common_prcmu_devs,ARRAY_SIZE (common_prcmu_devs),NULL ,0 , db8500_irq_domain);
drivers/regulator/db8500-prcmu.c +6 -6
@@ -13,7 +13,7 @@#include <linux/err.h> #include <linux/spinlock.h> #include <linux/platform_device.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/db8500-prcmu.h>
@@ -93,13 +93,13 @@ static int enable_epod(u16 epod_id, bool ramret)if (ramret) {if (!epod_on[epod_id]) { - ret =prcmu_set_epod (epod_id,EPOD_STATE_RAMRET ); + ret =db8500_prcmu_set_epod (epod_id,EPOD_STATE_RAMRET );if (ret <0 )return ret; } epod_ramret[epod_id] = true; }else { - ret =prcmu_set_epod (epod_id,EPOD_STATE_ON ); + ret =db8500_prcmu_set_epod (epod_id,EPOD_STATE_ON );if (ret <0 )return ret; epod_on[epod_id] = true;
@@ -114,18 +114,18 @@ static int disable_epod(u16 epod_id, bool ramret)if (ramret) {if (!epod_on[epod_id]) { - ret =prcmu_set_epod (epod_id,EPOD_STATE_OFF ); + ret =db8500_prcmu_set_epod (epod_id,EPOD_STATE_OFF );if (ret <0 )return ret; } epod_ramret[epod_id] = false; }else {if (epod_ramret[epod_id]) { - ret =prcmu_set_epod (epod_id,EPOD_STATE_RAMRET ); + ret =db8500_prcmu_set_epod (epod_id,EPOD_STATE_RAMRET );if (ret <0 )return ret; }else { - ret =prcmu_set_epod (epod_id,EPOD_STATE_OFF ); + ret =db8500_prcmu_set_epod (epod_id,EPOD_STATE_OFF );if (ret <0 )return ret; }
drivers/thermal/db8500_thermal.c +5 -5
@@ -10,7 +10,7 @@#include <linux/cpu_cooling.h> #include <linux/interrupt.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h>
@@ -82,7 +82,7 @@ static void db8500_thermal_update_config(struct db8500_thermal_zone *th,unsigned long next_low, unsigned long next_high) { -prcmu_stop_temp_sense (); +db8500_prcmu_stop_temp_sense (); th->cur_index = idx; th->interpolated_temp = (next_low + next_high)/2 ;
@@ -91,8 +91,8 @@ static void db8500_thermal_update_config(struct db8500_thermal_zone *th,* The PRCMU accept absolute temperatures in celsius so divide * down the millicelsius with 1000 */ -prcmu_config_hotmon ((u8)(next_low/1000 ), (u8)(next_high/1000 )); -prcmu_start_temp_sense (PRCMU_DEFAULT_MEASURE_TIME ); +db8500_prcmu_config_hotmon ((u8)(next_low /1000 ), (u8)(next_high /1000 )); +db8500_prcmu_start_temp_sense (PRCMU_DEFAULT_MEASURE_TIME ); }static irqreturn_t prcmu_low_irq_handler (int irq,void *irq_data)
@@ -204,7 +204,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)static int db8500_thermal_suspend (struct platform_device *pdev,pm_message_t state) { -prcmu_stop_temp_sense (); +db8500_prcmu_stop_temp_sense ();return 0 ; }
drivers/watchdog/db8500_wdt.c +11 -11
@@ -16,7 +16,7 @@#include <linux/watchdog.h> #include <linux/platform_device.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #define WATCHDOG_TIMEOUT 600/* 10 minutes */
@@ -37,24 +37,24 @@ MODULE_PARM_DESC(nowayout,static int db8500_wdt_start (struct watchdog_device *wdd) { -return prcmu_enable_a9wdog (PRCMU_WDOG_ALL ); +return db8500_prcmu_enable_a9wdog (PRCMU_WDOG_ALL ); }static int db8500_wdt_stop (struct watchdog_device *wdd) { -return prcmu_disable_a9wdog (PRCMU_WDOG_ALL ); +return db8500_prcmu_disable_a9wdog (PRCMU_WDOG_ALL ); }static int db8500_wdt_keepalive (struct watchdog_device *wdd) { -return prcmu_kick_a9wdog (PRCMU_WDOG_ALL ); +return db8500_prcmu_kick_a9wdog (PRCMU_WDOG_ALL ); }static int db8500_wdt_set_timeout (struct watchdog_device *wdd,unsigned int timeout) {db8500_wdt_stop (wdd); -prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 ); +db8500_prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 );db8500_wdt_start (wdd);return 0 ;
@@ -91,10 +91,10 @@ static int db8500_wdt_probe(struct platform_device *pdev)watchdog_set_nowayout (&db8500_wdt, nowayout);/* disable auto off on sleep */ -prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , false); +db8500_prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , false);/* set HW initial value */ -prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 ); +db8500_prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 ); ret =devm_watchdog_register_device (dev, &db8500_wdt);if (ret)
@@ -110,9 +110,9 @@ static int db8500_wdt_suspend(struct platform_device *pdev, {if (watchdog_active (&db8500_wdt)) {db8500_wdt_stop (&db8500_wdt); -prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , true); +db8500_prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , true); -prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 ); +db8500_prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 );db8500_wdt_start (&db8500_wdt); }return 0 ;
@@ -122,9 +122,9 @@ static int db8500_wdt_resume(struct platform_device *pdev) {if (watchdog_active (&db8500_wdt)) {db8500_wdt_stop (&db8500_wdt); -prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , false); +db8500_prcmu_config_a9wdog (PRCMU_WDOG_CPU1 , false); -prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 ); +db8500_prcmu_load_a9wdog (PRCMU_WDOG_ALL , timeout *1000 );db8500_wdt_start (&db8500_wdt); }return 0 ;
include/linux/mfd/db8500-prcmu.h +250 -2
312 lines not on this page · raw message
include/linux/mfd/dbx500-prcmu.h deleted +0 -575
575 lines not on this page · raw message
sound/soc/ux500/ux500_msp_dai.c +1 -1
@@ -14,7 +14,7 @@#include <linux/clk.h> #include <linux/of.h> #include <linux/regulator/consumer.h> -#include <linux/mfd/dbx500-prcmu.h> +#include <linux/mfd/db8500-prcmu.h> #include <sound/soc.h> #include <sound/soc-dai.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/1193 ASoC: ux500: Request the MSP MMIO resource
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 4fb67925f33ad789e9e00903a73306ed40f7ae32 ]
A bare devm_ioremap() neither reserves the register range nor preserves the platform resource error. This permits another driver to claim the same range and reports every mapping failure as an allocation failure.
Use the managed platform resource helper, retaining the resolved resource only to derive the DMA register address.
--- sound/soc/ux500/ux500_msp_i2s.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
sound/soc/ux500/ux500_msp_i2s.c +4 -14
@@ -733,7 +733,7 @@ int ux500_msp_i2s_close(struct ux500_msp *msp, unsigned int dir)int ux500_msp_i2s_init_msp (struct platform_device *pdev,struct ux500_msp **msp_p) { -struct resource *res =NULL ; +struct resource *res;struct ux500_msp *msp; *msp_p =devm_kzalloc (&pdev->dev,sizeof (struct ux500_msp ),GFP_KERNEL );
@@ -743,20 +743,10 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, msp->dev = &pdev->dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (res ==NULL ) { -dev_err (&pdev->dev,"%s: ERROR: Unable to get resource!\n" , - __func__); -return -ENOMEM ; - } - + msp->registers =devm_platform_get_and_ioremap_resource (pdev,0 , &res); +if (IS_ERR (msp->registers)) +return PTR_ERR (msp->registers); msp->tx_rx_addr = res->start +MSP_DR ; - msp->registers =devm_ioremap (&pdev->dev, res->start, -resource_size (res)); -if (msp->registers ==NULL ) { -dev_err (&pdev->dev,"%s: ERROR: ioremap failed!\n" , __func__); -return -ENOMEM ; - } msp->msp_state =MSP_STATE_IDLE ; msp->loopback_enable =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/1193 ASoC: ux500: Program the MSP FIFO watermarks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 2519439b4b5f6ee95879b1a44fc373127291b1e4 ]
The DMA engine is configured for four-element bursts, but the MSP driver never programs the FIFO watermark register and instead depends on its previous or reset value. The DB8500 DMA request protocol requires the peripheral watermark to match the DMA packet size.
Program four-element receive and transmit watermarks when configuring the first direction, before enabling MSP DMA requests.
--- sound/soc/ux500/ux500_msp_i2s.c | 2 ++ sound/soc/ux500/ux500_msp_i2s.h | 5 +++++ 2 files changed, 7 insertions(+)
sound/soc/ux500/ux500_msp_i2s.c +2 -0
@@ -507,6 +507,8 @@ int ux500_msp_i2s_open(struct ux500_msp *msp, old_reg &= ~mask; new_reg |= old_reg;writel (new_reg, msp->registers +MSP_GCR ); +writel (MSP_WMRK_TX_4_ELEMENTS |MSP_WMRK_RX_4_ELEMENTS , + msp->registers +MSP_WMRK ); } res =enable_msp (msp, config, first);
sound/soc/ux500/ux500_msp_i2s.h +5 -0
@@ -62,6 +62,7 @@ enum msp_direction {#define MSP_SRG 0x10#define MSP_FLR 0x14#define MSP_DMACR 0x18 +#define MSP_WMRK 0x1c#define MSP_IMSC 0x20#define MSP_RIS 0x24
@@ -228,6 +229,10 @@ enum msp_direction {#define RDMAE_SHIFT 0#define TDMAE_SHIFT 1 +/* FIFO watermark register */ +#define MSP_WMRK_RX_4_ELEMENTS BIT(0) +#define MSP_WMRK_TX_4_ELEMENTS BIT(3) +/* Interrupt Register */ #define RX_SERVICE_INT BIT(0)#define RX_OVERRUN_ERROR_INT BIT(1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/1193 btrfs: fix transaction use-after-free in raid stripe insertion
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuangpeng Bai <[email protected]>
[ Upstream commit a8813a923f9e43f788b357fb55c35f7f6ed6f98c ]
If allocation of a RAID stripe extent fails, btrfs_insert_one_raid_extent() aborts and ends the transaction before returning -ENOMEM.
btrfs_finish_one_ordered(), the production caller through btrfs_insert_raid_extent(), still owns the transaction handle. It handles the error by aborting the transaction and then reaches the common exit path, which ends the transaction again.
The premature end can free the handle and drop its transaction reference. Transaction cleanup can then free the transaction before the caller's second abort accesses the handle and transaction, resulting in use-after-free.
Keep the abort at the failure site, but let the caller's common exit path end the transaction once, after it has finished using both objects.
--- fs/btrfs/raid-stripe-tree.c | 1 - 1 file changed, 1 deletion(-)
fs/btrfs/raid-stripe-tree.c +0 -1
@@ -29,7 +29,6 @@ static int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans, stripe_extent =kzalloc (item_size,GFP_NOFS );if (!stripe_extent) {btrfs_abort_transaction (trans, -ENOMEM ); -btrfs_end_transaction (trans);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/1193 btrfs: directly return 0 on no error code in btrfs_insert_raid_extent()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b8212814d1e8428a082234223105e4071b844fab ]
It's more obvious to return a literal zero instead of "return ret;". Plus Smatch complains that ret could be uninitialized if the ordered_extent->bioc_list list is empty and this silences that warning.
Stable-dep-of: afbe73778338 ("btrfs: fix the possible bioc_list memory leak during error")
--- fs/btrfs/raid-stripe-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/raid-stripe-tree.c +1 -1
@@ -82,5 +82,5 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,btrfs_put_bioc (bioc); } -return ret; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/1193 btrfs: fix the possible bioc_list memory leak during error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit afbe73778338e6d1ac8c4486fbdf33f0cc1f2624 ]
There are two possible ways to leak bioc memory on btrfs_ordered_extent::bioc_list:
- An error occurred for btrfs_insert_one_raid_extent() Then the function btrfs_insert_raid_extent() immediately return without freeing any bioc in the bioc_list.
- An ordered extent hit an IO error
In that case the ordered extent will have BTRFS_ORDERED_IOERR set, and skip the call on btrfs_insert_raid_extent() completely.
Fix the problem by:
- Introduce a new helper, btrfs_cleanup_ordered_bioc_list() Which will remove all bioc from the bioc_list, and release the bioc.
- Call the above helper for btrfs_insert_raid_extent() So that the cleanup helper is always called no matter what.
- Call the above helper for btrfs_finish_one_ordered() This is called just before the final release on the ordered extent.
This was reported by Sashiko when reviewing another patch.
--- fs/btrfs/inode.c | 3 +++ fs/btrfs/raid-stripe-tree.c | 18 ++++++++++++------ fs/btrfs/raid-stripe-tree.h | 1 + 3 files changed, 16 insertions(+), 6 deletions(-)
fs/btrfs/inode.c +3 -0
@@ -3300,6 +3300,9 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)*/ btrfs_remove_ordered_extent (inode, ordered_extent); +/* Cleanup any remaining biocs attached to the OE. */ +btrfs_cleanup_ordered_bioc_list (ordered_extent); +/* once for us */ btrfs_put_ordered_extent (ordered_extent);/* once for the tree */
fs/btrfs/raid-stripe-tree.c +12 -6
@@ -64,7 +64,7 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans, struct btrfs_ordered_extent *ordered_extent) {struct btrfs_io_context *bioc; -int ret; +int ret =0 ;if (!btrfs_fs_incompat (trans->fs_info,RAID_STRIPE_TREE ))return 0 ;
@@ -72,15 +72,21 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,list_for_each_entry (bioc, &ordered_extent->bioc_list, rst_ordered_entry) { ret =btrfs_insert_one_raid_extent (trans, bioc);if (ret) -return ret; +break ; } -while (!list_empty (&ordered_extent->bioc_list)) { - bioc =list_first_entry (&ordered_extent->bioc_list, +btrfs_cleanup_ordered_bioc_list (ordered_extent); +return ret; +} + +void btrfs_cleanup_ordered_bioc_list (struct btrfs_ordered_extent *ordered) +{ +while (!list_empty (&ordered->bioc_list)) { +struct btrfs_io_context *bioc; + + bioc =list_first_entry (&ordered->bioc_list,typeof (*bioc), rst_ordered_entry);list_del (&bioc->rst_ordered_entry);btrfs_put_bioc (bioc); } - -return 0 ; }
fs/btrfs/raid-stripe-tree.h +1 -0
@@ -13,6 +13,7 @@ struct btrfs_trans_handle;int btrfs_insert_raid_extent (struct btrfs_trans_handle *trans,struct btrfs_ordered_extent *ordered_extent); +void btrfs_cleanup_ordered_bioc_list (struct btrfs_ordered_extent *ordered);static inline bool btrfs_need_stripe_tree_update (struct btrfs_fs_info *fs_info,u64 map_type)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/1193 btrfs: send: fix lost error return value in will_overwrite_ref()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit d0285dfbc3b46f41395b26ee2f4a16d99fb3e736 ]
The direct-return refactoring in commit b3047a42f55d ("btrfs: send:
directly return from will_overwrite_ref() and simplify it") changed will_overwrite_ref() to return directly instead of going through the common out label.
That resulted in a negative return value from is_inode_existent() to start being converted to 0, making lookup errors unable to be distinguished from the inode not existing.
process_recorded_refs() expects negative errors from will_overwrite_ref() and aborts processing when it receives one.
Return the value from is_inode_existent() to restore the previous error propagation behavior as it was before the refactor.
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -2157,7 +2157,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen, ret =is_inode_existent (sctx, dir, dir_gen,NULL , &parent_root_dir_gen);if (ret <=0 ) -return 0 ; +return ret;/* * If we have a parent root we need to verify that the parent dir was
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/1193 btrfs: do not force reloc root creation during qgroup_account_snapshot()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit cacf35832292997018837e484283f95a9301ebf5 ]
[BUG]
When running btrfs/252 with quota enabled through MKFS_OPTIONS="-O quota", it has a high chance to trigger the following kernel warning and flips the fs RO:
BTRFS info (device dm-2): relocating block group 30408704 flags metadata|dup
------------[ cut here ]------------
WARNING: fs/btrfs/extent-tree.c:879 at lookup_inline_extent_backref+0x74b/0x960 [btrfs], CPU#4: btrfs/2173
CPU: 4 UID: 0 PID: 2173 Comm: btrfs Not tainted 7.2.0-rc6-custom+ #457 PREEMPT(full) 3adc6528fb66f7a55fe1095385818e742f200aab
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022
RIP: 0010:lookup_inline_extent_backref+0x74b/0x960 [btrfs]
Call Trace:
<TASK>
insert_inline_extent_backref+0x7c/0x160 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__btrfs_inc_extent_ref+0xa9/0x270 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__btrfs_run_delayed_refs+0x4af/0x11c0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_run_delayed_refs+0x9d/0xf0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
create_pending_snapshot+0x39d/0xf00 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
create_pending_snapshots+0x9b/0xc0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_commit_transaction+0x280/0xeb0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
prepare_to_relocate+0x147/0x200 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
relocate_block_group+0x6b/0x5e0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_relocate_block_group+0x92c/0x2380 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_relocate_chunk+0x3f/0x1a0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_balance+0xa2c/0x19c0 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
btrfs_ioctl+0x2839/0x2d30 [btrfs 32f09462c54d9c922fca74a3e4866f4aa7737b72]
__x64_sys_ioctl+0x416/0x9a0
do_syscall_64+0xe1/0x790
entry_SYSCALL_64_after_hwframe+0x4b/0x53
</TASK>
---[ end trace 0000000000000000 ]---
BTRFS info (device dm-2): leaf 4593991680 gen 233 total ptrs 175 free space 5953 owner 2
BTRFS info (device dm-2): refs 3 lock_owner 2173 current 2173
item 0 key (166772736 METADATA_ITEM 1) itemoff 16250 itemsize 33
extent refs 1 gen 222 flags 2
ref#0: tree block backref root 266
[ Skip the tree dump ]
item 174 key (263225344 METADATA_ITEM 0) itemoff 10328 itemsize 33
extent refs 1 gen 162 flags 258
ref#0: tree block backref root 267
BTRFS error (device dm-2): extent item not found for insert, bytenr 179847168 num_bytes 16384 parent 4594335744 root_objectid 273 owner 0 offset 0
BTRFS error (device dm-2): failed to run delayed ref for logical 179847168 num_bytes 16384 type 182 action 1 ref_mod 1: -117[CAUSE]
The above error is showing that there is a tree reference to a metadata extent that is no longer there.
With "ref_verify" mount option (requires CONFIG_BTRFS_DEBUG), there is some extra debug output:
BTRFS error (device dm-2): dumping block entry [180961280 16384], num_refs 0, metadata 1, from disk 0
BTRFS error (device dm-2): root entry 256, num_refs 18446744073709551615
BTRFS error (device dm-2): root entry 273, num_refs 18446744073709551615
BTRFS error (device dm-2): Ref action 3, root 273, ref_root 273, parent 0, owner 0, offset 0, num_refs 1
btrfs_force_cow_block+0x129/0x7d0 [btrfs]
btrfs_cow_block+0x10a/0x250 [btrfs]
btrfs_search_slot+0x5eb/0xf40 [btrfs]
btrfs_insert_empty_items+0x3a/0x70 [btrfs]
insert_with_overflow+0x53/0x130 [btrfs]
btrfs_insert_dir_item+0x125/0x290 [btrfs]
btrfs_add_link+0xaa/0x410 [btrfs]
btrfs_rename+0x5ea/0xcd0 [btrfs]
btrfs_rename2+0x28/0x60 [btrfs]
vfs_rename+0x5b2/0xe10
filename_renameat2+0x244/0x430
__x64_sys_rename+0x48/0x70
do_syscall_64+0xe1/0x790
entry_SYSCALL_64_after_hwframe+0x4b/0x53
BTRFS error (device dm-2): Ref action 2, root 273, ref_root 273, parent 0, owner 0, offset 0, num_refs 18446744073709551615
btrfs_force_cow_block+0x327/0x7d0 [btrfs]
btrfs_cow_block+0x10a/0x250 [btrfs]
btrfs_search_slot+0x5eb/0xf40 [btrfs]
btrfs_lookup_file_extent+0x4d/0x70 [btrfs]
btrfs_drop_extents+0x151/0xf00 [btrfs]
insert_reserved_file_extent+0xfe/0x3e0 [btrfs]
btrfs_finish_one_ordered+0x549/0xc40 [btrfs]
btrfs_work_helper+0xde/0x350 [btrfs]
process_one_work+0x198/0x380
worker_thread+0x1c8/0x330
kthread+0xee/0x120
ret_from_fork+0x28f/0x310
ret_from_fork_asm+0x11/0x20
BTRFS error (device dm-2): Ref action 1, root 273, ref_root 0, parent 4594335744, owner 0, offset 0, num_refs 1
__btrfs_mod_ref+0x1c5/0x2d0 [btrfs]
btrfs_copy_root+0x262/0x390 [btrfs]
create_reloc_root+0xb9/0x370 [btrfs]
btrfs_init_reloc_root+0xb0/0x1b0 [btrfs]
record_root_in_trans+0xa6/0xd0 [btrfs]
create_pending_snapshot+0x383/0xf00 [btrfs]
create_pending_snapshots+0x9b/0xc0 [btrfs]
btrfs_commit_transaction+0x280/0xeb0 [btrfs]
prepare_to_relocate+0x147/0x200 [btrfs]
relocate_block_group+0x6b/0x5e0 [btrfs]
btrfs_relocate_block_group+0x92c/0x2380 [btrfs]
btrfs_relocate_chunk+0x3f/0x1a0 [btrfs]
btrfs_balance+0xa2c/0x19c0 [btrfs]
btrfs_ioctl+0x2839/0x2d30 [btrfs]
__x64_sys_ioctl+0x416/0x9a0
do_syscall_64+0xe1/0x790The above shows the direct cause, Ref action 3 is the oldest operation, which shows the tree block is created by COW. Then ref action 2 shows it's COWed away, by a metadata update, meaning the tree block is already released, should not be referred any more.
Then the final one, is trying to create a reloc tree for subvolume 273, and that reloc root creation is referring to the already dropped tree block.
The root cause is that, during qgroup_account_snapshot(), we are calling record_root_in_trans() with "force = true".
So if the root has no reloc root, we will create one, but at that timing it's already too late.
Normally reloc root should be created before the commit and current roots diverge, to avoid the same problem we are hitting.
But during relocation initialization, we are committing the current running transaction, with a new reloc_control attached halfway.
And if qgroup is enabled, the record_root_in_trans() with "force = true" calls will force reloc root creation even if we do not and should not create reloc root at that timing.
[FIX]
Do not force reloc root creation during record_root_in_trans() with "force = true" cases, which is only called by qgroup_account_snapshot().
If we're really under relocation, the reloc root should be created way early, before the commit and current root diverge. If the root has no reloc tree yet, it means we're still initializing the reloc, and do not need a reloc root.
So skipping the reloc tree creation in qgroup_account_snapshot() should be safe.
--- fs/btrfs/transaction.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/btrfs/transaction.c +12 -1
@@ -453,8 +453,19 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans,* through btrfs_record_root_in_trans without having to take the * lock. smp_wmb() makes sure that all the writes above are * done before we pop in the zero below +* +* If @force is true, it means the call is from +* qgroup_account_snapshot(), which only requires radix tree +* tracking. +* We should not force reloc root creation here, as the root +* may have already been modified, and in that case +* root->commit_root has already been dropped. +* +* Using that commit root will cause the reloc root to refer +* to a deleted extent, causing extent tree corruption. */ - ret =btrfs_init_reloc_root (trans, root); +if (!force) + ret =btrfs_init_reloc_root (trans, root);smp_mb__before_atomic ();clear_bit (BTRFS_ROOT_IN_TRANS_SETUP , &root->state); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/1193 ipvs: fix reversed sequence option serialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit b04578b74f2d3755548fe9e829e3b2a6c6f966a1 ]
hton_seq() expects the host-order source first and the unaligned network-order destination second. The version 1 sync sender passes these arguments in reverse for both sequence blocks. This leaves 24 bytes of the kmalloc-backed message unwritten. It may disclose stale heap data and replace the live connection sequence state with values read from the buffer.
Pass the connection sequence state as the source and the message payload as the destination for both blocks.
--- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +2 -2
@@ -748,9 +748,9 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options ); -hton_seq ((struct ip_vs_seq *)p, &cp->in_seq); +hton_seq (&cp->in_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); -hton_seq ((struct ip_vs_seq *)p, &cp->out_seq); +hton_seq (&cp->out_seq, (struct ip_vs_seq *)p); p +=sizeof (struct ip_vs_seq ); }/* Handle pe data */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/1193 netfilter: nf_conntrack_sip: fix OOB read in sip_skip_whitespace()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit e8f8231824b5815f57ce62cba116e511b10196de ]
sip_skip_whitespace() returns dptr unchanged when its own loop exhausts the buffer (dptr == limit), instead of NULL like its sibling sip_follow_continuation() returns on its own "no more data" path.
ct_sip_get_header() only checks for NULL after calling it:
dptr = sip_skip_whitespace(dptr, limit);
if (dptr == NULL)
break;
if (*dptr != ':' || ++dptr >= limit)
break;so a recognized header name followed only by spaces/tabs running to the exact end of the SIP payload, with no colon, makes the very next statement read one byte past the buffer.
Make both "no more data" outcomes return NULL, matching the convention sip_follow_continuation() already uses and that both existing callers already check for.
--- net/netfilter/nf_conntrack_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -429,7 +429,7 @@ static const char *sip_skip_whitespace(const char *dptr, const char *limit) dptr =sip_follow_continuation (dptr, limit);break ; } -return dptr; +return dptr < limit ? dptr :NULL ; }/* Search within a SIP header value, dealing with continuation lines */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/1193 tracing/probes: Fix use-after-free on field name/type of events with multiple probes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 86b7a239ec6b14a7544200ede85474c6f5526049 ]
The fields of a probe-based dynamic event (kprobe, uprobe, eprobe and fprobe events) are created in traceprobe_define_arg_fields() by handing the probe_arg name/type strings to trace_define_field(), which only stores the pointers without copying. Those strings are owned by the trace_probe and are freed when that probe is removed.
An event can have several probes attached. The field list is defined only once, by the first probe that registers the event, but it is kept alive by any surviving sibling probe. Deleting just that first probe by symbol -
# primary A: fields are defined from A's args echo 'p:kprobes/ev vfs_read a1=$arg1' > kprobe_events # append B: shares A's event call echo 'p:kprobes/ev vfs_write a1=$arg1' >> kprobe_events # delete only A (matched by symbol), B survives echo '-:kprobes/ev vfs_read' >> kprobe_events
frees A's args (trace_probe_cleanup() -> traceprobe_free_probe_arg()), but trace_probe_unlink() keeps the trace_probe_event because the probe list is not empty. The event call stays registered via B while its fields now reference freed memory. Any field lookup then reads it, e.g.
echo 'a1 == 1' > events/kprobes/ev/filter
BUG: KASAN: slab-use-after-free in strcmp+0xa7/0xb0 Call Trace: strcmp trace_find_event_field parse_pred process_preds create_filter apply_event_filter event_filter_write
field->name references parg->name (kstrdup'd, freed with the probe) and, for array arguments, field->type references parg->fmt (kmalloc'd, freed with the probe) - the scalar type otherwise points at the static fmttype rodata, which is safe.
Have traceprobe_define_arg_fields() duplicate the name and type strings and anchor the copies on the trace_probe_event, which embeds the event call and outlives every individual probe; trace_probe_event_free() releases them.
The reproducer above triggers reliably; the field lookup and the delete both run under event_mutex, so this is a dangling reference after removal rather than a race.
The issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
--- kernel/trace/trace_probe.c | 48 +++++++++++++++++++++++++++++++++++++- kernel/trace/trace_probe.h | 2 ++ 2 files changed, 49 insertions(+), 1 deletion(-)
kernel/trace/trace_probe.c +47 -1
@@ -1876,19 +1876,60 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptypeint traceprobe_define_arg_fields (struct trace_event_call *event_call,size_t offset,struct trace_probe *tp) { +struct trace_probe_event *tpe =trace_probe_event_from_call (event_call);int ret, i; +/* +* A field created by trace_define_field() only stores the name and +* type pointers, it does not copy the strings. Here they point into +* the probe_arg of @tp, which is freed when @tp is removed. For an +* event with multiple probes attached, the field list is defined +* once by the first probe but kept alive by the surviving siblings, +* so removing that first probe would leave the fields referencing +* freed memory. Duplicate the strings and anchor the copies on the +* trace_probe_event, which lives as long as the field list itself. +* +* event_define_fields() ignores the return value of this hook, so +* if a previous attempt failed before creating any field, it may +* call here again. Release duplicates left behind by such an +* attempt before starting over. +*/ +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings); + tpe->field_strings =NULL ; + tpe->nr_field_strings =0 ; + +if (tp->nr_args) { + tpe->field_strings =kcalloc (tp->nr_args *2 ,sizeof (char *), +GFP_KERNEL ); +if (!tpe->field_strings) +return -ENOMEM ; + } +/* Set argument names as fields */ for (i =0 ; i < tp->nr_args; i++) {struct probe_arg *parg = &tp->args[i];const char *fmt = parg->type->fmttype;int size = parg->type->size; +char *name, *type;if (parg->fmt) fmt = parg->fmt;if (parg->count) size *= parg->count; - ret =trace_define_field (event_call, fmt, parg->name, + + name =kstrdup (parg->name,GFP_KERNEL ); + type =kstrdup (fmt,GFP_KERNEL ); +if (!name || !type) { +kfree (name); +kfree (type); +return -ENOMEM ; + } + tpe->field_strings[tpe->nr_field_strings++] = name; + tpe->field_strings[tpe->nr_field_strings++] = type; + + ret =trace_define_field (event_call, type, name, offset + parg->offset, size, parg->type->is_signed,FILTER_OTHER );
@@ -1900,6 +1941,11 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,static void trace_probe_event_free (struct trace_probe_event *tpe) { +int i; + +for (i =0 ; i < tpe->nr_field_strings; i++) +kfree (tpe->field_strings[i]); +kfree (tpe->field_strings);kfree (tpe->class.system);kfree (tpe->call.name);kfree (tpe->call.print_fmt);
kernel/trace/trace_probe.h +2 -0
@@ -252,6 +252,8 @@ struct trace_probe_event {struct trace_event_call call;struct list_head files;struct list_head probes; +char **field_strings; +int nr_field_strings;struct trace_uprobe_filter filter[]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/1193 bpf: reject BPF_PSEUDO_FUNC reference to the main program
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
[ Upstream commit 374b2c5561db80fcdd7cdce44af37a49416f61c7 ]
fixups.c:jit_subprogs() rewrites BPF_PSEUDO_FUNC loads to contain real function addresses. This function is invoked from bpf_jit_subprogs() only when env->subprog_cnt > 1. Meaning that for any program like below:
int main(void *ctx) {
void *ptr = main;
...
bpf_timer_set_callback(..., ptr);
...
}The 'ptr' won't be ever converted to contain an address.
In combination with e.g. bpf_timer_set_callback() this would lead to a function call at a bogus address.
Instead of complicating the implementation, just assume that no useful program needs main to be a sync or async callback and reject BPF_PSEUDO_FUNC loads for the main subprogram.
--- kernel/bpf/verifier.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/bpf/verifier.c +9 -0
@@ -14994,6 +14994,15 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)verbose (env,"callback function not static\n" );return -EINVAL ; } +/* +* When env->subprog_cnt == 1 this instruction won't be rewritten +* to hold a real function address. Assume that no usable program +* combines e.g. main and timer callback and just reject here. +*/ +if (subprogno ==0 ) { +verbose (env,"callback function cannot be the main program\n" ); +return -EINVAL ; + } dst_reg->type =PTR_TO_FUNC ; dst_reg->subprogno = subprogno;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/1193 bonding: do not clear curr_active_slave prematurely when releasing all slaves
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit af602c7aa5fedc9be3043244017aef4f26c96b70 ]
When releasing all slaves during bond destruction (all == true), __bond_release_one() unconditionally clears bond->curr_active_slave to NULL in every iteration.
If a backup slave is released before the active slave, bond_alb_deinit_slave() triggers rlb_teach_disabled_mac_on_primary(), which increments the active slave dev promiscuity counter and sets bond_info->primary_is_promisc = 1.
Because bond->curr_active_slave was prematurely cleared to NULL when releasing the backup slave, the subsequent iteration releasing the active slave evaluates oldcurrent as NULL, so bond_change_active_slave(bond, NULL) is skipped. Consequently, bond_alb_handle_active_change() is never called to decrement the promiscuity counter, permanently leaking promiscuous mode on the physical device after bond teardown.
When oldcurrent == slave, bond_change_active_slave(bond, NULL) already sets bond->curr_active_slave to NULL. We only need to avoid selecting a new active slave when all == true. Replace the if (all) branch with if (!all && oldcurrent == slave).
--- drivers/net/bonding/bond_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +1 -3
@@ -2496,9 +2496,7 @@ static int __bond_release_one(struct net_device *bond_dev,bond_alb_deinit_slave (bond, slave); } -if (all) { -RCU_INIT_POINTER (bond->curr_active_slave,NULL ); - }else if (oldcurrent == slave) { +if (!all && oldcurrent == slave) {/* Note that we hold RTNL over this sequence, so there * is no concern that another slave add/remove event * will interfere.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/1193 net/rds: use wq_has_sleeper() in release_in_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 6d0c8b7073913011459cf968cbbadd341e166bc3 ]
release_in_xmit() clears RDS_IN_XMIT with clear_bit_unlock() and then checks waitqueue_active() to decide whether anyone needs waking. clear_bit_unlock() is only a release operation: it orders the critical section before the bit clear, but does not order the subsequent plain load of the wait queue head after it. The waiter side does the mirror image - it adds itself to the wait queue and then tests the bit. That is the classic store-buffering pattern: the releasing CPU can read the wait queue as empty while the waiting CPU still reads the bit as set, so the sleeper is never woken.
The waiters are rds_conn_shutdown() and rds_tcp_reset_callbacks(), both in uninterruptible wait_event() with no timeout. A lost wake-up strands the shutdown worker on its single-threaded workqueue until some other sender releases the bit again - and on a connection that is being torn down precisely because it failed, there may never be another sender.
The barrier used to be there: release_in_xmit() did clear_bit() followed by smp_mb__after_atomic() until commit 1422f28826d2 ("rds:
introduce acquire/release ordering in acquire/release_in_xmit()") folded both into clear_bit_unlock(), which strengthened the lock hand-off but silently dropped the full barrier the wake-up check depends on. The refill counterpart, release_refill() in net/rds/ib_recv.c, still carries its smp_mb__after_atomic() for exactly this reason.
Use wq_has_sleeper(), which is waitqueue_active() preceded by the required full barrier.
--- net/rds/send.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/rds/send.c +6 -1
@@ -114,8 +114,13 @@ static void release_in_xmit(struct rds_conn_path *cp)* hot path and finding waiters is very rare. We don't want to walk * the system-wide hashed waitqueue buckets in the fast path only to * almost never find waiters. +* +* wq_has_sleeper() supplies the full barrier that orders the wait +* queue read after the bit clear; clear_bit_unlock() alone is only +* a release and would let this check read a stale empty queue, +* losing the wake-up. */ -if (waitqueue_active (&cp->cp_waitq)) +if (wq_has_sleeper (&cp->cp_waitq))wake_up_all (&cp->cp_waitq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/1193 net/rds: use clear_bit_unlock() in release_refill()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 17c4476dbb9c3bfd34193a6c22f2c3da8747134a ]
release_refill() drops the RDS_RECV_REFILL bit with a plain clear_bit(). clear_bit() has no ordering semantics, and the smp_mb__after_atomic() that follows it sits on the wrong side for a lock release: it orders the clear against the waitqueue_active() load below it, but does nothing to order the refill critical section's ring and descriptor stores before the clear itself.
That matters once connection teardown owns RDS_RECV_REFILL as a lock across the transport shutdown and path reset, rather than sampling it clear, which "net/rds: acquire the fastpath locks in rds_conn_shutdown()" later in this series arranges: on a weakly ordered architecture the teardown can win the bit and start the shutdown and reset while some of the refill's stores are not yet visible to it. The same gap existed under the sample-based scheme - a waiter that saw the bit clear had no guarantee it also observed the refill's stores - but taking the bit as a lock makes the missing release pairing load-bearing.
Switch to clear_bit_unlock(), which orders the critical section before the release, and replace the open-coded barrier-plus-waitqueue_active() with wq_has_sleeper(), whose internal full barrier keeps the store-buffering guarantee between clearing the bit and checking for sleepers. This mirrors what "net/rds: use wq_has_sleeper() in release_in_xmit()" does for RDS_IN_XMIT.
The fast-path acquire side, acquire_refill(), uses test_and_set_bit(), a full-barrier RMW that pairs with this release. The teardown at this point in the series still samples the bit, so on its own this change is release-side hardening; the shutdown-conversion patch named above makes the teardown acquire the bit with the same RMW, completing the pairing at the end of the series.
--- net/rds/ib_recv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/rds/ib_recv.c +2 -3
@@ -363,15 +363,14 @@ static int acquire_refill(struct rds_connection *conn)static void release_refill (struct rds_connection *conn) { -clear_bit (RDS_RECV_REFILL , &conn->c_flags); -smp_mb__after_atomic (); +clear_bit_unlock (RDS_RECV_REFILL , &conn->c_flags);/* We don't use wait_on_bit()/wake_up_bit() because our waking is in a * hot path and finding waiters is very rare. We don't want to walk * the system-wide hashed waitqueue buckets in the fast path only to * almost never find waiters. */ -if (waitqueue_active (&conn->c_waitq)) +if (wq_has_sleeper (&conn->c_waitq))wake_up_all (&conn->c_waitq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/1193 net/rds: clear cp_flags bits individually in rds_conn_path_reset()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 103c4b13c4f50322910078d1c02f29334a574122 ]
rds_conn_path_reset() wipes the whole flag word with a plain cp->cp_flags = 0 store. Every other accessor of that word uses atomic bitops, and some of them can run concurrently with the reset:RDS_LL_SEND_FULL is set from rds_send_xmit() and cleared from the transport completion paths, neither of which holds anything that excludes the shutdown worker. A plain store racing an atomic read-modify-write on the same word is a data race, and whichever side loses has its update silently discarded.
Clear the two bits the reset is actually responsible for instead. RDS_IN_XMIT and RDS_RECV_REFILL need no store at all here: they belong to the caller, rds_conn_shutdown(), which waits for both to be clear before calling the transport shutdown and this reset.
This also gives every bit in cp_flags a single well-defined writer discipline, which the following patches rely on when they turn RDS_IN_XMIT and RDS_RECV_REFILL into bit locks held across the
teardown: a blanket store mid-teardown would destroy lock ownership that an atomic clear preserves.
Oracle UEK carries the same conversion ("net/rds: Preserve essential connection state flags"), motivated by its asynchronous shutdown state machine, whose progress and destroy flags must survive the reset. UEK's variant also clears RDS_IN_XMIT and RDS_RECV_REFILL because there the reset runs as the final step of a teardown that owns both bits, making those clears its unlock. Upstream that release belongs in rds_conn_shutdown(): once a later patch in this series turns the two bits into locks held across the teardown, ending ownership needs release semantics and a wake-up that a plain clear inside the reset would not provide.
Based on Oracle UEK commit "net/rds: Preserve essential connection state flags" by Gerd Rausch.
--- net/rds/connection.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/rds/connection.c +9 -1
@@ -119,7 +119,15 @@ static void rds_conn_path_reset(struct rds_conn_path *cp)rds_stats_inc (s_conn_reset);rds_send_path_reset (cp); - cp->cp_flags =0 ; + +/* Clear the bits the reset is responsible for individually: a +* blanket cp_flags = 0 is a plain store that can clobber a +* concurrent atomic read-modify-write on the same word. +* RDS_IN_XMIT and RDS_RECV_REFILL belong to the caller, +* rds_conn_shutdown(), and are left alone here. +*/ +clear_bit (RDS_LL_SEND_FULL , &cp->cp_flags); +clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags);/* Do not clear next_rx_seq here, else we cannot distinguish * retransmitted packets from new packets, and will hand all
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/1193 net/rds: tcp: dont force RDS_CONN_RESETTING over a concurrent shutdown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerd Rausch <[email protected]>
[ Upstream commit e8e60d74fec49ccae2aea9b04a6eb162feb8d9af ]
rds_tcp_reset_callbacks() resolves a duelling SYN by storing RDS_CONN_RESETTING into cp_state unconditionally. Nothing serializes that store against the shutdown path: rds_tcp_accept_one() checks for RDS_CONN_CONNECTING or RDS_CONN_ERROR under t_conn_path_lock, but neither rds_conn_path_drop(), which forces RDS_CONN_ERROR, nor rds_conn_shutdown(), which moves the path to RDS_CONN_DISCONNECTING under cp_cm_lock, takes that lock. The store can therefore land on top of a shutdown that is already in progress, or that gets queued right after the accept-side check.
When it does, the shutdown worker's final DISCONNECTING -> DOWN transition fails and the path goes through rds_conn_path_error() and a second drop/shutdown cycle instead of a clean reconnect, tearing down the socket the accept path has just installed. Before commit ad22d24be635 ("net/rds: No shortcut out of RDS_CONN_ERROR") a path found in RDS_CONN_RESETTING even made rds_conn_shutdown() bail out altogether.
Make the transition conditional: move CONNECTING -> RESETTING (or stay in RESETTING from an earlier duel), and drop the path in any other state. The drop has side effects of its own: it replaces the shutdown's RDS_CONN_DISCONNECTING (or RDS_CONN_ERROR) with RDS_CONN_ERROR and queues one more cp_down_w run. The difference is that rds_conn_shutdown() accepts RDS_CONN_ERROR in its final transition to RDS_CONN_DOWN, so the shutdown in flight completes normally instead of through rds_conn_path_error(); the extra down-work pass then finds the path already down and falls through to the reconnect check, or catches a reconnect that has already started and restarts it. The accept path still installs the new socket, rds_connect_path_complete() then fails its RESETTING -> UP transition and drops it: the raced socket ends up torn down as it does today. The comment at that call site, which promised that rds_connect_path_complete() marks the path RDS_CONN_UP, is updated to name this outcome as well.
The state can change again between the failed transitions and the drop. That is inherent to rds_conn_path_drop(), which the socket state-change callbacks also call unconditionally, and costs at most one extra drop/reconnect cycle.
Based on Oracle UEK commit "net/rds: Don't force state RDS_CONN_RESETTING" by Gerd Rausch.
[achender: port to net-next: use the two-argument
rds_conn_path_transition()/rds_conn_path_drop() and rewrite the changelog for the upstream shutdown path]
--- net/rds/tcp.c | 17 +++++++++++++++-- net/rds/tcp_listen.c | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-)
net/rds/tcp.c +15 -2
@@ -149,9 +149,22 @@ void rds_tcp_reset_callbacks(struct socket *sock,* end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT * would not get set. As a result, we set c_state to * RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change -* cannot mark rds_conn_path_up() in the window before lock_sock() +* cannot mark rds_conn_path_up() in the window before lock_sock(). +* +* Only make that transition if the path is still connecting +* (or already resetting from an earlier duel). A path in any +* other state - typically RDS_CONN_DISCONNECTING or +* RDS_CONN_ERROR with a shutdown in flight - is dropped +* instead. That still replaces its state, with RDS_CONN_ERROR, +* and queues one more shutdown pass, but rds_conn_shutdown() +* accepts RDS_CONN_ERROR in its final transition to +* RDS_CONN_DOWN, so the shutdown in flight completes normally. */ -atomic_set (&cp->cp_state,RDS_CONN_RESETTING ); +if (!rds_conn_path_transition (cp,RDS_CONN_CONNECTING , +RDS_CONN_RESETTING ) && + !rds_conn_path_transition (cp,RDS_CONN_RESETTING , +RDS_CONN_RESETTING )) +rds_conn_path_drop (cp,0 );wait_event (cp->cp_waitq, !test_bit (RDS_IN_XMIT , &cp->cp_flags));/* reset receive side state for rds_tcp_data_recv() for osock */ cancel_delayed_work_sync (&cp->cp_send_w);
net/rds/tcp_listen.c +5 -1
@@ -197,7 +197,11 @@ int rds_tcp_accept_one(struct socket *sock)if (rs_tcp->t_sock) {/* Duelling SYN has been handled in rds_tcp_accept_one() */ rds_tcp_reset_callbacks (new_sock, cp); -/* rds_connect_path_complete() marks RDS_CONN_UP */ +/* rds_connect_path_complete() marks RDS_CONN_UP, or, +* if a concurrent shutdown won the duel, drops the +* path again and the pass that drop queues reaps the +* socket installed above. +*/ rds_connect_path_complete (cp,RDS_CONN_RESETTING ); }else {rds_tcp_set_callbacks (new_sock, cp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/1193 net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 02c5f9dc2efd823e061954d564ce00bacd1bebeb ]
rds_tcp_reset_callbacks() quiesces the transmit path by setting the path state to RDS_CONN_RESETTING and then waiting for RDS_IN_XMIT to be sampled clear before swapping the underlying socket and calling rds_send_path_reset().
Sampling the bit clear is not the same as owning it: rds_send_xmit() can re-acquire RDS_IN_XMIT right after the wait_event() returns. Its state recheck after taking the lock is a store-buffering pattern (the resetter writes the state and reads the bit, the sender writes the bit and reads the state) and acquire_in_xmit() is only an acquire operation, so on weakly ordered architectures both sides can miss each other's write and the transmit path then runs concurrently with rds_send_path_reset() rewriting cp_xmit_* state - which is exactly what the comment above rds_send_path_reset() tells its callers to prevent.
Take the lock instead, hold it across the socket swap and rds_send_path_reset(), and release it with a wake-up at the end. The lock-ordering constraint documented above the wait still holds: the lock is acquired before lock_sock(), so a sender inside tcp_sendmsg() can never be waited on while we hold the socket lock.
Two details of the old code go away with the same change:
- t_sock is now read only after the lock is acquired. The old code cached it before waiting; the teardown in rds_conn_shutdown() releases that socket and clears t_sock, so a pointer cached before the wait can be stale by the time the accept path resumes. Reading it under RDS_IN_XMIT is what makes the exclusion complete once the teardown owns the same lock, which the next patch arranges; until then the teardown still only samples the bit, and the two paths remain as exposed to each other as they are today.
- The old !osock early path called rds_send_path_reset() with no serialization at all. It now runs under the lock like the normal path. The conditional RDS_CONN_RESETTING transition of the previous patch happens before the socket check either way: a path found without a socket is either still connecting (its reconnect worker blocked on t_conn_path_lock) and legitimately goes RESETTING -> UP on the new socket, or it has been torn down meanwhile and is dropped.
The in-function comment describing the old wait-based quiesce is rewritten to describe the lock-based one, and the stale block comment above the function (which still described a return value and an incomplete list of t_sock writers) is refreshed to name all four writers - the connect, accept, teardown and swap paths - and what serializes each of them.
--- net/rds/tcp.c | 70 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 25 deletions(-)
net/rds/tcp.c +45 -25
@@ -114,42 +114,48 @@ void rds_tcp_restore_callbacks(struct socket *sock, }/* -* rds_tcp_reset_callbacks() switches the to the new sock and -* returns the existing tc->t_sock. +* rds_tcp_reset_callbacks() switches a path to a new socket and +* releases the old one it finds in tc->t_sock, resolving a duelling +* SYN. * -* The only functions that set tc->t_sock are rds_tcp_set_callbacks -* and rds_tcp_reset_callbacks. Send and receive trust that -* it is set. The absence of RDS_CONN_UP bit protects those paths -* from being called while it isn't set. +* tc->t_sock is set by rds_tcp_set_callbacks() and cleared by +* rds_tcp_restore_callbacks(). Four paths write it: the active +* connect in rds_tcp_conn_path_connect(), which sets it and clears it +* again on failure; the accept path in rds_tcp_accept_one(), which +* sets it for a path with no socket yet; the teardown in +* rds_tcp_conn_path_shutdown(), which clears it; and the swap done +* here, which does both. The connect and accept paths are serialized +* against each other by t_conn_path_lock. Send and receive trust +* that it is set: the absence of RDS_CONN_UP protects those paths +* from being called while it isn't, and the swap done here runs under +* RDS_IN_XMIT so that it cannot interleave with a sender already +* inside rds_send_xmit(). */ void rds_tcp_reset_callbacks (struct socket *sock,struct rds_conn_path *cp) {struct rds_tcp_connection *tc = cp->cp_transport_data; -struct socket *osock = tc->t_sock; - -if (!osock) - goto newsock; +struct socket *osock;/* Need to resolve a duelling SYN between peers. * We have an outstanding SYN to this peer, which may * potentially have transitioned to the RDS_CONN_UP state, * so we must quiesce any send threads before resetting -* cp_transport_data. We quiesce these threads by setting -* cp_state to something other than RDS_CONN_UP, and then -* waiting for any existing threads in rds_send_xmit to -* complete release_in_xmit(). (Subsequent threads entering -* rds_send_xmit() will bail on !rds_conn_up(). +* cp_transport_data. Setting cp_state to something other +* than RDS_CONN_UP stops new senders, and owning RDS_IN_XMIT +* excludes any thread already inside rds_send_xmit() for the +* whole socket swap and the rds_send_path_reset() below. * -* However an incoming syn-ack at this point would end up -* marking the conn as RDS_CONN_UP, and would again permit -* rds_send_xmi() threads through, so ideally we would -* synchronize on RDS_CONN_UP after lock_sock(), but cannot -* do that: waiting on !RDS_IN_XMIT after lock_sock() may -* end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT -* would not get set. As a result, we set c_state to -* RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change -* cannot mark rds_conn_path_up() in the window before lock_sock(). +* An incoming syn-ack at this point would end up marking the +* conn as RDS_CONN_UP, and would again permit rds_send_xmit() +* threads through, so ideally we would synchronize on +* RDS_CONN_UP after lock_sock(), but cannot do that: acquiring +* RDS_IN_XMIT after lock_sock() may end up deadlocking with +* tcp_sendmsg(), which takes the socket lock while holding +* RDS_IN_XMIT. As a result, we set c_state to +* RDS_CONN_RESETTING, to ensure that rds_tcp_state_change +* cannot mark rds_conn_path_up() in the window before +* lock_sock(). * * Only make that transition if the path is still connecting * (or already resetting from an earlier duel). A path in any
@@ -165,7 +171,18 @@ void rds_tcp_reset_callbacks(struct socket *sock, !rds_conn_path_transition(cp, RDS_CONN_RESETTING, RDS_CONN_RESETTING))rds_conn_path_drop (cp,0 ); -wait_event (cp->cp_waitq, !test_bit (RDS_IN_XMIT , &cp->cp_flags)); +wait_event (cp->cp_waitq, + !test_and_set_bit_lock (RDS_IN_XMIT , &cp->cp_flags)); + +/* Read t_sock only while owning RDS_IN_XMIT, never before the +* wait: the teardown in rds_conn_shutdown() releases the old +* socket and clears t_sock, so a pointer sampled earlier can +* be stale by the time we wake up. +*/ + osock = tc->t_sock; +if (!osock) + goto newsock; +/* reset receive side state for rds_tcp_data_recv() for osock */ cancel_delayed_work_sync (&cp->cp_send_w);cancel_delayed_work_sync (&cp->cp_recv_w);
@@ -184,6 +201,9 @@ void rds_tcp_reset_callbacks(struct socket *sock,lock_sock (sock->sk);rds_tcp_set_callbacks (sock, cp);release_sock (sock->sk); + +clear_bit_unlock (RDS_IN_XMIT , &cp->cp_flags); +wake_up_all (&cp->cp_waitq); }/* Add tc to rds_tcp_tc_list and set tc->t_sock. See comments
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/1193 net/rds: acquire the fastpath locks in rds_conn_shutdown()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Håkon Bugge <[email protected]>
[ Upstream commit 813f3582ac7ae9f60f917937d54660e0952d5f2d ]
rds_conn_shutdown() quiesces the transmit and receive-refill paths by waiting for RDS_IN_XMIT and RDS_RECV_REFILL to be sampled clear, and then runs the transport shutdown and rds_conn_path_reset(). Sampling the bits clear is not the same as owning them: the moment after the wait_event() returns, rds_send_xmit() can re-acquire RDS_IN_XMIT (or rds_ib_recv_refill() can re-acquire RDS_RECV_REFILL) and run concurrently with the teardown.
The sender does recheck the connection state after taking the lock, but that recheck is a classic store-buffering pattern: teardown writes the state and reads the bit while the sender writes the bit and reads the state. acquire_in_xmit() is only an acquire operation, so on weakly ordered architectures both sides can miss each other's write, and the transmit path then runs while the transport zeroes its rings (e.g. rds_ib_ring_init()) and rds_send_path_reset() rewrites the transmit state under it.
Oracle UEK fixed the same class of crashes - a 14-year tail of BUG_ON()s in rds_ib_sub_signaled(), unexpected op-codes and NULL dereferences in rds_ib_send_cqe_handler() during failover testing - by making the teardown path *acquire* the fastpath bit locks instead of testing them ("rds: Make sure transmit path and connection tear-down does not run concurrently"). Ownership of a single word is decided by RMW atomicity, so no cross-variable ordering is needed.
Do the same here: take both locks before calling the transport shutdown, hold them across rds_conn_path_reset(), and release them explicitly with a wake-up afterwards. Both are released with clear_bit_unlock(), so that the ring re-initialization done by the transport shutdown and the transmit state rewritten by rds_send_path_reset() are ordered before either bit is seen clear by the next acquire_in_xmit() or acquire_refill().
The fastpath users of these bits - rds_send_xmit() and rds_ib_recv_refill() - are trylock style and back off while teardown owns the locks, so no new lock dependency is introduced for them. rds_tcp_reset_callbacks() is different: since the previous patch it acquires RDS_IN_XMIT as well, and it blocks doing so, so its wait now spans the teardown instead of at most one send batch. That waiter runs from rds_tcp_accept_one() on the single-threaded krdsd workqueue and holds rds_tcp_accept_lock and t_conn_path_lock while it waits, so a duelling SYN accepted while its path is being torn down parks accept processing for the duration of the teardown - for TCP bounded by the (up to 5 s) drain loop in rds_tcp_conn_path_shutdown(). An IB path's drain in rds_ib_conn_path_shutdown() has no round cap, but no blocking waiter either: rds_tcp_reset_callbacks() is the only blocking acquirer of these bits and waits only on its own TCP path, and the fastpaths are trylock-and-back-off on both transports, so a long IB drain lengthens only that path's own quiesce. The
window is narrow: the accept-side state check has to pass before the teardown moves the path to RDS_CONN_DISCONNECTING.
Because krdsd is a single global workqueue, everything else queued there - accept processing for other connections and network namespaces, and the flush_workqueue(rds_wq) in rds_tcp_listen_stop() during namespace teardown - waits behind the parked accept worker for that time. It cannot deadlock, although the waits do point at each
other: the teardown blocks until the bit's holder releases it, and the holder may be that krdsd accept worker. The holder finishes without needing anything the teardown owns: the sync cancels rds_tcp_reset_callbacks() issues target cp_send_w and cp_recv_w on the path's ordered cp_wq, whose only execution slot is occupied by the blocked cp_down_w itself, so they are pending at most and cancel without flushing - a reliance on cp_wq being ordered that is now noted next to those cancels (on the allocation-failure fallback where a path shares rds_wq, the work items simply serialize). Nor is the blocking wait itself new: rds_tcp_reset_callbacks() has waited on RDS_IN_XMIT from the krdsd work item since commit 335b48d980f6 ("RDS: TCP: Add/use rds_tcp_reset_callbacks to reset tcp socket safely"); this patch stretches its worst case from a sender's batch to the teardown's drain. The alternative to parking is the accept path racing the teardown, which is what these patches close; making the teardown itself non-blocking is a separate item.
One observable side effect: the SENDING flag reported by rds-info has always mirrored RDS_IN_XMIT, so it now also covers the window where teardown owns the bit.
The comments that describe the old sample-based handshake or name rds_send_xmit() as the only other holder of these bits - in rds_send_xmit(), above rds_conn_path_reset(), in rds_ib_recv_refill() and in rds_tcp_reset_callbacks() - are updated to match.
For anyone backporting this patch standalone: it depends on "net/rds: clear cp_flags bits individually in rds_conn_path_reset()" and "net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()" earlier in this series. Without the former, the blanket cp_flags clear in rds_conn_path_reset() would drop both held bits in the middle of the teardown; without the latter, rds_tcp_reset_callbacks() would still sample t_sock without owning RDS_IN_XMIT. "net/rds: use clear_bit_unlock() in release_refill()" is needed for the refill side's release to pair with the acquire added here, and the follow-up "net/rds: don't let rds_conn_shutdown() consume a concurrent drop" completes the teardown-state handling for the waiter this patch parks; a backport should carry all four.
[achender: reimplement for net-next shutdown path: acquire the existing
RDS_IN_XMIT/RDS_RECV_REFILL bit locks in rds_conn_shutdown() and release after teardown; update comments and commit message]
--- net/rds/connection.c | 40 ++++++++++++++++++++++++++++++++-------- net/rds/ib_recv.c | 4 +++- net/rds/send.c | 7 +++++-- net/rds/tcp.c | 19 +++++++++++++++---- 4 files changed, 55 insertions(+), 15 deletions(-)
net/rds/connection.c +32 -8
@@ -105,10 +105,12 @@ static struct rds_connection *rds_conn_lookup(struct net *net, }/* -* This is called by transports as they're bringing down a connection. -* It clears partial message state so that the transport can start sending -* and receiving over this connection again in the future. It is up to -* the transport to have serialized this call with its send and recv. +* This is called by rds_conn_shutdown() once the transport has brought +* a path down. It clears partial message state so that the transport +* can start sending and receiving over this path again in the future. +* The caller owns RDS_IN_XMIT and RDS_RECV_REFILL across this call, +* which is what serializes it against the send and receive-refill +* paths. */ static void rds_conn_path_reset (struct rds_conn_path *cp) {
@@ -123,8 +125,9 @@ static void rds_conn_path_reset(struct rds_conn_path *cp)/* Clear the bits the reset is responsible for individually: a * blanket cp_flags = 0 is a plain store that can clobber a * concurrent atomic read-modify-write on the same word. -* RDS_IN_XMIT and RDS_RECV_REFILL belong to the caller, -* rds_conn_shutdown(), and are left alone here. +* RDS_IN_XMIT and RDS_RECV_REFILL are held as locks by the +* caller, rds_conn_shutdown(), which releases them once the +* teardown is complete. */ clear_bit (RDS_LL_SEND_FULL , &cp->cp_flags);clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags);
@@ -400,14 +403,35 @@ void rds_conn_shutdown(struct rds_conn_path *cp) }mutex_unlock (&cp->cp_cm_lock); +/* Quiesce the transmit and receive-refill paths by +* acquiring their bit locks, not merely waiting for +* them to be released: with a plain wait, either path +* can re-take its lock the instant after we sample it +* clear and then run concurrently with the transport +* shutdown and the path reset below. Holding both +* locks across the teardown makes that structurally +* impossible. +*/ wait_event (cp->cp_waitq, - !test_bit (RDS_IN_XMIT , &cp->cp_flags)); + !test_and_set_bit_lock (RDS_IN_XMIT , &cp->cp_flags));wait_event (cp->cp_waitq, - !test_bit (RDS_RECV_REFILL , &cp->cp_flags)); + !test_and_set_bit (RDS_RECV_REFILL , &cp->cp_flags)); conn->c_trans->conn_path_shutdown (cp);rds_conn_path_reset (cp); +/* Release the two locks and wake any waiter (e.g. +* rds_tcp_reset_callbacks()) that blocked on them while +* we held them. The unlock orders the transport's ring +* re-initialization and the path reset above before +* either bit is seen clear. rds_conn_path_reset() leaves +* both bits alone: ownership ends here, not inside the +* reset. +*/ +clear_bit_unlock (RDS_IN_XMIT , &cp->cp_flags); +clear_bit_unlock (RDS_RECV_REFILL , &cp->cp_flags); +wake_up_all (&cp->cp_waitq); +if (!rds_conn_path_transition (cp,RDS_CONN_DISCONNECTING ,RDS_CONN_DOWN ) && !rds_conn_path_transition(cp, RDS_CONN_ERROR,
net/rds/ib_recv.c +3 -1
@@ -391,7 +391,9 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)/* the goal here is to just make sure that someone, somewhere * is posting buffers. If we can't get the refill lock, -* let them do their thing +* let them do their thing. The holder may also be +* rds_conn_shutdown() tearing the path down, in which case +* there is nothing to post. */ if (!acquire_refill (conn))return ;
net/rds/send.c +5 -2
@@ -185,8 +185,11 @@ int rds_send_xmit(struct rds_conn_path *cp)WRITE_ONCE (cp->cp_send_gen, send_gen);/* -* rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT, -* we do the opposite to avoid races. +* rds_conn_shutdown() sets the conn state and then acquires +* RDS_IN_XMIT; we take the lock first and then check the state. +* Ownership is decided by the atomic RMW on the cp_flags word: +* if the teardown won the bit we back off here, and if we won +* it the teardown waits until we release it. */ if (!rds_conn_path_up (cp)) {release_in_xmit (cp);
net/rds/tcp.c +15 -4
@@ -143,8 +143,10 @@ void rds_tcp_reset_callbacks(struct socket *sock,* so we must quiesce any send threads before resetting * cp_transport_data. Setting cp_state to something other * than RDS_CONN_UP stops new senders, and owning RDS_IN_XMIT -* excludes any thread already inside rds_send_xmit() for the -* whole socket swap and the rds_send_path_reset() below. +* excludes any thread already inside rds_send_xmit() - or a +* teardown in rds_conn_shutdown(), which holds the same lock +* for the duration of the transport shutdown - for the whole +* socket swap and the rds_send_path_reset() below. * * An incoming syn-ack at this point would end up marking the * conn as RDS_CONN_UP, and would again permit rds_send_xmit()
@@ -177,13 +179,22 @@ void rds_tcp_reset_callbacks(struct socket *sock,/* Read t_sock only while owning RDS_IN_XMIT, never before the * wait: the teardown in rds_conn_shutdown() releases the old * socket and clears t_sock, so a pointer sampled earlier can -* be stale by the time we wake up. +* be stale by the time we wake up. The teardown holds the +* same lock while it does so, so what we read here cannot +* change under us until we release it. */ osock = tc->t_sock;if (!osock) goto newsock; -/* reset receive side state for rds_tcp_data_recv() for osock */ +/* reset receive side state for rds_tcp_data_recv() for osock. +* +* The sync cancels while owning RDS_IN_XMIT rely on cp_wq +* being ordered: a teardown blocked on the bit occupies +* cp_wq's only execution slot, so cp_send_w and cp_recv_w are +* pending at most and the cancels never flush. Nothing here +* may flush or wait on cp_wq itself. +*/ cancel_delayed_work_sync (&cp->cp_send_w);cancel_delayed_work_sync (&cp->cp_recv_w);lock_sock (osock->sk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/1193 net/rds: dont let rds_conn_shutdown() consume a concurrent drop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 260c6308fe2e19ad519389d44d582e292aecc3af ]
rds_conn_shutdown() finishes by moving the path from RDS_CONN_DISCONNECTING to RDS_CONN_DOWN, and also accepts RDS_CONN_ERROR as the starting state of that final transition, so that a FIN processed in softirq context during the teardown does not derail the shutdown into a noisy error path.
But consuming that RDS_CONN_ERROR also consumes the shutdown pass that came with it: rds_conn_path_drop() sets RDS_CONN_ERROR and then queues cp_down_w, and a pass that starts on a path already in RDS_CONN_DOWN is a no-op. For the FIN case that is harmless - the socket the FIN arrived on is the very socket the teardown just released. It is not harmless for a dropper that attached something to the path first.
rds_tcp_accept_one() is such a dropper. Its path claim in rds_tcp_accept_one_path() transitions RDS_CONN_DOWN -> RDS_CONN_CONNECTING, and a concurrent drop - a FIN on a previous socket in softirq context, an administrative reset - can put the path into RDS_CONN_ERROR between that claim and the state check that follows, which accepts RDS_CONN_ERROR. The accept then installs the freshly accepted socket with rds_tcp_set_callbacks() while the queued teardown - which sampled tc->t_sock before this socket existed - is still running. rds_connect_path_complete() fails its transition to RDS_CONN_UP and drops the path again, queueing the pass that should reap the socket it just installed. If the in-flight shutdown's final transition consumes that drop's RDS_CONN_ERROR, the queued pass finds the path in RDS_CONN_DOWN and does nothing. The installed socket is never torn down: it sits established with its callbacks armed and its rds_tcp_connection on rds_tcp_tc_list, the peer sees a connection that nothing ever reads, and the path is wedged in RDS_CONN_DOWN until some later event drops it again. Reproduced with widened race windows as an ever-growing receive queue on a socket owned by a path stuck in RDS_CONN_DOWN, with the peer's send path wedged behind it.
Make the final transition only DISCONNECTING -> DOWN. If it fails because the path is in RDS_CONN_ERROR, a drop raced the teardown:
cancel the reconnect timer and clear RDS_RECONNECT_PENDING - the one piece of the skipped tail that must not be left behind - and return, letting the pass the drop queued finish the job: it tears down whatever attached to the path in the meantime, completes the transition to RDS_CONN_DOWN, and re-arms the reconnect from its own tail.
The timer quiesce in that branch matters because the racing drop does not always queue that pass: rds_conn_path_drop() returns without queueing when a destroy is pending - exactly the situation during a netns teardown or module unload, when a FIN on the dying socket is processed while rds_conn_path_destroy() flushes cp_down_w. If the flushed pass is the one that takes this return, no later pass exists, and rds_conn_path_destroy() would find cp_conn_w still armed (WARN_ON) and then free a path whose reconnect timer can still fire. With the cancel in the branch, every exit of a shutdown pass leaves the timer quiesced no matter which pass completes the transition.
The FIN case keeps making progress, one pass later and still without noisy logging. Any other state keeps today's rds_conn_path_error() handling; no current cp_state writer can leave a DISCONNECTING path in anything but RDS_CONN_ERROR (every other writer is a cmpxchg from a non-DISCONNECTING state), so that branch is defensive.
On kernels without the preceding patches the same hazard exists with the sample-based quiesce; the fix applies there equally.
--- net/rds/connection.c | 43 ++++++++++++++++++++++++++++++++----------- net/rds/tcp.c | 9 ++++++--- 2 files changed, 38 insertions(+), 14 deletions(-)
net/rds/connection.c +32 -11
@@ -433,19 +433,40 @@ void rds_conn_shutdown(struct rds_conn_path *cp)wake_up_all (&cp->cp_waitq);if (!rds_conn_path_transition (cp,RDS_CONN_DISCONNECTING , -RDS_CONN_DOWN ) && - !rds_conn_path_transition (cp,RDS_CONN_ERROR ,RDS_CONN_DOWN )) { -/* This can happen - eg when we're in the middle of tearing -* down the connection, and someone unloads the rds module. -* Quite reproducible with loopback connections. -* Mostly harmless. +/* The path was dropped again while we tore it +* down: by a socket state-change callback in +* irq context on receipt of a FIN, or by an +* accept that claimed the path just before a +* drop put it back to RDS_CONN_ERROR and then +* installed a fresh socket on it. Unless a +* pending destroy suppressed it, the drop also +* queued another shutdown pass, and that pass +* must run, because it is what tears down +* whatever attached to the path after the +* transport shutdown above sampled its state. +* Consuming the RDS_CONN_ERROR here would turn +* that pass into a no-op: leave the state +* alone, and let the pass finish the job. * -* Note that this also happens with rds-tcp because -* we could have triggered rds_conn_path_drop in irq -* mode from rds_tcp_state change on the receipt of -* a FIN, thus we need to recheck for RDS_CONN_ERROR -* here. +* Quiesce the reconnect timer before bailing +* out, though. When a pending destroy did +* suppress the queue, no later pass runs, and +* rds_conn_path_destroy() is about to flush +* cp_down_w and free the path: it must not +* find cp_conn_w still armed. A successor +* pass, when there is one, re-arms the +* reconnect from its own tail. +*/ +cancel_delayed_work_sync (&cp->cp_conn_w); +clear_bit (RDS_RECONNECT_PENDING , &cp->cp_flags); + +if (rds_conn_path_state (cp) ==RDS_CONN_ERROR ) +return ; +/* No current cp_state writer leaves a +* DISCONNECTING path in any state but +* RDS_CONN_ERROR; report loudly if one ever +* does. */ rds_conn_path_error (cp,"%s: failed to transition " "to state DOWN, current state "
net/rds/tcp.c +6 -3
@@ -164,9 +164,12 @@ void rds_tcp_reset_callbacks(struct socket *sock,* other state - typically RDS_CONN_DISCONNECTING or * RDS_CONN_ERROR with a shutdown in flight - is dropped * instead. That still replaces its state, with RDS_CONN_ERROR, -* and queues one more shutdown pass, but rds_conn_shutdown() -* accepts RDS_CONN_ERROR in its final transition to -* RDS_CONN_DOWN, so the shutdown in flight completes normally. +* and, unless a pending destroy is about to reap the whole +* connection anyway, queues one more shutdown pass. A shutdown +* already in flight leaves that RDS_CONN_ERROR alone when it +* finishes; the queued pass then completes the transition to +* RDS_CONN_DOWN and tears down anything that attached to the +* path in the meantime. */ if (!rds_conn_path_transition(cp, RDS_CONN_CONNECTING, RDS_CONN_RESETTING) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/1193 net: stmmac: reconfigure RX packet parser table in stmmac_hw_setup() after reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 6b8fed2675fb75d23e6cf2b7e49c94926e884b34 ]
The core software reset issued in stmmac_init_dma_engine() during ndo_open() callback clears the MTL RX packet parser registers, but stmmac_rxp_config() is only invoked from the cls_u32 add/delete paths. After an ifdown/ifup cycle the hardware therefore runs with the default all-pass table while priv->tc_entries still reports the filters as installed. Re-apply the RX packet parser table from priv->tc_entries in stmmac_hw_setup(), right after the software reset, so the filters are restored when the interface is brought up again.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 -0
@@ -3330,6 +3330,14 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)/* Initialize MTL*/ stmmac_mtl_configuration (priv); +/* Apply the RX packet parser table */ +if (priv->tc_entries) { + ret =stmmac_rxp_config (priv, priv->hw->pcsr, priv->tc_entries, + priv->tc_entries_max); +if (ret) +return ret; + } +/* Initialize Safety Features */ stmmac_safety_feat_configuration (priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/1193 selftests/alsa: Fix the step check for INTEGER controls
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8efd5f623c63584c2e284a837a7795d95a0491cb ]
The modulo sits inside the subtraction, so the check evaluates int_val - (min % step) rather than (int_val - min) % step. The INTEGER64 branch below it is parenthesised correctly.
The written form passes only when the value equals min % step, and such a value is always on a step boundary, so it never misses a real violation. It only reports valid values as invalid.
snd-aloop declares step 1 on four controls, so every non-zero value on them is reported. Before:
# PCM Rate Shift 100000.0 value 100000 invalid for step 1 minimum 80000 # Totals: pass:660 fail:101 xfail:0 xpass:0 skip:296 error:0
After, same card, nothing else changed:
# Totals: pass:740 fail:21 xfail:0 xpass:0 skip:296 error:0
Eighteen files under sound/ declare a non-zero step.
--- tools/testing/selftests/alsa/mixer-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/alsa/mixer-test.c +2 -2
@@ -299,8 +299,8 @@ static bool ctl_value_index_valid(struct ctl_data *ctl,/* Only check step size if there is one and we're in bounds */ if (snd_ctl_elem_info_get_step (ctl->info) && - (int_val -snd_ctl_elem_info_get_min (ctl->info) % -snd_ctl_elem_info_get_step (ctl->info))) { + (int_val -snd_ctl_elem_info_get_min (ctl->info)) % +snd_ctl_elem_info_get_step (ctl->info)) { ksft_print_msg("%s.%d value %ld invalid for step %ld minimum %ld\n", ctl->name, index, int_val, snd_ctl_elem_info_get_step(ctl->info),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/1193 ALSA: caiaq: Fix potential double-free at error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 3b26ceef88c110f4d188387cffa0df78657be904 ]
The fix for caiaq driver's resource management to handle the errors tries to release the resources in a common destructor call, but as a sashiko review for another patch suggested, some of the audio resources such as URBs have been already freed, and this may lead to a double-free.
For addressing the double-free, call the common destructor function from each place, and assure that the resource pointers get cleared.
--- sound/usb/caiaq/audio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/usb/caiaq/audio.c +5 -5
@@ -853,16 +853,13 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) cdev->data_urbs_in =alloc_urbs (cdev,SNDRV_PCM_STREAM_CAPTURE , &ret);if (ret <0 ) { -kfree (cdev->data_cb_info); -free_urbs (cdev->data_urbs_in); +snd_usb_caiaq_audio_free (cdev);return ret; } cdev->data_urbs_out =alloc_urbs (cdev,SNDRV_PCM_STREAM_PLAYBACK , &ret);if (ret <0 ) { -kfree (cdev->data_cb_info); -free_urbs (cdev->data_urbs_in); -free_urbs (cdev->data_urbs_out); +snd_usb_caiaq_audio_free (cdev);return ret; }
@@ -883,6 +880,9 @@ void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev)dev_dbg (dev,"%s(%p)\n" , __func__, cdev);free_urbs (cdev->data_urbs_in); + cdev->data_urbs_in =NULL ;free_urbs (cdev->data_urbs_out); + cdev->data_urbs_out =NULL ;kfree (cdev->data_cb_info); + cdev->data_cb_info =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/1193 bpf: Fix NULL-ptr-deref when showing a void BTF type
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 4ea508b9ebd78bce7f212166d2e2cba66b875f08 ]
btf_modifier_show() resolves the modifier and then calls btf_type_ops(t)->show() unconditionally. For the void type (type_id 0, BTF_KIND_UNKN) kind_ops[] has no entry, so ->show is NULL.
A "const void" (a modifier resolving to void) cannot be a map key or value - map_check_btf() rejects it because void has no size - so the map dump path does not reach it. But bpf_snprintf_btf() takes a type_id straight from the BPF program, and passing such a "const void" from the vmlinux BTF NULL-derefs:
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] RIP: 0010:btf_modifier_show (kernel/bpf/btf.c:2914) Call Trace: <TASK> btf_type_show (kernel/bpf/btf.c:8251) btf_type_snprintf_show (kernel/bpf/btf.c:8321) bpf_snprintf_btf (kernel/trace/bpf_trace.c:1047) bpf_prog_test_run_raw_tp (net/bpf/test_run.c:829) __sys_bpf (kernel/bpf/syscall.c:4804) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Fall back to btf_df_show() when the resolved type has no show op; it emits the "<unsupported kind:N>" placeholder already used for kinds like FWD and FUNC. bpf_snprintf_btf() then returns the length as usual.
--- kernel/bpf/btf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +8 -1
@@ -2718,7 +2718,14 @@ static void btf_modifier_show(const struct btf *btf,else t =btf_type_skip_modifiers (btf, type_id,NULL ); -btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); +/* +* A modifier can resolve to void, which has no show op; print a +* placeholder rather than dereferencing NULL. +*/ +if (!btf_type_ops (t)) +btf_df_show (btf, t, type_id, data, bits_offset, show); +else +btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); } static void btf_var_show(const struct btf *btf, const struct btf_type *t,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/1193 bpf: Fix NULL-ptr-deref in btf_var_show()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 5403a383f52fc0905703b488f7c3db4b2447dc58 ]
btf_var_show() calls btf_type_id_resolve() unconditionally, which dereferences btf->resolved_ids. That is NULL for a base BTF - e.g. the vmlinux BTF that bpf_snprintf_btf() renders against - since base BTF is not resolved during parsing. btf_modifier_show() guards this with 'if (btf->resolved_ids)', but btf_var_show() does not.
A BPF program that passes the type_id of a BTF_KIND_VAR from the vmlinux BTF to bpf_snprintf_btf() thus NULL-derefs:
KASAN: probably user-memory-access in range [0x46638-0x4663f] RIP: 0010:btf_var_show (kernel/bpf/btf.c:2929) Call Trace: <TASK> btf_type_show (kernel/bpf/btf.c:8259) btf_type_snprintf_show (kernel/bpf/btf.c:8329) bpf_snprintf_btf (kernel/trace/bpf_trace.c:1047) bpf_prog_test_run_raw_tp (net/bpf/test_run.c:829) __sys_bpf (kernel/bpf/syscall.c:4804) do_syscall_64 (arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) </TASK>
Resolve the var's type directly with btf_type_skip_modifiers() when resolved_ids is NULL, mirroring btf_modifier_show().
--- kernel/bpf/btf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +9 -1
@@ -2732,7 +2732,15 @@ static void btf_var_show(const struct btf *btf, const struct btf_type *t, u32 type_id, void *data, u8 bits_offset, struct btf_show *show) { - t =btf_type_id_resolve (btf, &type_id); + /* + * btf_type_id_resolve() dereferences btf->resolved_ids, which is NULL + * for a base BTF (e.g. the vmlinux BTF that bpf_snprintf_btf() uses). + * Resolve the var's type directly in that case. + */ + if (btf->resolved_ids) + t =btf_type_id_resolve (btf, &type_id); + else + t =btf_type_skip_modifiers (btf, t->type, &type_id);btf_type_ops (t)->show (btf, t, type_id, data, bits_offset, show); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/1193 nvme_core: scan namespaces asynchronously
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stuart Hayes <[email protected]>
[ Upstream commit 4e893ca8117022de68ce1b61c0309e3d17bb8a25 ]
Use async function calls to make namespace scanning happen in parallel.
Without the patch, NVME namespaces are scanned serially, so it can take a long time for all of a controller's namespaces to become available, especially with a slower (TCP) interface with large number of namespaces.
It is not uncommon to have large numbers (hundreds or thousands) of namespaces on nvme-of with storage servers.
The time it took for all namespaces to show up after connecting (via TCP) to a controller with 1002 namespaces was measured on one system:
network latency without patch with patch
0 6s 1s
50ms 210s 10s
100ms 417s 18s
Measurements taken on another system show the effect of the patch on the time nvme_scan_work() took to complete, when connecting to a linux nvme-of target with varying numbers of namespaces, on a network of 400us.
namespaces without patch with patch
1 16ms 14ms
2 24ms 16ms
4 49ms 22ms
8 101ms 33ms
16 207ms 56ms 100 1.4s 0.6s
1000 12.9s 2.0s
On the same system, connecting to a local PCIe NVMe drive (a Samsung PM1733) instead of a network target:
namespaces without patch with patch
1 13ms 12ms
2 41ms 13msStable-dep-of: 4ed7f3d7d435 ("nvme: remove stale namespaces by NSID range during scan")
--- drivers/nvme/host/core.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +39 -1
@@ -4,6 +4,7 @@* Copyright (c) 2011-2014, Intel Corporation. */ +#include <linux/async.h> #include <linux/blkdev.h> #include <linux/blk-mq.h> #include <linux/blk-integrity.h>
@@ -3829,6 +3830,35 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid) } } +/** +* struct async_scan_info - keeps track of controller & NSIDs to scan +* @ctrl: Controller on which namespaces are being scanned +* @next_nsid: Index of next NSID to scan in ns_list +* @ns_list: Pointer to list of NSIDs to scan +* +* Note: There is a single async_scan_info structure shared by all instances +* of nvme_scan_ns_async() scanning a given controller, so the atomic +* operations on next_nsid are critical to ensure each instance scans a unique +* NSID. +*/ +struct async_scan_info { +struct nvme_ctrl *ctrl; +atomic_t next_nsid; +__le32 *ns_list; +}; + +static void nvme_scan_ns_async (void *data,async_cookie_t cookie) +{ +struct async_scan_info *scan_info = data; +int idx; +u32 nsid; + + idx = (u32 )atomic_fetch_inc (&scan_info->next_nsid); + nsid =le32_to_cpu (scan_info->ns_list[idx]); + +nvme_scan_ns (scan_info->ctrl, nsid); +} +static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl,unsigned nsid) {
@@ -3855,11 +3885,15 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl)__le32 *ns_list;u32 prev =0 ;int ret =0 , i; +ASYNC_DOMAIN (domain); +struct async_scan_info scan_info; ns_list =kzalloc (NVME_IDENTIFY_DATA_SIZE ,GFP_KERNEL );if (!ns_list)return -ENOMEM ; + scan_info.ctrl = ctrl; + scan_info.ns_list = ns_list;for (;;) {struct nvme_command cmd = { .identify.opcode = nvme_admin_identify,
@@ -3875,19 +3909,23 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl) goto free; } +atomic_set (&scan_info.next_nsid,0 );for (i =0 ; i < nr_entries; i++) {u32 nsid =le32_to_cpu (ns_list[i]);if (!nsid)/* end of the list? */ goto out; -nvme_scan_ns (ctrl, nsid); +async_schedule_domain (nvme_scan_ns_async, &scan_info, + &domain);while (++prev < nsid)nvme_ns_remove_by_nsid (ctrl, prev); } +async_synchronize_full_domain (&domain); } out:nvme_remove_invalid_namespaces (ctrl, prev); free: +async_synchronize_full_domain (&domain);kfree (ns_list);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/1193 nvme: remove stale namespaces by NSID range during scan
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Khalfella <[email protected]>
[ Upstream commit 4ed7f3d7d435bf5b63da2814dc9270f5ba896011 ]
nvme_scan_ns_list() drops the stale namespaces in each gap in the reported NSID list one NSID at a time. Every iteration calls nvme_find_get_ns() to look the namespace up and removes it if it is present. The loop runs once per NSID in the gap rather than once per namespace actually present.
NSIDs are 32-bit, so a target with a sparse NSID space can make a single gap spin the loop billions of times with nothing to remove.
watchdog: BUG: soft lockup - CPU#4 stuck for 26s! Workqueue: nvme-wq nvme_scan_work [nvme_core] RIP: 0010:__srcu_read_unlock+0xb/0x20 Call Trace: nvme_find_get_ns+0x7d/0xb0 [nvme_core] nvme_scan_ns_list+0xe8/0x280 [nvme_core] nvme_scan_work+0x18a/0x280 [nvme_core] process_one_work+0x197/0x380 worker_thread+0x2fe/0x410 kthread+0xe0/0x100
Rename nvme_remove_invalid_namespaces() to nvme_remove_nsid_range() and give it an open (start, end) NSID range. ctrl->namespaces is sorted by NSID, so the whole gap is dropped in a single walk that stops once end is reached. This bounds the work by the namespaces that are present instead of by the size of the gap.
--- drivers/nvme/host/core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/nvme/host/core.c +9 -9
@@ -122,8 +122,6 @@ static dev_t nvme_ns_chr_devt;static struct class *nvme_ns_chr_class;static void nvme_put_subsystem (struct nvme_subsystem *subsys); -static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl, -unsigned nsid);static void nvme_update_keep_alive (struct nvme_ctrl *ctrl,struct nvme_command *cmd);
@@ -3859,15 +3857,16 @@ static void nvme_scan_ns_async(void *data, async_cookie_t cookie)nvme_scan_ns (scan_info->ctrl, nsid); } -static void nvme_remove_invalid_namespaces (struct nvme_ctrl *ctrl, -unsigned nsid) +static void nvme_remove_nsid_range (struct nvme_ctrl *ctrl,u32 start,u32 end) {struct nvme_ns *ns, *next;LIST_HEAD (rm_list);mutex_lock (&ctrl->namespaces_lock);list_for_each_entry_safe (ns, next, &ctrl->namespaces, list) { -if (ns->head->ns_id > nsid) { +if (ns->head->ns_id >= end) +break ; +if (ns->head->ns_id > start) {list_del_rcu (&ns->list);synchronize_srcu (&ctrl->srcu);list_add_tail_rcu (&ns->list, &rm_list);
@@ -3917,13 +3916,14 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl) goto out;async_schedule_domain (nvme_scan_ns_async, &scan_info, &domain); -while (++prev < nsid) -nvme_ns_remove_by_nsid (ctrl, prev); +if (prev +1 < nsid) +nvme_remove_nsid_range (ctrl, prev, nsid); + prev =max (prev +1 , nsid); }async_synchronize_full_domain (&domain); } out: -nvme_remove_invalid_namespaces (ctrl, prev); +nvme_remove_nsid_range (ctrl, prev,UINT_MAX ); free:async_synchronize_full_domain (&domain);kfree (ns_list);
@@ -3943,7 +3943,7 @@ static void nvme_scan_ns_sequential(struct nvme_ctrl *ctrl)for (i =1 ; i <= nn; i++)nvme_scan_ns (ctrl, i); -nvme_remove_invalid_namespaces (ctrl, nn); +nvme_remove_nsid_range (ctrl, nn,UINT_MAX ); }static void nvme_clear_changed_ns_log (struct nvme_ctrl *ctrl)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/1193 ASoC: Intel: avs: Clean up the bus when fetching ML caps fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 559ea14b7ae7c7562b48759fa545b64958f35b73 ]
snd_hdac_ext_bus_get_ml_capabilities() may fail and its return code shall be checked and accounted for. Address the issue by updating the error-path for avs_pci_probe().
At the same time, if the function in question succeeds but the next part of avs_pci_probe() fails, the hlink list shall be cleaned up before leaving the scope.
--- sound/soc/intel/avs/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/intel/avs/core.c +9 -2
@@ -443,8 +443,13 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) }snd_hdac_bus_parse_capabilities (bus); -if (bus->mlcap) -snd_hdac_ext_bus_get_ml_capabilities (bus); +if (bus->mlcap) { + ret =snd_hdac_ext_bus_get_ml_capabilities (bus); +if (ret <0 ) { +dev_err (dev,"failed to get ml capabilities: %d\n" , ret); + goto err_ml_cap; + } + }if (dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 )))dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));
@@ -474,6 +479,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)snd_hdac_bus_free_stream_pages (bus);snd_hdac_ext_stream_free_all (bus); err_init_streams: +snd_hdac_ext_link_free_all (bus); +err_ml_cap:iounmap (adev->dsp_ba); err_remap_bar4:iounmap (bus->remap_addr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/1193 net: bcmasp: clear txcb->last before writing each descriptor
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit 18e5e0ec0e9282c897e2aa81a3e43ccaee03b003 ]
bcmasp_xmit() only wrote txcb->last = true for the final fragment of an SKB; non-final fragments left the field untouched. If a descriptor slot was reused while it still held a stale true from a previous SKB (possible when tx_spb_ring_full() underreported fullness), bcmasp_tx_reclaim() would see last == true mid-SKB and call dev_consume_skb_any() prematurely, freeing the sk_buff while its remaining fragments were still in flight.
Unconditionally clear txcb->last before the conditional set so every descriptor slot starts from a known false state regardless of what a prior transmission left behind.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1 -0
@@ -333,6 +333,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev) txcb->bytes_sent = total_bytes;dma_unmap_addr_set (txcb, dma_addr, mapping);dma_unmap_len_set (txcb, dma_len, size); + txcb->last = false;if (!i) { desc->flags |=DESC_SOF ;if (csum_hw)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/1193 net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit 0c5cf62e72d7a666ee4da757e122dc1600df1ecc ]
The loop initialised next_index from intf->tx_spb_index on every iteration, so incr_ring() always produced the same result and only one slot was ever tested. Move the initialisation before the loop so each iteration advances next_index and the function correctly checks that cnt consecutive descriptor slots are available before allowing a new transmission.
--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +2 -1
@@ -147,8 +147,9 @@ static int tx_spb_ring_full(struct bcmasp_intf *intf, int cnt)int next_index, i;/* Check if we have enough room for cnt descriptors */ + next_index = intf->tx_spb_index;for (i =0 ; i < cnt; i++) { - next_index =incr_ring (intf->tx_spb_index,DESC_RING_COUNT ); + next_index =incr_ring (next_index,DESC_RING_COUNT );if (next_index == intf->tx_spb_clean_index)return 1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/1193 bpf: Mark bpf_btf_find_by_name_kind() as sleepable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 620614bf7672130c43b3cff375525a2202f61979 ]
When bpf_btf_find_by_name_kind() finds a type in module BTF, it returns a new BTF object fd through __btf_new_fd(). This reaches anon_inode_getfd(), which can sleep while allocating or expanding the current task fd table.
The helper prototype does not set might_sleep, so the verifier allows the helper in non-sleepable contexts such as BPF timer callbacks. The fd allocation can then sleep in softirq context and install the fd into the interrupted task.
Mark the helper as sleepable. This preserves calls from the main body of a sleepable syscall program while rejecting calls from its non-sleepable regions.
--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/btf.c +1 -0
@@ -7594,6 +7594,7 @@ BPF_CALL_4(bpf_btf_find_by_name_kind, char *, name, int, name_sz, u32, kind, intconst struct bpf_func_proto bpf_btf_find_by_name_kind_proto = { .func = bpf_btf_find_by_name_kind, .gpl_only = false, + .might_sleep = true, .ret_type =RET_INTEGER , .arg1_type =ARG_PTR_TO_MEM |MEM_RDONLY , .arg2_type =ARG_CONST_SIZE ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/1193 selftests/bpf: Update tests for new ct zone opts for nf_conntrack kfuncs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brad Cowie <[email protected]>
[ Upstream commit a87f34e742d279d54d529e4bc4763fdaab32a466 ]
Add test for allocating and looking up ct entry in a non-default ct zone with kfuncs bpf_{xdp,skb}_ct_alloc and bpf_{xdp,skb}_ct_lookup.
Add negative tests for looking up ct entry in a different ct zone to where it was allocated and with a different direction.
Update reserved test for old struct definition to test for ct_zone_id being set when opts size isn't NF_BPF_CT_OPTS_SZ (16).
Stable-dep-of: 5e8c349bc8d7 ("selftests/bpf: Fix flaky bpf_nf test when random NAT port is 0")
--- tools/testing/selftests/bpf/config | 1 + .../testing/selftests/bpf/prog_tests/bpf_nf.c | 7 ++ .../testing/selftests/bpf/progs/test_bpf_nf.c | 108 ++++++++++++++++++ 3 files changed, 116 insertions(+)
tools/testing/selftests/bpf/config +1 -0
@@ -76,6 +76,7 @@ CONFIG_NETFILTER_XT_MATCH_STATE=y CONFIG_NETFILTER_XT_TARGET_CT=y CONFIG_NF_CONNTRACK=y CONFIG_NF_CONNTRACK_MARK=y +CONFIG_NF_CONNTRACK_ZONES=y CONFIG_NF_DEFRAG_IPV4=y CONFIG_NF_DEFRAG_IPV6=y CONFIG_NF_NAT=y
tools/testing/selftests/bpf/prog_tests/bpf_nf.c +7 -0
@@ -110,6 +110,7 @@ static void test_bpf_nf_ct(int mode)ASSERT_EQ (skel->bss->test_einval_bpf_tuple, -EINVAL ,"Test EINVAL for NULL bpf_tuple" );ASSERT_EQ (skel->bss->test_einval_reserved, -EINVAL ,"Test EINVAL for reserved not set to 0" ); +ASSERT_EQ (skel->bss->test_einval_reserved_new, -EINVAL ,"Test EINVAL for reserved in new struct not set to 0" );ASSERT_EQ (skel->bss->test_einval_netns_id, -EINVAL ,"Test EINVAL for netns_id < -1" );ASSERT_EQ (skel->bss->test_einval_len_opts, -EINVAL ,"Test EINVAL for len__opts != NF_BPF_CT_OPTS_SZ" );ASSERT_EQ (skel->bss->test_eproto_l4proto, -EPROTO ,"Test EPROTO for l4proto != TCP or UDP" );
@@ -128,6 +129,12 @@ static void test_bpf_nf_ct(int mode)ASSERT_EQ (skel->bss->test_exist_lookup_mark,43 ,"Test existing connection lookup ctmark" );ASSERT_EQ (skel->data->test_snat_addr,0 ,"Test for source natting" );ASSERT_EQ (skel->data->test_dnat_addr,0 ,"Test for destination natting" ); +ASSERT_EQ (skel->data->test_ct_zone_id_alloc_entry,0 ,"Test for alloc new entry in specified ct zone" ); +ASSERT_EQ (skel->data->test_ct_zone_id_insert_entry,0 ,"Test for insert new entry in specified ct zone" ); +ASSERT_EQ (skel->data->test_ct_zone_id_succ_lookup,0 ,"Test for successful lookup in specified ct_zone" ); +ASSERT_EQ (skel->bss->test_ct_zone_dir_enoent_lookup, -ENOENT ,"Test ENOENT for lookup with wrong ct zone dir" ); +ASSERT_EQ (skel->bss->test_ct_zone_id_enoent_lookup, -ENOENT ,"Test ENOENT for lookup in wrong ct zone" ); + end:if (client_fd !=-1 )close (client_fd);
tools/testing/selftests/bpf/progs/test_bpf_nf.c +108 -0
146 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/1193 selftests/bpf: Fix flaky bpf_nf test when random NAT port is 0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 5e8c349bc8d790fe031a4332e502f5d4f9878644 ]
The bpf_nf test allocs a ct, sets snat and dnat with random addr and port via bpf_ct_set_nat_info(), then looks the ct up and checks the reply tuple against what was set.
The port comes from bpf_get_prandom_u32() and can be 0. For bpf_ct_set_nat_info(), port 0 means "port not specified", so only the addr is mapped and the kernel keeps the original port. The check then compares that port with 0 and fails, which shows up as a flaky "Test for source natting" failure in CI [1][2].
Keep the random port in 1..65535 so it is always specified.
[1] https://github.com/kernel-patches/bpf/actions/runs/33830002889/job/100893868791
[2] https://github.com/kernel-patches/bpf/actions/runs/33829976794/job/100893220999
--- tools/testing/selftests/bpf/progs/test_bpf_nf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/test_bpf_nf.c +4 -4
@@ -170,8 +170,8 @@ nf_ct_test(struct nf_conn *(*lookup_fn)(void *, struct bpf_sock_tuple *, u32, ct =alloc_fn (ctx, &bpf_tuple,sizeof (bpf_tuple.ipv4), &opts_def,sizeof (opts_def));if (ct) { -__u16 sport =bpf_get_prandom_u32 (); -__u16 dport =bpf_get_prandom_u32 (); +__u16 sport =bpf_get_prandom_u32 () %65535 +1 ; +__u16 dport =bpf_get_prandom_u32 () %65535 +1 ;union nf_inet_addr saddr = {};union nf_inet_addr daddr = {};struct nf_conn *ct_ins;
@@ -273,8 +273,8 @@ nf_ct_opts_new_test(struct nf_conn *(*lookup_fn)(void *, struct bpf_sock_tuple * ct =alloc_fn (ctx, &bpf_tuple,sizeof (bpf_tuple.ipv4), &opts_def,sizeof (opts_def));if (ct) { -__u16 sport =bpf_get_prandom_u32 (); -__u16 dport =bpf_get_prandom_u32 (); +__u16 sport =bpf_get_prandom_u32 () %65535 +1 ; +__u16 dport =bpf_get_prandom_u32 () %65535 +1 ;union nf_inet_addr saddr = {};union nf_inet_addr daddr = {};struct nf_conn *ct_ins;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/1193 nexthop: Initialize extack in remove_nh_grp_entry()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 5bd9e4e7cdaa03879e9b73b12ab52cceb1edd55b ]
remove_nh_grp_entry() prints the extack message when a listener fails to replace the reduced nexthop group. However, extack is not initialized and listeners are not required to set a message when returning an error. Neither netdevsim nor mlxsw do so when an allocation fails, resulting in the dereference of an uninitialized stack pointer.
Fix by zero-initializing extack, as was done in commit 6347c5314cee ("nexthop: initialize extack in nh_res_bucket_migrate()").
--- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/nexthop.c +1 -1
@@ -1759,7 +1759,7 @@ static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge, {struct nh_grp_entry *nhges, *new_nhges;struct nexthop *nhp = nhge->nh_parent; -struct netlink_ext_ack extack; +struct netlink_ext_ack extack = {};struct nexthop *nh = nhge->nh;struct nh_group *nhg, *newg;int i, j, err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/1193 bonding: use skb_cow_head() in bond_do_alb_xmit() and rlb_arp_xmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 1746ef2e2df2ad71c66eca56364d56bde284523b ]
In bond_do_alb_xmit() and rlb_arp_xmit(), make sure to unclone skb head via skb_cow_head() before modifying the source MAC address (Ethernet header and ARP payload) to avoid silent corruption if the skb is shared or cloned. Avoid caching the header pointers across skb_cow_head().
In rlb_arp_xmit(), only modify arp->mac_src if it differs from tx_slave->dev->dev_addr to avoid an unnecessary copy and head reallocation.
Also, we should not assume mac header is set in output path.
Use skb_eth_hdr() instead of eth_hdr() to fix the issue, and remove now redundant skb_reset_mac_header() calls.
--- drivers/net/bonding/bond_alb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/bonding/bond_alb.c +12 -7
@@ -678,9 +678,15 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)if (arp->op_code ==htons (ARPOP_REPLY )) {/* the arp must be sent on the selected rx channel */ tx_slave =rlb_choose_channel (skb, bond, arp); -if (tx_slave) +if (tx_slave && + !ether_addr_equal_64bits (arp->mac_src, + tx_slave->dev->dev_addr)) { +if (unlikely (skb_cow_head (skb,0 ))) +return NULL ; + arp = (struct arp_pkt *)skb_network_header (skb);bond_hw_addr_copy (arp->mac_src, tx_slave->dev->dev_addr, tx_slave->dev->addr_len); + }netdev_dbg (bond->dev,"(slave %s): Server sent ARP Reply packet\n" , tx_slave ? tx_slave->dev->name :"NULL" ); }else if (arp->op_code ==htons (ARPOP_REQUEST )) {
@@ -1341,7 +1347,6 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, struct slave *tx_slave) {struct alb_bond_info *bond_info = &(BOND_ALB_INFO (bond)); -struct ethhdr *eth_data =eth_hdr (skb);if (!tx_slave) {/* unbalanced or unassigned, send through primary */
@@ -1352,7 +1357,9 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,if (tx_slave &&bond_slave_can_tx (tx_slave)) {if (tx_slave !=rcu_access_pointer (bond->curr_active_slave)) { -ether_addr_copy (eth_data->h_source, +if (unlikely (skb_cow_head (skb,0 ))) +return bond_tx_drop (bond->dev, skb); +ether_addr_copy (skb_eth_hdr (skb)->h_source, tx_slave->dev->dev_addr); }
@@ -1376,8 +1383,7 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,struct ethhdr *eth_data;u32 hash_index; -skb_reset_mac_header (skb); - eth_data =eth_hdr (skb); + eth_data =skb_eth_hdr (skb);/* Do not TX balance any multicast or broadcast */ if (!is_multicast_ether_addr (eth_data->h_dest)) {
@@ -1429,8 +1435,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,u32 hash_index =0 ;int hash_size =0 ; -skb_reset_mac_header (skb); - eth_data =eth_hdr (skb); + eth_data =skb_eth_hdr (skb);switch (ntohs (skb->protocol)) {case ETH_P_IP : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/1193 net: dsa: bcm_sf2: bound the CFP rule dump by the callers buffer size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit cdb719f4b8596d9ccee2d56d204c2c4dce982f46 ]
bcm_sf2_cfp_rule_get_all() walks the whole cfp.unique bitmap into rule_locs[] without consulting nfc->rule_cnt, which is how many entries the caller had room for. ETHTOOL_GRXCLSRLALL requires no CAP_NET_ADMIN and the ioctl sizes the buffer from the rule_cnt userspace passes in, so once an admin has installed CFP rules any user can ask for fewer slots than there are rules and run off the end of the allocation. A rule_cnt of 0 leaves the buffer pointer NULL and the walk dereferences it.
--- drivers/net/dsa/bcm_sf2_cfp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/dsa/bcm_sf2_cfp.c +2 -0
@@ -1088,6 +1088,8 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,unsigned int index =1 , rules_cnt =0 ;for_each_set_bit_from (index, priv->cfp.unique, priv->num_cfp_rules) { +if (rules_cnt == nfc->rule_cnt) +return -EMSGSIZE ; rule_locs[rules_cnt] = index; rules_cnt++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/1193 net: dsa: mv88e6xxx: bound the policy rule dump by the callers buffer size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit b1fffc273112e7284c5b705e186b43b5770cd3d5 ]
mv88e6xxx_get_rxnfc() uses rxnfc->rule_cnt as the write index while dumping the policy IDR, clobbering the input value before it has been looked at. That input is the number of entries the caller had room for. ETHTOOL_GRXCLSRLALL requires no CAP_NET_ADMIN and the ioctl sizes the buffer from the rule_cnt userspace passes in, so once an admin has installed policy rules any user can ask for fewer slots than there are rules and run off the end of the allocation. A rule_cnt of 0 leaves the buffer pointer NULL and the walk dereferences it.
Count into a local so the caller's limit survives the walk, and stop with -EMSGSIZE once it is reached.
--- drivers/net/dsa/mv88e6xxx/chip.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +12 -4
@@ -2356,6 +2356,7 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,struct ethtool_rx_flow_spec *fs = &rxnfc->fs;struct mv88e6xxx_chip *chip = ds->priv;struct mv88e6xxx_policy *policy; +u32 cnt =0 ;int err;int id;
@@ -2381,11 +2382,18 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,break ;case ETHTOOL_GRXCLSRLALL : rxnfc->data =0 ; - rxnfc->rule_cnt =0 ; -idr_for_each_entry (&chip->policies, policy, id) -if (policy->port == port) - rule_locs[rxnfc->rule_cnt++] = id; err =0 ; +idr_for_each_entry (&chip->policies, policy, id) { +if (policy->port != port) +continue ; +if (cnt == rxnfc->rule_cnt) { + err = -EMSGSIZE ; +break ; + } + rule_locs[cnt++] = id; + } +if (!err) + rxnfc->rule_cnt = cnt;break ;default : err = -EOPNOTSUPP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/1193 net: bridge: mcast: properly convert mglist to rcu
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 4b772869a1e5f9da5cef5b9c722ec0aa424ee0a0 ]
Sashiko reported a bug [1] that br_multicast_del_port_group unlists the port group not using proper rcu helper that preserves the next pointer and after that immediately frees the port group without waiting for rcu grace period. The only rcu walker of mglist is br_multicast_list_adjacent() and it turns out that function has always been buggy because mglist was never properly converted to RCU. Fix it by converting it to rcu and moving its initialization after eth_addr's. Initializing p->next can use RCU_INIT_POINTER because we have a barrier from the hlist_add_head_rcu call later, besides we're initializing an unpublished structure anyway.
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260826014200.362304-1-littleddfu%40gmail.com
--- net/bridge/br_multicast.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/bridge/br_multicast.c +5 -4
@@ -1436,16 +1436,17 @@ struct net_bridge_port_group *br_multicast_new_port_group( goto free_out; } -rcu_assign_pointer (p->next, next);timer_setup (&p->timer, br_multicast_port_group_expired,0 );timer_setup (&p->rexmit_timer, br_multicast_port_group_rexmit,0 ); -hlist_add_head (&p->mglist, &port->mglist);if (src)memcpy (p->eth_addr, src,ETH_ALEN );else eth_broadcast_addr (p->eth_addr); +RCU_INIT_POINTER (p->next, next); +hlist_add_head_rcu (&p->mglist, &port->mglist); +return p; free_out:
@@ -1460,11 +1461,11 @@ void br_multicast_del_port_group(struct net_bridge_port_group *p)struct net_bridge_port *port = p->key.port;__u16 vid = p->key.addr.vid; -hlist_del_init (&p->mglist); +hlist_del_init_rcu (&p->mglist);if (!br_multicast_is_star_g (&p->key.addr))rhashtable_remove_fast (&port->br->sg_port_tbl, &p->rhnode, br_sg_port_rht_params); -kfree (p); +kfree_rcu (p, rcu);br_multicast_port_ngroups_dec (port, vid); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/1193 octeontx2-af: mcs: Clear stale X2P calibration state before calibration
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viswajith Murali <[email protected]>
[ Upstream commit 1f29543126dde307e8b5fb6a740c54e59deaa2ff ]
Some firmware versions leave MCSX_MIL_GLOBAL bit 5 set on boot. If the bit is already set when the driver attempts X2P calibration, the hardware sees no rising edge and calibration never triggers. Clear the bit and wait briefly before starting calibration to ensure a clean rising edge.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +10 -0
@@ -1417,6 +1417,16 @@ static int mcs_x2p_calibration(struct mcs *mcs)int i, err =0 ;u64 val; +/* Clear any stale calibration state left by firmware/bootloader. +* Some firmware versions may leave MCSX_MIL_GLOBAL bit 5 set, +* preventing the hardware from detecting the rising edge needed to +* trigger X2P calibration. +*/ + val =mcs_reg_read (mcs,MCSX_MIL_GLOBAL ); + val &= ~BIT_ULL (5 ); +mcs_reg_write (mcs,MCSX_MIL_GLOBAL , val); +usleep_range (100 ,200 ); +/* set X2P calibration */ val =mcs_reg_read (mcs,MCSX_MIL_GLOBAL ); val |=BIT_ULL (5 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/1193 net: usb: cx82310_eth: drop URB after 0xffff reboot sentinel to prevent partial_data heap overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Winter <[email protected]>
[ Upstream commit 5d50e90add8b4a978395e893e81954d19d58a7c5 ]
The 0xffff length sentinel detects a router reboot and schedules re-enabling of ethernet mode, but then falls through to the rest of the loop body. The next check is
} else if (len > CX82310_MTU) {which is the else of the just-matched if -- it never fires for len == 0xffff. The MTU bound that normally caps the incomplete-packet save path is silently bypassed.
With 0xffff > skb->len always true (rx_urb_size is 4096), the incomplete-packet branch saves dev->partial_len = skb->len bytes into dev->partial_data. partial_data is kmalloc(hard_mtu) = kmalloc(CX82310_MTU + 2) = 1516 bytes, but skb->len after the 2-byte header pull can be up to 4094. A device that sends a 4096-byte URB starting with [0xff 0xff] therefore copies 4094 device-provided bytes into a buffer allocated for 1516 bytes, exceeding its requested size by 2578 bytes.
The next URB then reads dev->partial_len (4094) back from the same 1516-byte buffer and dev->partial_rem (65535 - 4094 = 61441) from the new URB's ~4KB skb, both well past their allocations, and delivers the spliced result as a 64KB "frame" to the network stack.
Bail out of rx_fixup after scheduling the re-enable work; the remainder of a reboot-marker URB is not meaningful packet data. This restores the invariant that partial_len < CX82310_MTU + 2 on the save path, since every other route there has already passed the MTU check.
--- drivers/net/usb/cx82310_eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/cx82310_eth.c +1 -0
@@ -282,6 +282,7 @@ static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb)if (len ==0xffff ) {netdev_info (dev->net,"router was rebooted, re-enabling ethernet mode" );schedule_work (&priv->reenable_work); +return 0 ; }else if (len >CX82310_MTU ) {netdev_err (dev->net,"RX packet too long: %d B\n" , len);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/1193 s390/ism: folio_put() after error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Winter <[email protected]>
[ Upstream commit 907a56ab3eb8a58500a58daa76087f17bb2b6826 ]
dmb->cpu_addr was allocated via folio_alloc(). Use folio_put() instead of kfree() in the error exit of ism_alloc_dmb() to avoid slab allocator corruption.
While at it, reset dmb->cpu_addr after folio_put to avoid unintentional UAF by future callers.
--- drivers/s390/net/ism_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/s390/net/ism_drv.c +3 -1
@@ -296,6 +296,7 @@ static void ism_free_dmb(struct ism_dev *ism, struct ism_dmb *dmb)dma_unmap_page (&ism->pdev->dev, dmb->dma_addr, dmb->dmb_len,DMA_FROM_DEVICE );folio_put (virt_to_folio (dmb->cpu_addr)); + dmb->cpu_addr =NULL ; }static int ism_alloc_dmb (struct ism_dev *ism,struct ism_dmb *dmb)
@@ -339,7 +340,8 @@ static int ism_alloc_dmb(struct ism_dev *ism, struct ism_dmb *dmb)return 0 ; out_free: -kfree (dmb->cpu_addr); +folio_put (folio); + dmb->cpu_addr =NULL ; out_bit:clear_bit (dmb->sba_idx, ism->sba_bitmap);return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/1193 vxlan: reject dynamic fdb entries that reference a nexthop id
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungwon Bae <[email protected]>
[ Upstream commit 98fc57d167446b95b4e719815fe79edef93f8e7a ]
The commit cited in the Fixes tag allowed VXLAN FDB entries to point to FDB nexthops so that overlay traffic could be load balanced across multiple VTEPs. Such entries can only be configured from user space, cannot be learned and cannot roam. They only make sense with a user space control plane such as E-VPN where data plane learning is disabled.
Despite that, the VXLAN driver does not currently prevent such entries from being configured with the "dynamic" flag. The per-nexthop FDB list is only protected by the per-device hash lock, which is not sufficient when two VXLAN devices point to the same FDB nexthop and therefore share the list. Aging runs in softirq context without RTNL, so an entry deleted by one device can race with an addition or deletion from the other, leading to list corruption:
list_del corruption. next->prev should be ffff8881069d9548, but was dead000000000122. (next=ffff8881069d9448)
WARNING: CPU: 0 PID: 90 at lib/list_debug.c:65 __list_del_entry_valid_or_report+0x1aa/0x210 ... vxlan_fdb_destroy+0x5b8/0xad0 vxlan_cleanup+0x328/0x450 call_timer_fn+0x2a/0x1c0 run_timer_softirq+0x18c/0x210 BUG: KASAN: slab-use-after-free in vxlan_fdb_destroy
Fix this by rejecting the bogus configuration of dynamic FDB entries that point to FDB nexthops, both when created and when an existing entry is updated. As such, the per-nexthop FDB list is only ever mutated under the RTNL lock. Add test cases to make sure that this does not regress in the future.
--- drivers/net/vxlan/vxlan_core.c | 11 ++++++++ tools/testing/selftests/net/fib_nexthops.sh | 28 +++++++++++++++++++++ 2 files changed, 39 insertions(+)
drivers/net/vxlan/vxlan_core.c +11 -0
@@ -1007,6 +1007,12 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,return -EOPNOTSUPP ; } +if (rcu_access_pointer (f->nh) && + !(state & (NUD_PERMANENT |NUD_NOARP ))) { +NL_SET_ERR_MSG (extack,"Cannot make a nexthop fdb dynamic" ); +return -EOPNOTSUPP ; + } +/* Do not allow an externally learned entry to take over an entry added * by the user. */
@@ -1274,6 +1280,11 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],if (err)return err; +if (nhid && !(ndm->ndm_state & (NUD_PERMANENT |NUD_NOARP ))) { +NL_SET_ERR_MSG (extack,"A nexthop fdb cannot be dynamic" ); +return -EINVAL ; + } +if (vxlan->default_dst.remote_ip.sa.sa_family != ip.sa.sa_family)return -EAFNOSUPPORT ;
tools/testing/selftests/net/fib_nexthops.sh +28 -0
@@ -499,6 +499,20 @@ ipv6_fdb_grp_fcnal() run_cmd "$BRIDGE fdb add 02:02:00:00:00:14 dev vx10 nhid 61 self" log_test $? 255 "Fdb mac add with nexthop" + # fdb entries with a nexthop group cannot be aged out + run_cmd "$BRIDGE fdb add 02:02:00:00:00:15 dev vx10 nhid 102 self static" + log_test $? 0 "Fdb mac add with nexthop group and static state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" + log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" + run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" + log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" + log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 66" log_test $? 2 "Route add with fdb nexthop"
@@ -579,6 +593,20 @@ ipv4_fdb_grp_fcnal() run_cmd "$BRIDGE fdb add 02:02:00:00:00:14 dev vx10 nhid 12 self" log_test $? 255 "Fdb mac add with nexthop" + # fdb entries with a nexthop group cannot be aged out + run_cmd "$BRIDGE fdb add 02:02:00:00:00:15 dev vx10 nhid 102 self static" + log_test $? 0 "Fdb mac add with nexthop group and static state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" + log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" + run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" + log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + + run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" + log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP ro add 172.16.0.0/22 nhid 16" log_test $? 2 "Route add with fdb nexthop"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/1193 net: cap tx_queue_len at S16_MAX to prevent oversized ring allocations
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 66ab4c59b74db7ab53a1c9083feaaede393a96a0 ]
Several subsystems allocate ring buffers sized by dev->tx_queue_len with no upper bound. An unprivileged user (via unshare -Urn) can set a huge tx_queue_len and exhaust global memory with ring allocations:
- pfifo_fast: pfifo_fast_init() and pfifo_fast_change_tx_queue_len() allocate 3 skb_array rings of tx_queue_len entries each.
- tun: tun_queue_resize() and the queue-attach path resize ptr_rings to tx_queue_len on the NETDEV_CHANGE_TX_QUEUE_LEN notifier.
- tap (macvtap/ipvtap): tap_queue_resize() and tap_init() resize/init ptr_rings to tx_queue_len on the same notifier.
netif_change_tx_queue_len() is the single entry point for IFLA_TXQLEN, sysfs, and the SIOCSIFTXQLEN ioctl. Cap new_len at S16_MAX (32767) there so the oversized value is rejected at set time. This takes effect whether the device is up or down, before dev->tx_queue_len is written, before any notifier fires, and before any ring is allocated. The "> S16_MAX" check also subsumes the previous unsigned-long truncation test, and a negative ifr_qlen from the ioctl lands far above the cap after conversion, so both old failure modes are covered by the one comparison.
tx_queue_len is ambigious: both a per-ring sizing multiplier and a default queue-length/limit knob for consumers that allocate nothing at set time (pfifo/bfifo/gred/plug/sfb limits, htb direct_qlen, qfq max_classes, teql). 32767 is chosen as the largest value NLA_POLICY_FULL_RANGE can express for the u32 IFLA_TXQLEN policy in patch 2/3 while staying a legitimate queue length on high-BDP paths; the ring-memory trade-off of a shared knob is disclosed below.
Conditions to recreate the bug:
- CONFIG_NET_SCHED=y, CONFIG_VETH=y, CONFIG_USER_NS=y, CONFIG_NET_NS=y.
- Unprivileged user in a fresh user+net namespace (unshare -Urn).
- pfifo_fast: create veth pairs, set tx_queue_len to 500000, attach mq+pfifo_fast. ~28 iterations OOMs a 2GB guest.
- tun: create 50 tun devices with IFF_MULTI_QUEUE, set tx_queue_len to 500000, open 8 queues each. ~1.6GB of ptr_ring allocations OOMs a 512MB guest.
- tap: same as tun with IFF_TAP. ~960MB OOMs a 512MB guest.
- On the fixed kernel the oversized tx_queue_len is rejected with -ERANGE at set time (all four paths: RTM_SETLINK, RTM_NEWLINK create, sysfs, ioctl - the latter two via this check, the former two via this check and the 2/3 parse policy respectively).
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -8925,7 +8925,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len)unsigned int orig_len = dev->tx_queue_len;int res; -if (new_len != (unsigned int )new_len) +if (new_len >S16_MAX )return -ERANGE ;if (new_len != orig_len) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/1193 pds_core: fix cmd_regs access racing BAR unmap on reset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit 7980325b2f71e3f65c1323c39792e2455da6fab6 ]
pdsc_reset_prepare() and pdsc_reset_done()'s pdsc_map_bars() error path clear/iounmap cmd_regs without devcmd_lock, and pdsc_legacy_firmware_update()'s download loop derefs cmd_regs after dropping and retaking the lock without re-checking. An FLR concurrent with a devlink flash can unmap cmd_regs under an in-flight devcmd, causing a NULL deref or a write to unmapped MMIO.
Take devcmd_lock across the BAR unmap/remap, and re-check cmd_regs in the download loop. Only the PF maps cmd_regs and runs devcmd, so skip the unmap on a VF, as pdsc_remove() and pdsc_reset_done() already do.
A reset that completes entirely within the unlocked window is not a correctness problem for the image: the device clears its update session, so a resumed download is rejected, and it verifies the staged image before writing a flash slot, reporting PDS_RC_BAD_FW rather than activating it.
pdsc_unmap_bars() also clears info_regs, intr_status and intr_ctrl. The interrupt and start/stop readers of those are quiesced before the unmap by pdsc_fw_down(), which frees the interrupts and tears down the queues. The debugfs readers are not, since those files outlive a reset; that is pre-existing and out of scope here.
--- drivers/net/ethernet/amd/pds_core/fw.c | 10 +++++++++- drivers/net/ethernet/amd/pds_core/main.c | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/net/ethernet/amd/pds_core/fw.c +9 -1
@@ -107,8 +107,10 @@ int pdsc_firmware_update(struct pdsc *pdsc, const struct firmware *fw,dev_info (pdsc->dev,"Installing firmware\n" ); -if (!pdsc->cmd_regs) +if (!pdsc->cmd_regs) { +NL_SET_ERR_MSG_MOD (extack,"BARs not mapped" );return -ENXIO ; + } dl =priv_to_devlink (pdsc); devlink_flash_update_status_notify(dl, "Preparing to flash",
@@ -134,6 +136,12 @@ int pdsc_firmware_update(struct pdsc *pdsc, const struct firmware *fw, copy_sz = min_t(unsigned int, buf_sz, fw->size - offset);mutex_lock (&pdsc->devcmd_lock); +if (!pdsc->cmd_regs) { +mutex_unlock (&pdsc->devcmd_lock); + err = -ENXIO ; +NL_SET_ERR_MSG_MOD (extack,"Device reset during flash" ); + goto err_out; + }memcpy_toio (&pdsc->cmd_regs->data, fw->data + offset, copy_sz); err =pdsc_devcmd_fw_download_locked (pdsc, data_addr, offset, copy_sz);
drivers/net/ethernet/amd/pds_core/main.c +7 -1
@@ -490,7 +490,11 @@ static void pdsc_reset_prepare(struct pci_dev *pdev) &pf->vfs[pdsc->vf_id].padev); } -pdsc_unmap_bars (pdsc); +if (!pdev->is_virtfn) { +mutex_lock (&pdsc->devcmd_lock); +pdsc_unmap_bars (pdsc); +mutex_unlock (&pdsc->devcmd_lock); + }pci_release_regions (pdev);pci_disable_device (pdev); }
@@ -518,7 +522,9 @@ static void pdsc_reset_done(struct pci_dev *pdev)return ; } +mutex_lock (&pdsc->devcmd_lock); err =pdsc_map_bars (pdsc); +mutex_unlock (&pdsc->devcmd_lock);if (err)return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/1193 powerpc/kexec_file: Use inclusive range checks in add_usable_mem()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit c6755be4838d6ccd641effbcdc3d917b82631ff9 ]
add_usable_mem() adds usable memory ranges for the kdump kernel.
The ranges are inclusive, but the partial overlap check uses exclusive comparisons. This skips ranges with base == loc_end or end == loc_base. Use inclusive comparisons instead.
--- arch/powerpc/kexec/file_load_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kexec/file_load_64.c +1 -1
@@ -483,7 +483,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end) loc_end = um_info->ranges[i].end;if (loc_base >= base && loc_end <= end) add = true; -else if (base < loc_end && end > loc_base) { +else if (base <= loc_end && end >= loc_base) {if (loc_base < base) loc_base = base;if (loc_end > end)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/1193 net/sched: defer qdisc freeing after failed creation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit e6662f2100f8d33b0f4d0047c219efd6bba186ea ]
An RTM_NEWQDISC request can make clsact bind a populated shared ingress block during ->init(), publishing an embedded mini_Qdisc to lockless readers. If the same request has an invalid TCA_RATE, estimator setup fails after ->init(); the unwind removes the pointer but synchronously frees its containing qdisc while tc_run() may still hold it.
Retire failed qdiscs through the same RCU helper as normal destruction. Inline the synchronous free into the callback now that no direct callers remain.
--- include/net/sch_generic.h | 2 +- net/sched/sch_api.c | 2 +- net/sched/sch_generic.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-)
include/net/sch_generic.h +1 -1
@@ -755,7 +755,7 @@ void qdisc_offload_query_caps(struct net_device *dev,struct Qdisc *qdisc_alloc (struct netdev_queue *dev_queue,const struct Qdisc_ops *ops,struct netlink_ext_ack *extack); -void qdisc_free (struct Qdisc *qdisc); +void qdisc_free_rcu (struct Qdisc *qdisc);struct Qdisc *qdisc_create_dflt (struct netdev_queue *dev_queue,const struct Qdisc_ops *ops,u32 parentid,struct netlink_ext_ack *extack);
net/sched/sch_api.c +1 -1
@@ -1379,7 +1379,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, err_out3:lockdep_unregister_key (&sch->root_lock_key);netdev_put (dev, &sch->dev_tracker); -qdisc_free (sch); +qdisc_free_rcu (sch); err_out2:module_put (ops->owner); err_out:
net/sched/sch_generic.c +10 -10
@@ -1047,21 +1047,21 @@ void qdisc_reset(struct Qdisc *qdisc) }EXPORT_SYMBOL (qdisc_reset); -void qdisc_free (struct Qdisc *qdisc) +static void qdisc_free_cb (struct rcu_head *head) { -if (qdisc_is_percpu_stats (qdisc)) { -free_percpu (qdisc->cpu_bstats); -free_percpu (qdisc->cpu_qstats); + struct Qdisc *q = container_of(head, struct Qdisc, rcu); + +if (qdisc_is_percpu_stats (q)) { +free_percpu (q->cpu_bstats); +free_percpu (q->cpu_qstats); } -kfree (qdisc); +kfree (q); } -static void qdisc_free_cb (struct rcu_head *head) +void qdisc_free_rcu (struct Qdisc *qdisc) { - struct Qdisc *q = container_of(head, struct Qdisc, rcu); - -qdisc_free (q); +call_rcu (&qdisc->rcu, qdisc_free_cb); }static void __qdisc_destroy (struct Qdisc *qdisc)
@@ -1086,7 +1086,7 @@ static void __qdisc_destroy(struct Qdisc *qdisc)trace_qdisc_destroy (qdisc); -call_rcu (&qdisc->rcu, qdisc_free_cb); +qdisc_free_rcu (qdisc); }void qdisc_destroy (struct Qdisc *qdisc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/1193 net/mlx5e: Fix setting RS FEC after remapping
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shahar Shitrit <[email protected]>
[ Upstream commit b9d755c5a37519fb1354034db1dfeb30e1ba6856 ]
When a user sets a FEC mode via ethtool, the driver maps the ethtool FEC type to the lowest mlx5 bit of that type. For RS FEC, this is MLX5E_FEC_RS_528_514 (bit 2). The driver then checks whether this bit is supported by at least one link mode by inspecting the fec_override_cap fields via mlx5e_fec_in_caps(), and returns -EOPNOTSUPP if not.
This check is incorrect. RS FEC has three supported hardware variants:RS_528_514 (bit 2), RS_544_514_INTERLEAVED_QUAD (bit 4), and RS_544_514 (bit 7). mlx5e_remap_fec_conf_mode() already remaps bit 2 to the appropriate RS variant per link mode when writing the admin fields, but the early capability check is done against the raw unmapped bit. As a result, a device that supports RS_544_514 or RS_544_514_INTERLEAVED_QUAD but not RS_528_514 will incorrectly reject the user's RS FEC request.
Remove the early support check from mlx5e_set_fec_mode() and fold it into the existing write loop, checking caps against the remapped policy per link mode. Return -EOPNOTSUPP before the final register write if no link mode accepted the policy.
--- drivers/net/ethernet/mellanox/mlx5/core/en/port.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/port.c +9 -6
@@ -463,6 +463,7 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)u32 in[MLX5_ST_SZ_DW (pplm_reg)] = {};int sz =MLX5_ST_SZ_BYTES (pplm_reg);u16 fec_policy_auto =0 ; +bool fec_set = false;int err;int i;
@@ -475,9 +476,6 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)if (fec_policy >= (1 <<MLX5E_FEC_LLRS_272_257_1 ) && !fec_50g_per_lane)return -EOPNOTSUPP ; -if (fec_policy && !mlx5e_fec_in_caps (dev, fec_policy)) -return -EOPNOTSUPP ; -MLX5_SET (pplm_reg, in, local_port,1 ); err =mlx5_core_access_reg (dev, in, sz, out, sz,MLX5_REG_PPLM ,0 ,0 );if (err)
@@ -504,12 +502,17 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)mlx5e_get_fec_cap_field (out, &fec_caps, i);/* policy supported for link speed */ -if (fec_caps & conf_fec) +if (fec_caps & conf_fec) {mlx5e_fec_admin_field (out, &conf_fec,1 , i); -else -/* set FEC to auto*/ + fec_set = true; + }else { +/* set FEC to auto */ mlx5e_fec_admin_field (out, &fec_policy_auto,1 , i); + } } +if (fec_policy && !fec_set) +return -EOPNOTSUPP ; +return mlx5_core_access_reg (dev, out, sz, out, sz,MLX5_REG_PPLM ,0 ,1 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/1193 net/mlx5e: Fix ETS zero BW reporting when one TC holds 100%
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit e7ee89740800a1cf253713e9249c3ee9203ebe91 ]
When ETS TCs with zero bandwidth are configured, the driver programs the firmware using an alternate representation. On get, it needs to recognize that representation so those TCs can be translated back and reported as 0% bandwidth.
The existing detection relied on the programmed bandwidth because it was enough to identify this representation. However, when a single ETS TC owns 100% of the bandwidth, its firmware representation becomes the same as a strict-priority TC, causing zero-bandwidth ETS TCs to be reported with non-zero bandwidth values.
Use the cached TSA instead to distinguish the ETS and strict-priority cases.
--- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +1 -1
@@ -133,7 +133,7 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,if (err)return err; -if (ets->tc_tx_bw[i] <MLX5E_MAX_BW_ALLOC && +if (priv->dcbx.tc_tsa[i] ==IEEE_8021QAZ_TSA_ETS && tc_group[i] == (MLX5E_LOWEST_PRIO_GROUP +1 )) is_zero_bw_ets_tc = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/1193 net/mlx5e: Fix use-after-free race in sample_restore_put()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit af3aef0245abbab5e9f6302e7a7d6407187afb71 ]
Concurrent teardown of TC sample rules sharing the same restore context may re-read restore->count after dropping restore_lock. At that point another thread may already have completed cleanup and freed the restore object.
Use the result of the refcount decrement while holding restore_lock to determine whether cleanup is needed.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +5 -2
@@ -311,12 +311,15 @@ sample_restore_get(struct mlx5e_tc_psample *tc_psample, u32 obj_id,static void sample_restore_put (struct mlx5e_tc_psample *tc_psample,struct mlx5e_sample_restore *restore) { +bool last; +mutex_lock (&tc_psample->restore_lock); -if (--restore->count ==0 ) + last = --restore->count ==0 ; +if (last)hash_del (&restore->hlist);mutex_unlock (&tc_psample->restore_lock); -if (!restore->count) { +if (last) {mlx5_del_flow_rules (restore->rule);mlx5_modify_header_dealloc (tc_psample->esw->dev, restore->modify_hdr);kfree (restore);
Signature · 1 line
2.53.0