6.1.193-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 2624/2857 ipvs: fix more races around the overload flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3ba20137287f4f34ddbf0afb53c5d1ba03b6a8c2 ]
Sashiko warns that we still have races when the dest overload thresholds are updated. If we narrow the range between thresholds the lockless readers (ip_vs_bind_dest and ip_vs_unbind_dest) may use old threshold values and as result to skip the required flag change.
To solve the problem ip_vs_bind_dest() and ip_vs_unbind_dest() will have the chance as before to change the overload state not only at the exact threshold positions but
at any conn count below the lower and above the upper thresholds. To make it work without entering the locked region for every connection, we introduce l_threshold_val. Together with u_threshold_val we will switch between two states:
1. not overloaded: where l_threshold_val is set to 0 to close the door for more ip_vs_unbind_dest() calls to clear the overload state.
2. overloaded: where u_threshold_val is set to INT_MAX to close the door for more ip_vs_bind_dest() calls to set the overload state.
If a race occurs, multiple CPUs can repeat the state change but this should be for short time window.
With the introduction of l_threshold_val the IP_VS_DEST_F_OVERLOAD flag and the 'flags' field are not needed anymore. We will use the ip_vs_dest_is_overloaded() helper for all places that read the overload state.
Do not check IP_VS_DEST_CF_AVAILABLE in ip_vs_dh.c because we do not hold reference to dest after it is removed and rely on RCU to access the available dests.
To reduce the cacheline accesses while selecting destination, keep the mostly used fields (weight and l_threshold_val) at the first read-mostly cacheline together with the hash nodes.
--- include/net/ip_vs.h | 50 ++++++++++++++++++++------------ net/netfilter/ipvs/ip_vs_conn.c | 8 ++--- net/netfilter/ipvs/ip_vs_ctl.c | 38 ++++++++++++------------ net/netfilter/ipvs/ip_vs_dh.c | 16 ++-------- net/netfilter/ipvs/ip_vs_fo.c | 2 +- net/netfilter/ipvs/ip_vs_lblc.c | 4 +-- net/netfilter/ipvs/ip_vs_lblcr.c | 8 ++--- net/netfilter/ipvs/ip_vs_lc.c | 2 +- net/netfilter/ipvs/ip_vs_mh.c | 2 +- net/netfilter/ipvs/ip_vs_nq.c | 2 +- net/netfilter/ipvs/ip_vs_ovf.c | 2 +- net/netfilter/ipvs/ip_vs_rr.c | 2 +- net/netfilter/ipvs/ip_vs_sed.c | 4 +-- net/netfilter/ipvs/ip_vs_sh.c | 2 +- net/netfilter/ipvs/ip_vs_twos.c | 4 +-- net/netfilter/ipvs/ip_vs_wlc.c | 4 +-- net/netfilter/ipvs/ip_vs_wrr.c | 2 +- 17 files changed, 76 insertions(+), 76 deletions(-)
include/net/ip_vs.h +32 -18
@@ -33,9 +33,6 @@#define IP_VS_HDR_INVERSE 1#define IP_VS_HDR_ICMP 2 -/* Destination Server Flags */ -#define IP_VS_DEST_F_OVERLOAD 0x0002/* server is overloaded */ -/* Destination Server Config Flags */ #define IP_VS_DEST_CF_AVAILABLE 0x0001/* server is available */
@@ -661,32 +658,43 @@ struct ip_vs_dest_dst {* and so on. */ struct ip_vs_dest { +/* Cacheline for hash table nodes - read-mostly */ +struct list_head n_list;/* for the dests in the service */ struct hlist_node d_list;/* for table with all the dests */ -u16 af;/* address family */ -__be16 port;/* port number of the server */ -union nf_inet_addr addr;/* IP address of the server */ -volatile unsigned int flags;/* dest status flags */ -atomic_t conn_flags;/* flags to copy to conn */ atomic_t weight;/* server weight */ -unsigned long cflags;/* config flags */ atomic_t last_weight;/* server latest weight */ + +/* connection thresholds */ +u32 l_threshold_val;/* used lower threshold */ +u32 u_threshold_val;/* used upper threshold */ +/* 32/48 */ +u32 l_threshold;/* lower threshold */ +u32 u_threshold;/* upper threshold */ + +unsigned long cflags;/* config flags */ + +/* 44/64 */ +atomic_t conn_flags;/* flags to copy to conn */ +__u16 tun_type;/* tunnel type */ __be16 tun_port;/* tunnel port */ __u16 tun_flags;/* tunnel flags */ -refcount_t refcnt;/* reference counter */ -struct ip_vs_stats stats;/* statistics */ -unsigned long idle_start;/* start time, jiffies */ +u16 af;/* address family */ +__be16 port;/* port number of the server */ +/* 60/80 */ +union nf_inet_addr addr;/* IP address of the server */ -/* connection counters and thresholds */ -atomic_t activeconns;/* active connections */ +/* connection counters */ atomic_t totalconns;/* total connections */ +atomic_t activeconns;/* active connections */ atomic_t persistconns;/* persistent connections */ -__u32 u_threshold;/* upper threshold */ -__u32 l_threshold;/* lower threshold */ -__u32 l_threshold_val;/* used lower threshold */ + +refcount_t refcnt;/* reference counter */ +struct ip_vs_stats stats;/* statistics */ +unsigned long idle_start;/* start time, jiffies */ /* for destination cache */ spinlock_t dst_lock;/* lock of dst_cache */
@@ -1476,7 +1484,13 @@ static inline void ip_vs_dest_put_and_free(struct ip_vs_dest *dest)kfree (dest); } -void ip_vs_dest_update_overload (struct ip_vs_dest *dest,int mode); +void ip_vs_dest_update_overload (struct ip_vs_dest *dest,bool overload); + +/* Check if dest is in overloaded state */ +static inline bool ip_vs_dest_is_overloaded (const struct ip_vs_dest *dest) +{ +return READ_ONCE (dest->l_threshold_val); +}/* IPVS sync daemon data and function prototypes * (from ip_vs_sync.c)
net/netfilter/ipvs/ip_vs_conn.c +4 -4
@@ -633,8 +633,8 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)if (!(flags &IP_VS_CONN_F_INACTIVE ))atomic_inc (&dest->activeconns); tc =atomic_inc_return (&dest->totalconns); -if (tc ==READ_ONCE (dest->u_threshold)) -ip_vs_dest_update_overload (dest,1 ); +if (tc >=READ_ONCE (dest->u_threshold_val)) +ip_vs_dest_update_overload (dest, true); }else {/* It is a persistent connection/template, so increase the persistent connection counter */
@@ -726,8 +726,8 @@ static inline void ip_vs_unbind_dest(struct ip_vs_conn *cp)if (!(cp->flags &IP_VS_CONN_F_INACTIVE ))atomic_dec (&dest->activeconns); tc =atomic_fetch_dec (&dest->totalconns); -if (tc ==READ_ONCE (dest->l_threshold_val)) -ip_vs_dest_update_overload (dest,-1 ); +if (tc <=READ_ONCE (dest->l_threshold_val)) +ip_vs_dest_update_overload (dest, false); }else {/* It is a persistent connection/template, so decrease the persistent connection counter */
net/netfilter/ipvs/ip_vs_ctl.c +18 -20
@@ -869,32 +869,32 @@ ip_vs_zero_stats(struct ip_vs_stats *stats)* - conns reach u_threshold and exceed it: set the flag * - conns go below l_threshold (or 75% of u_threshold): clear the flag */ -static void __ip_vs_dest_update_overload (struct ip_vs_dest *dest,int mode) +static void __ip_vs_dest_update_overload (struct ip_vs_dest *dest,bool overload) {int conns;u32 l, u;lockdep_assert_held (&dest->dst_lock); u =READ_ONCE (dest->u_threshold); -if (!u) - goto unset; - l =READ_ONCE (dest->l_threshold_val); - conns =atomic_read (&dest->totalconns); -if (conns >= (mode >0 ? l : u)) { - dest->flags |=IP_VS_DEST_F_OVERLOAD ; -return ; +if (u) { +/* Low threshold defaults to 75% of upper threshold */ + l =READ_ONCE (dest->l_threshold) ? : (u - (u >>2 )); + conns =atomic_read (&dest->totalconns); +if (conns >= (overload ? l : u)) { +WRITE_ONCE (dest->u_threshold_val,INT_MAX ); +WRITE_ONCE (dest->l_threshold_val, l); +return ; + } } -if (conns >= (mode <0 ? u : l)) -return ; -unset: - dest->flags &= ~IP_VS_DEST_F_OVERLOAD ; +WRITE_ONCE (dest->u_threshold_val, u ? :INT_MAX ); +WRITE_ONCE (dest->l_threshold_val,0 ); } -void ip_vs_dest_update_overload (struct ip_vs_dest *dest,int mode) +void ip_vs_dest_update_overload (struct ip_vs_dest *dest,bool overload) {spin_lock_bh (&dest->dst_lock); -__ip_vs_dest_update_overload (dest, mode); +__ip_vs_dest_update_overload (dest, overload);spin_unlock_bh (&dest->dst_lock); }
@@ -966,15 +966,13 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,if (READ_ONCE (dest->u_threshold) != udest->u_threshold ||READ_ONCE (dest->l_threshold) != udest->l_threshold) { +bool overload; +spin_lock_bh (&dest->dst_lock);WRITE_ONCE (dest->u_threshold, udest->u_threshold);WRITE_ONCE (dest->l_threshold, udest->l_threshold); -/* Low threshold defaults to 75% of upper threshold */ -WRITE_ONCE (dest->l_threshold_val, - udest->l_threshold ? : - (udest->u_threshold - - (udest->u_threshold >>2 ))); -__ip_vs_dest_update_overload (dest,0 ); + overload =ip_vs_dest_is_overloaded (dest); +__ip_vs_dest_update_overload (dest, overload);spin_unlock_bh (&dest->dst_lock); }
net/netfilter/ipvs/ip_vs_dh.c +2 -14
@@ -196,16 +196,6 @@ static int ip_vs_dh_dest_changed(struct ip_vs_service *svc, } -/* -* If the dest flags is set with IP_VS_DEST_F_OVERLOAD, -* consider that the server is overloaded here. -*/ -static inline int is_overloaded (struct ip_vs_dest *dest) -{ -return dest->flags &IP_VS_DEST_F_OVERLOAD ; -} - -/* * Destination hashing scheduling */
@@ -220,10 +210,8 @@ ip_vs_dh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb, s = (struct ip_vs_dh_state *) svc->sched_data; dest =ip_vs_dh_get (svc->af, s, &iph->daddr); -if (!dest || - !(dest->cflags &IP_VS_DEST_CF_AVAILABLE ) - ||atomic_read (&dest->weight) <=0 - ||is_overloaded (dest)) { +if (!dest ||atomic_read (&dest->weight) <=0 || +ip_vs_dest_is_overloaded (dest)) {ip_vs_scheduler_err (svc,"no destination available" );return NULL ; }
net/netfilter/ipvs/ip_vs_fo.c +1 -1
@@ -30,7 +30,7 @@ ip_vs_fo_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,* Find virtual server with highest weight and send it traffic */ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD ) && +if (!ip_vs_dest_is_overloaded (dest) &&atomic_read (&dest->weight) > hw) { hweight = dest; hw =atomic_read (&dest->weight);
net/netfilter/ipvs/ip_vs_lblc.c +2 -2
@@ -419,7 +419,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc)* new connection. */ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ;if (atomic_read (&dest->weight) >0 ) { least = dest;
@@ -434,7 +434,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc)*/ nextstage:list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; doh =ip_vs_dest_conn_overhead (dest);
net/netfilter/ipvs/ip_vs_lblcr.c +4 -4
@@ -167,7 +167,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)/* select the first destination server, whose weight > 0 */ list_for_each_entry_rcu (e, &set->list, list) { least = e->dest; -if (least->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (least))continue ; if ((atomic_read(&least->weight) > 0) &&
@@ -182,7 +182,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set) nextstage:list_for_each_entry_continue_rcu (e, &set->list, list) { dest = e->dest; -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; doh =ip_vs_dest_conn_overhead (dest);
@@ -581,7 +581,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc)* new connection. */ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ;if (atomic_read (&dest->weight) >0 ) {
@@ -597,7 +597,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc)*/ nextstage:list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; doh =ip_vs_dest_conn_overhead (dest);
net/netfilter/ipvs/ip_vs_lc.c +1 -1
@@ -39,7 +39,7 @@ ip_vs_lc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if ((dest->flags &IP_VS_DEST_F_OVERLOAD ) || +if (ip_vs_dest_is_overloaded (dest) ||atomic_read (&dest->weight) ==0 )continue ; doh =ip_vs_dest_conn_overhead (dest);
net/netfilter/ipvs/ip_vs_mh.c +1 -1
@@ -81,7 +81,7 @@ static inline void generate_hash_secret(hsiphash_key_t *hash1,static inline bool is_unavailable (struct ip_vs_dest *dest) {return atomic_read (&dest->weight) <=0 || - dest->flags &IP_VS_DEST_F_OVERLOAD ; +ip_vs_dest_is_overloaded (dest); }/* Returns hash value for IPVS MH entry */
net/netfilter/ipvs/ip_vs_nq.c +1 -1
@@ -73,7 +73,7 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD || +if (ip_vs_dest_is_overloaded (dest) || !atomic_read (&dest->weight))continue ;
net/netfilter/ipvs/ip_vs_ovf.c +1 -1
@@ -34,7 +34,7 @@ ip_vs_ovf_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { w =atomic_read (&dest->weight); -if ((dest->flags &IP_VS_DEST_F_OVERLOAD ) || +if (ip_vs_dest_is_overloaded (dest) ||atomic_read (&dest->activeconns) > w || w ==0 )continue ;
net/netfilter/ipvs/ip_vs_rr.c +1 -1
@@ -67,7 +67,7 @@ ip_vs_rr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD ) && +if (!ip_vs_dest_is_overloaded (dest) &&atomic_read (&dest->weight) >0 )/* HIT */ goto out;
net/netfilter/ipvs/ip_vs_sed.c +2 -2
@@ -76,7 +76,7 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD ) && +if (!ip_vs_dest_is_overloaded (dest) &&atomic_read (&dest->weight) >0 ) { least = dest; loh =ip_vs_sed_dest_overhead (least);
@@ -91,7 +91,7 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ nextstage:list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; doh =ip_vs_sed_dest_overhead (dest); if ((__s64)loh * atomic_read(&dest->weight) >
net/netfilter/ipvs/ip_vs_sh.c +1 -1
@@ -74,7 +74,7 @@ struct ip_vs_sh_state {static inline bool is_unavailable (struct ip_vs_dest *dest) {return atomic_read (&dest->weight) <=0 || - dest->flags &IP_VS_DEST_F_OVERLOAD ; +ip_vs_dest_is_overloaded (dest); }/*
net/netfilter/ipvs/ip_vs_twos.c +2 -2
@@ -53,7 +53,7 @@ static struct ip_vs_dest *ip_vs_twos_schedule(struct ip_vs_service *svc,/* Generate a random weight between [0,sum of all weights) */ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD )) { +if (!ip_vs_dest_is_overloaded (dest)) { weight =atomic_read (&dest->weight);if (weight >0 ) { total_weight += weight;
@@ -76,7 +76,7 @@ static struct ip_vs_dest *ip_vs_twos_schedule(struct ip_vs_service *svc,/* Pick two weighted servers */ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; weight =atomic_read (&dest->weight);
net/netfilter/ipvs/ip_vs_wlc.c +2 -2
@@ -48,7 +48,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ list_for_each_entry_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD ) && +if (!ip_vs_dest_is_overloaded (dest) &&atomic_read (&dest->weight) >0 ) { least = dest; loh =ip_vs_dest_conn_overhead (least);
@@ -63,7 +63,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,*/ nextstage:list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (dest->flags &IP_VS_DEST_F_OVERLOAD ) +if (ip_vs_dest_is_overloaded (dest))continue ; doh =ip_vs_dest_conn_overhead (dest); if ((__s64)loh * atomic_read(&dest->weight) >
net/netfilter/ipvs/ip_vs_wrr.c +1 -1
@@ -177,7 +177,7 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,list_for_each_entry_continue_rcu (dest, &svc->destinations, n_list) { -if (!(dest->flags &IP_VS_DEST_F_OVERLOAD ) && +if (!ip_vs_dest_is_overloaded (dest) &&atomic_read (&dest->weight) >= mark->cw) goto found;if (dest == stop)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2625/2857 netfilter: flowtable: use the vlan id, not the full tci, in the tuple key
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuangfeng He <[email protected]>
[ Upstream commit c203ecf905745d979de5df28fa657121f2e9342d ]
nf_flow_tuple_encap() stores the skb vlan tag in the encap tuple id using skb_vlan_tag_get(), which returns the unmasked TCI including the 3 PCP priority bits. The flowtable entry, however, is programmed by nf_dev_path_info() with vlan_dev_vlan_id(), a plain 12-bit VID.
When a NIC delivers RX vlan offload skbs with a non-zero priority (an RTL9617C EPON ONU was observed handing over vid 818 skbs with tci 0x6332, PCP 3), the runtime lookup key never matches the programmed entry, so every packet misses the flow table and software flow offload is silently defeated.
Mask both parse sites to the 12-bit VID so the lookup key matches for any priority. The in-header variant has the same problem for frames received with PCP != 0 on a non-offload path.
The egress side is unaffected: nf_flow_encap_push() restores tags from the programmed tuple id, which never carried priority bits.
Measured on an RTL9617C ONU (PPPoE over VLAN 818 WAN, NATed 6-flow download over a 1G EPON line), before -> after:
download throughput 377 Mbps -> 936 Mbps
CPU0 %soft at that rate 91.5% -> 70.9%
--- net/netfilter/nf_flow_table_ip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_ip.c +2 -2
@@ -145,14 +145,14 @@ static void nf_flow_tuple_encap(struct sk_buff *skb,int i =0 ;if (skb_vlan_tag_present (skb)) { - tuple->encap[i].id =skb_vlan_tag_get (skb); + tuple->encap[i].id =skb_vlan_tag_get_id (skb); tuple->encap[i].proto = skb->vlan_proto; i++; }switch (skb->protocol) {case htons (ETH_P_8021Q ): veth = (struct vlan_ethhdr *)skb_mac_header (skb); - tuple->encap[i].id =ntohs (veth->h_vlan_TCI); + tuple->encap[i].id =ntohs (veth->h_vlan_TCI) &VLAN_VID_MASK ; tuple->encap[i].proto = skb->protocol;break ;case htons (ETH_P_PPP_SES ):
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2626/2857 netfilter: xt_dccp: handle reserved options as single-byte
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 2edda78aa4eb04cd8f112a81897510ee0cdd7099 ]
The DCCP UAPI defines option numbers 3 through 31 as reserved. Like Padding and Mandatory, these options occupy one byte. dccp_find_option() only treats values below 2 as single-byte and interprets the byte after a reserved option as a TLV length.
This can skip a later option and invert an XT_DCCP_OPTION rule result. A local production-hook fixture installed the same DROP rule for IPv4 and IPv6. In three fresh boots per kernel, a target-only packet was dropped 20/20 times, while adding reserved option 3 before the same target let 20/20 packets reach the protected receiver. The fixed kernel dropped all trigger packets in three fresh boots and preserved the normal controls.
Treat every option up to DCCPO_MAX_RESERVED as single-byte, matching the protocol definition. Triggering requires CONFIG_NETFILTER_XTABLES_LEGACY, CONFIG_NETFILTER_XT_MATCH_DCCP, an option-based rule, and remote protocol-33 reachability. The touched source is unchanged at 0c2669a9f4a1d607e7591ae50ccf3c432a0aff08, where the patch applies and builds cleanly.
--- net/netfilter/xt_dccp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_dccp.c +1 -1
@@ -62,7 +62,7 @@ dccp_find_option(u_int8_t option,return true; } -if (op[i] <2 || i == optlen -1 ) +if (op[i] <=DCCPO_MAX_RESERVED || i == optlen -1 ) i++;else i += op[i +1 ] ? :1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2627/2857 nios2: ksyms: Declare __mulsi3 export
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 2180d11e06fb56fd13643ae59964f144896870be ]
GCC may emit libcalls to __mulsi3(). As modpost is not aware that this function is provided through the linked in libgcc, it fails:
ERROR: modpost: kernel/locking/test-ww_mutex.ko: symbol '__mulsi3' undefined!
ERROR: modpost: kernel/time/test_udelay.ko: symbol '__mulsi3' undefined!
ERROR: modpost: kernel/resource_kunit.ko: symbol '__mulsi3' undefined!
ERROR: modpost: fs/fuse/virtiofs.ko: symbol '__mulsi3' undefined! etc.
Make sure modpost can see the symbol from libgcc.
--- arch/nios2/kernel/nios2_ksyms.c | 1 + 1 file changed, 1 insertion(+)
arch/nios2/kernel/nios2_ksyms.c +1 -0
@@ -39,6 +39,7 @@ DECLARE_EXPORT(__udivsi3);DECLARE_EXPORT (__umoddi3);DECLARE_EXPORT (__umodsi3);DECLARE_EXPORT (__muldi3); +DECLARE_EXPORT (__mulsi3);DECLARE_EXPORT (__ucmpdi2);DECLARE_EXPORT (__lshrdi3);DECLARE_EXPORT (__ashldi3);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2628/2857 ALSA: pcm: Remove channel-map controls before freeing substreams
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d5dd05c1f72a95d8ab06828d7272a185ad2b9185 ]
A late HDA codec bind on an already registered card builds new PCMs before registering them. add_std_chmaps() publishes generic channel-map controls during this BUILD stage. If an earlier chmap succeeds and a later allocation fails, probe cleanup frees the BUILD PCM while the card's control device remains accessible.
These generic controls are added directly by snd_pcm_add_chmap_ctls(); snd_hda_ctls_clear() only removes codec-tracked mixer controls. BUILD devices also skip dev_disconnect. snd_pcm_free_stream() then frees the substreams before free_chmap() withdraws their generic control:
Late HDA codec bind / rollback Control GET on the live card
------------------------------ ----------------------------
hda_codec_driver_probe()
snd_hda_codec_build_pcms()
PCM is BUILD
snd_hda_codec_build_controls()
add_std_chmaps()
publish an earlier chmap
later allocation: -ENOMEM
snd_hda_codec_cleanup_for_unbind()
snd_hda_ctls_clear()
generic chmap remains
codec_release_pcms()
snd_device_free()
BUILD: skip dev_disconnect snd_pcm_free_stream()
kfree(substream)
snd_ctl_elem_read()
down_read(controls_rwsem) pcm_chmap_ctl_get()
walk freed substream
free_chmap()
snd_ctl_remove()
wait for GET
up_read(controls_rwsem)
The control read lock cannot protect a substream already freed before control removal starts. The failure above occurs before snd_card_register(), so the PCM has not transitioned out of BUILD.
Move free_chmap() before the substream free loop. Its snd_ctl_remove() withdraws the control and drains readers under controls_rwsem before any substream is released. Normal registered-device disconnect already removes the control, so the later call remains harmless on that path.
--- sound/core/pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/pcm.c +3 -1
@@ -830,6 +830,9 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)/* free all proc files under the stream */ snd_pcm_stream_proc_done (pstr); +/* Drain channel-map callbacks before freeing the substreams. */ +free_chmap (pstr); + substream = pstr->substream;while (substream) { substream_next = substream->next;
@@ -844,7 +847,6 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) kfree(setup); }#endif -free_chmap (pstr);if (pstr->substream_count)put_device (&pstr->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2629/2857 cleanup: Add conditional guard support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
[ Upstream commit e4ab322fbaaaf84b23d6cb0e3317a7f68baf36dc ]
Adds:
- DEFINE_GUARD_COND() / DEFINE_LOCK_GUARD_1_COND() to extend existing guards with conditional lock primitives, eg. mutex_trylock(), mutex_lock_interruptible().
nb. both primitives allow NULL 'locks', which cause the lock to
fail (obviously).
- extends scoped_guard() to not take the body when the the conditional guard 'fails'. eg.
scoped_guard (mutex_intr, &task->signal_cred_guard_mutex) {
...
}will only execute the body when the mutex is held.
- provides scoped_cond_guard(name, fail, args...); which extends scoped_guard() to do fail when the lock-acquire fails.
Stable-dep-of: bb4834d5242c ("ALSA: pcm: Protect channel-map reads against runtime detach")
--- include/linux/cleanup.h | 52 +++++++++++++++++++++++++++++++++++++--- include/linux/mutex.h | 3 ++- include/linux/rwsem.h | 8 +++---- include/linux/spinlock.h | 15 ++++++++++++ 4 files changed, 70 insertions(+), 8 deletions(-)
include/linux/cleanup.h +49 -3
@@ -92,25 +92,55 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \* trivial wrapper around DEFINE_CLASS() above specifically * for locks. * +* DEFINE_GUARD_COND(name, ext, condlock) +* wrapper around EXTEND_CLASS above to add conditional lock +* variants to a base class, eg. mutex_trylock() or +* mutex_lock_interruptible(). +* * guard(name): -* an anonymous instance of the (guard) class +* an anonymous instance of the (guard) class, not recommended for +* conditional locks. * * scoped_guard (name, args...) { }: * similar to CLASS(name, scope)(args), except the variable (with the * explicit name 'scope') is declard in a for-loop such that its scope is * bound to the next (compound) statement. * +* for conditional locks the loop body is skipped when the lock is not +* acquired. +* +* scoped_cond_guard (name, fail, args...) { }: +* similar to scoped_guard(), except it does fail when the lock +* acquire fails. +* */ #define DEFINE_GUARD (_name, _type, _lock, _unlock) \ - DEFINE_CLASS(_name, _type, _unlock, ({ _lock; _T; }), _type _T) + DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \ + static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \ + { return *_T; } + +#define DEFINE_GUARD_COND (_name, _ext, _condlock) \ + EXTEND_CLASS(_name, _ext, \ + ({ void *_t = _T; if (_T && !(_condlock)) _t = NULL; _t; }), \ + class_##_name##_t _T) \ + static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \ + { return class_##_name##_lock_ptr(_T); }#define guard (_name) \ CLASS(_name, __UNIQUE_ID(guard)) +#define __guard_ptr (_name) class_##_name##_lock_ptr + #define scoped_guard(_name, args...) \ for (CLASS(_name, scope)(args), \ - *done = NULL; !done; done = (void *)1) + *done = NULL; __guard_ptr(_name)(&scope) && !done; done = (void *)1) + +#define scoped_cond_guard(_name, _fail, args...) \ + for (CLASS(_name, scope)(args), \ + *done = NULL; !done; done = (void *)1) \ + if (!__guard_ptr(_name)(&scope)) _fail; \ + else/* * Additional helper macros for generating lock guards with types, either for
@@ -119,6 +149,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \* * DEFINE_LOCK_GUARD_0(name, lock, unlock, ...) * DEFINE_LOCK_GUARD_1(name, type, lock, unlock, ...) +* DEFINE_LOCK_GUARD_1_COND(name, ext, condlock) * * will result in the following type: *
@@ -140,6 +171,11 @@ typedef struct { \ static inline void class_##_name##_destructor(class_##_name##_t *_T) \ { \if (_T->lock) { _unlock; } \ +} \ + \ +static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \ +{ \ +return _T->lock; \ }
@@ -168,4 +204,14 @@ __DEFINE_LOCK_GUARD_1(_name, _type, _lock) __DEFINE_UNLOCK_GUARD(_name, void, _unlock, __VA_ARGS__) \ __DEFINE_LOCK_GUARD_0(_name, _lock) +#define DEFINE_LOCK_GUARD_1_COND (_name, _ext, _condlock) \ + EXTEND_CLASS(_name, _ext, \ + ({ class_##_name##_t _t = { .lock = l }, *_T = &_t;\ + if (_T->lock && !(_condlock)) _T->lock = NULL; \ + _t; }), \ + typeof_member(class_##_name##_t, lock) l) \ + static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \ + { return class_##_name##_lock_ptr(_T); } + +#endif /* __LINUX_GUARDS_H */
include/linux/mutex.h +2 -1
@@ -248,6 +248,7 @@ extern void mutex_unlock(struct mutex *lock);extern int atomic_dec_and_mutex_lock (atomic_t *cnt,struct mutex *lock); DEFINE_GUARD(mutex, struct mutex *, mutex_lock(_T), mutex_unlock(_T)) -DEFINE_FREE(mutex, struct mutex *, if (_T) mutex_unlock(_T)) +DEFINE_GUARD_COND(mutex, _try, mutex_trylock(_T)) +DEFINE_GUARD_COND(mutex, _intr, mutex_lock_interruptible(_T) == 0)#endif /* __LINUX_MUTEX_H */
include/linux/rwsem.h +4 -4
@@ -203,11 +203,11 @@ extern void up_read(struct rw_semaphore *sem);extern void up_write (struct rw_semaphore *sem); DEFINE_GUARD(rwsem_read, struct rw_semaphore *, down_read(_T), up_read(_T)) -DEFINE_GUARD(rwsem_write, struct rw_semaphore *, down_write(_T), up_write(_T)) - -DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T)) -DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T)) +DEFINE_GUARD_COND(rwsem_read, _try, down_read_trylock(_T)) +DEFINE_GUARD_COND(rwsem_read, _intr, down_read_interruptible(_T) == 0) +DEFINE_GUARD(rwsem_write, struct rw_semaphore *, down_write(_T), up_write(_T)) +DEFINE_GUARD_COND (rwsem_write, _try,down_write_trylock (_T))/* * downgrade write lock to read lock
include/linux/spinlock.h +15 -0
@@ -498,6 +498,8 @@ DEFINE_LOCK_GUARD_1(raw_spinlock, raw_spinlock_t, raw_spin_lock(_T->lock), raw_spin_unlock(_T->lock)) +DEFINE_LOCK_GUARD_1_COND(raw_spinlock, _try, raw_spin_trylock(_T->lock)) +DEFINE_LOCK_GUARD_1 (raw_spinlock_nested, raw_spinlock_t,raw_spin_lock_nested (_T->lock,SINGLE_DEPTH_NESTING ),raw_spin_unlock (_T->lock))
@@ -506,23 +508,36 @@ DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t, raw_spin_lock_irq(_T->lock), raw_spin_unlock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock)) + DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t, raw_spin_lock_irqsave(_T->lock, _T->flags), raw_spin_unlock_irqrestore(_T->lock, _T->flags), unsigned long flags) +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irqsave, _try, + raw_spin_trylock_irqsave(_T->lock, _T->flags)) + DEFINE_LOCK_GUARD_1(spinlock, spinlock_t, spin_lock(_T->lock), spin_unlock(_T->lock)) +DEFINE_LOCK_GUARD_1_COND(spinlock, _try, spin_trylock(_T->lock)) + DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t, spin_lock_irq(_T->lock), spin_unlock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1_COND(spinlock_irq, _try, + spin_trylock_irq(_T->lock)) + DEFINE_LOCK_GUARD_1(spinlock_irqsave, spinlock_t, spin_lock_irqsave(_T->lock, _T->flags), spin_unlock_irqrestore(_T->lock, _T->flags), unsigned long flags) +DEFINE_LOCK_GUARD_1_COND(spinlock_irqsave, _try, + spin_trylock_irqsave(_T->lock, _T->flags)) +#undef __LINUX_INSIDE_SPINLOCK_H#endif /* __LINUX_SPINLOCK_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2630/2857 ALSA: pcm: Protect channel-map reads against runtime detach
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit bb4834d5242c4829c0d8467ee68eb25a9bafc38d ]
Channel-map controls remain accessible between PCM opens. In-tree HDA code publishes the generic controls through add_std_chmaps(), so a SNDRV_CTL_IOCTL_ELEM_READ can overlap the final close of the same PCM substream.
pcm_chmap_ctl_get() checks substream->runtime and later reads its channel count. Final close clears and frees that runtime under pcm->open_mutex, while the control callback holds only controls_rwsem:
Control GET Final PCM close
----------- ---------------
snd_ctl_elem_read()
down_read(controls_rwsem)
pcm_chmap_ctl_get()
check substream->runtime
lock(pcm->open_mutex)
snd_pcm_release_substream()
snd_pcm_detach_substream()
substream->runtime = NULL
kfree(runtime)
unlock(pcm->open_mutex)
substream->runtime->channels
NULL or freed-pointer access
up_read(controls_rwsem)Reloading the cleared field can fault through NULL, while retaining the old pointer can access freed storage. controls_rwsem keeps the control alive, but does not serialize the matching PCM close.
Copy the channel count under open_mutex and use that scalar for the map lookup. Use trylock with -EBUSY because snd_pcm_dev_disconnect() takes open_mutex before removing controls under controls_rwsem; blocking in the reverse order from GET could deadlock.
--- sound/core/pcm_lib.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/core/pcm_lib.c +13 -3
@@ -2397,6 +2397,7 @@ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,unsigned int idx =snd_ctl_get_ioffidx (kcontrol, &ucontrol->id);struct snd_pcm_substream *substream;const struct snd_pcm_chmap_elem *map; +unsigned int channels;if (!info->chmap)return -EINVAL ;
@@ -2405,11 +2406,20 @@ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol,return -ENODEV ;memset (ucontrol->value.integer.value,0 ,sizeof (long ) * info->max_channels); -if (!substream->runtime) -return 0 ;/* no channels set */ +/* +* PCM disconnect takes open_mutex before removing controls. +* Use trylock to avoid a deadlock with controls_rwsem. +*/ +scoped_cond_guard (mutex_try, return -EBUSY , + &info->pcm->open_mutex) { +if (!substream->runtime) +return 0 ;/* no channels set */ + channels = substream->runtime->channels; + }for (map = info->chmap; map->channels; map++) {int i; -if (map->channels == substream->runtime->channels && + +if (map->channels == channels &&valid_chmap_channels (info, map->channels)) {for (i =0 ; i < map->channels; i++) ucontrol->value.integer.value[i] = map->map[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2631/2857 ALSA: aloop: Keep the timer source alive until card release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 762ef425cf0ac9c4b9e9e61e0da0950e16e6fbea ]
The timer_source string must remain valid while PCM opens can select and parse it. loopback_set_timer_source() allocates the string with parent-device devres, which can release it while the card is still registered.
A successful nonempty proc replacement after snd_card_register() adds the string allocation after trigger_card_free. Unbinding the platform device while snd_aloop remains loaded releases devres in reverse order. An open for an unused cable can run after the string is freed and before the card-free action disconnects the card:
Device unbind PCM open
devres_release_all()
free replacement string
snd_pcm_open()
snd_card_file_add()
loopback_open()
loopback_snd_timer_open()
loopback_parse_timer_id()
trigger_card_free()
snd_card_free()
snd_card_disconnect()The parser can then read freed memory. KASAN has reported a one-byte use-after-free read in strchr() from loopback_snd_timer_open(). The cable_lock mutex serializes explicit replacements with opens, but implicit devres release does not take it. The card and module references held by PCM open do not retain this separate devres allocation.
Use kstrdup() and release the current string from card->private_free. PCM admission already retains the card until each file is removed, and card disconnect drains proc callbacks before final card release. This keeps the string alive across admitted PCM opens and preserves the cable_lock serialization of replacements. Install the callback before the initial allocation so probe failures also release the string.
--- sound/drivers/aloop.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
sound/drivers/aloop.c +11 -6
@@ -1716,13 +1716,10 @@ static int loopback_cable_proc_new(struct loopback *loopback, int cidx)static void loopback_set_timer_source (struct loopback *loopback,const char *value) { -if (loopback->timer_source) { -devm_kfree (loopback->card->dev, loopback->timer_source); - loopback->timer_source =NULL ; - } +kfree (loopback->timer_source); + loopback->timer_source =NULL ;if (value && *value) - loopback->timer_source =devm_kstrdup (loopback->card->dev, - value,GFP_KERNEL ); + loopback->timer_source =kstrdup (value,GFP_KERNEL ); } static void print_timer_source_info(struct snd_info_entry *entry,
@@ -1755,6 +1752,13 @@ static int loopback_timer_source_proc_new(struct loopback *loopback) change_timer_source_info); } +static void loopback_private_free (struct snd_card *card) +{ +struct loopback *loopback = card->private_data; + +kfree (loopback->timer_source); +} +static int loopback_probe (struct platform_device *devptr) {struct snd_card *card;
@@ -1780,6 +1784,7 @@ static int loopback_probe(struct platform_device *devptr) pcm_substreams[dev] =MAX_PCM_SUBSTREAMS ; loopback->card = card; + card->private_free = loopback_private_free;loopback_set_timer_source (loopback, timer_source[dev]);mutex_init (&loopback->cable_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2632/2857 cgroup/cpuset: use mems_allowed_seq when checking a policy nodemask
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit b0cec62d2867ab3ed27604d5c177b8960c43b17a ]
A cpuset update changes the task's mems_allowed and rebinds its mempolicy in separate steps under mems_allowed_seq, but the check reads both without it. This can cause a spurious numa placement miss under some cpuset/mempolicy combinations.
A reader that loads one mask before the update and the other after it can see a spurious empty intersection and drop the nodemask.
For example, a task with cpuset.mems={0} and MPOL_BIND={0}. If the cpuset moves to mems={1,2}, the policy is rebound to {1}.
The allocator can race and compare the old mems_allowed {0} against the new policy {1} - which will result in a dropped nodemask and a misplaced allocation on node 2.
Simply retry the intersection until mems_allowed_seq is stable.
This covers the task policy, which is rebound under mems_allowed_seq. VMA policies are rebound afterwards by mpol_rebind_mm(), outside mems_allowed_seq, and are not covered by this change.
--- kernel/cgroup/cpuset.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/cgroup/cpuset.c +12 -1
@@ -3790,10 +3790,21 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)* @nodemask: the nodemask to be checked * * Are any of the nodes in the nodemask allowed in current->mems_allowed? +* +* A cpuset update rebinds the task's mempolicy and changes mems_allowed in +* separate steps, so retry if an update raced with the check. */ int cpuset_nodemask_valid_mems_allowed (nodemask_t *nodemask) { -return nodes_intersects (*nodemask, current->mems_allowed); +unsigned int seq; +int ret; + +do { + seq =read_mems_allowed_begin (); + ret =nodes_intersects (*nodemask, current->mems_allowed); + }while (read_mems_allowed_retry (seq)); + +return ret; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2633/2857 net/sched: act_api: reject duplicate actions in a batch
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f67b3ed1308d7a282e2d6202d61af052ab0da39e ]
tca_action_gd() builds actions[] with one tcf_action_get_1() per nested TCA_ACT_TAB entry. Each successful lookup takes its own reference to the resolved action, so repeated TCA_ACT_INDEX entries in one request yield the same pointer in multiple slots.
For RTM_DELACTION, tcf_action_delete() then consumes two references per
slot: one in tcf_action_put() and one in tcf_idr_delete_index(). A duplicate therefore drives the refcount to zero mid-walk -- the delete frees the action and removes its IDR slot -- and the next slot calls tcf_action_put() on the freed action:
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:87 at refcount_dec_not_one refcount_dec_and_mutex_lock __tcf_action_put tca_action_gd
Three duplicate entries are enough. Reject a repeated action while a delete batch is built, dropping the reference the extra lookup took, and return -EINVAL. RTM_GETACTION balances its own references and keeps accepting duplicate entries.
Conditions to recreate the bug:
tc actions add action gact index 100
tc actions delete action gact index 100 action gact index 100 \
action gact index 100
--- net/sched/act_api.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
net/sched/act_api.c +20 -1
@@ -1994,7 +1994,7 @@ static int tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, u32 portid, int event, struct netlink_ext_ack *extack) { - int i, ret; + int i, j, ret;struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;size_t attr_size =0 ;
@@ -2019,6 +2019,25 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, ret =PTR_ERR (act); goto err; } + +/* A delete consumes two references per slot (tcf_action_put() +* and tcf_idr_delete_index()) but each entry takes one, so a +* repeated action would hit zero mid-walk. GET balances its +* own references and keeps accepting duplicates. +*/ +if (event ==RTM_DELACTION ) { +for (j =0 ; j < i -1 ; j++) { +if (actions[j] != act) +continue ; + +tcf_action_put (act); +NL_SET_ERR_MSG (extack, +"Duplicate TC action in a delete batch" ); + ret = -EINVAL ; + goto err; + } + } + attr_size +=tcf_action_fill_size (act); actions[i -1 ] = act; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2634/2857 RDMA/mlx5: Fix CQ resize destination index mask
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 0fe31052d948a3a993bb2f58cd5886f7ec279ea7 ]
In copy_resize_cqes, the destination CQE index is computed as (i + 1) & cq->resize_buf->nent, but resize_buf->nent is produced by roundup_pow_of_two(), so it is a power of two with exactly one bit set. Masking with a single-bit value can only yield 0 or nent itself. The buffer has nent entries, so valid indices are 0 .. nent - 1 and nent is one past the last slot; whenever the masked result is nent the following memcpy writes one entry out of bounds.
Use (nent - 1) as the wrap mask instead. For a power-of-two nent, (i + 1) & (nent - 1) is the correct modulo-nent reduction, keeping the index within [0, nent - 1]. This matches get_sw_cqe(), which addresses the CQ buffer via n & cq->ibcq.cqe, where cq->ibcq.cqe == entries - 1 is exactly the nent - 1 wrap mask.
--- drivers/infiniband/hw/mlx5/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cq.c +1 -1
@@ -1250,7 +1250,7 @@ static int copy_resize_cqes(struct mlx5_ib_cq *cq)while (get_cqe_opcode (scqe64) !=MLX5_CQE_RESIZE_CQ ) { dcqe =mlx5_frag_buf_get_wqe (&cq->resize_buf->fbc, - (i +1 ) & cq->resize_buf->nent); + (i +1 ) & (cq->resize_buf->nent -1 )); dcqe64 = dsize ==64 ? dcqe : dcqe +64 ; sw_own =sw_ownership_bit (i +1 , cq->resize_buf->nent);memcpy (dcqe, scqe, dsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2635/2857 net: stmmac: Fix interrupt handling for level-triggered mode in DWC_XGMAC2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: EricChan <[email protected]>
[ Upstream commit 78b7920a03351a8402de2f81914c1d2e2bdf24b7 ]
According to the Synopsys Controller IP XGMAC-10G Ethernet MAC Databook v3.30a (section 2.7.2), when the INTM bit in the DMA_Mode register is set to 2, the sbd_perch_tx_intr_o[] and sbd_perch_rx_intr_o[] signals operate in level-triggered mode. However, in this configuration, the DMA does not assert the XGMAC_NIS status bit for Rx or Tx interrupt events.
This creates a functional regression where the condition
if (likely(intr_status & XGMAC_NIS)) in dwxgmac2_dma_interrupt() will never evaluate to true, preventing proper interrupt handling for level-triggered mode. The hardware specification explicitly states that "The DMA does not assert the NIS status bit for the Rx or Tx interrupt events" (Synopsys DWC_XGMAC2 Databook v3.30a, sec. 2.7.2).
The fix ensures correct handling of both edge and level-triggered interrupts while maintaining backward compatibility with existing configurations. It has been tested on the hardware device (not publicly available), and it can properly trigger the RX and TX interrupt handling in both the INTM=0 and INTM=2 configurations.
Stable-dep-of: 305deb54c6c2 ("net: stmmac: xgmac: do not treat TBU as a TX event")
--- .../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +11 -13
@@ -360,19 +360,17 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv, }/* TX/RX NORMAL interrupts */ -if (likely (intr_status &XGMAC_NIS )) { -if (likely (intr_status &XGMAC_RI )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->rx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); - ret |= handle_rx; - } -if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->tx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); - ret |= handle_tx; - } +if (likely (intr_status &XGMAC_RI )) { +u64_stats_update_begin (&stats->syncp); +u64_stats_inc (&stats->rx_normal_irq_n[chan]); +u64_stats_update_end (&stats->syncp); + ret |= handle_rx; + } +if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { +u64_stats_update_begin (&stats->syncp); +u64_stats_inc (&stats->tx_normal_irq_n[chan]); +u64_stats_update_end (&stats->syncp); + ret |= handle_tx; }/* Clear interrupts */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2636/2857 net: stmmac: xgmac: do not treat TBU as a TX event
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengfei Zhang <[email protected]>
[ Upstream commit 305deb54c6c287e586bed92da2375ae1220e8dde ]
Commit 8d07a7930434 ("net: stmmac: xgmac: Do not enable TBU interrupt") removed TBUE from the default DMA interrupt mask, but did not remove the TBU check from dwxgmac2_dma_interrupt().
TBU is set whenever a TX channel runs out of descriptors. Since TBUE is not enabled and only enabled bits are cleared, the TBU status bit is never cleared. As a result, TBU stays set on every idle TX channel, regardless of whether there is any TX traffic.
With a shared interrupt, stmmac_dma_interrupt() checks all channels, so every interrupt from any source schedules TX NAPI on every idle TX channel.
Only use TI to trigger TX processing.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +1 -1
@@ -366,7 +366,7 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv,u64_stats_update_end (&stats->syncp); ret |= handle_rx; } -if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { +if (likely (intr_status &XGMAC_TI )) {u64_stats_update_begin (&stats->syncp);u64_stats_inc (&stats->tx_normal_irq_n[chan]);u64_stats_update_end (&stats->syncp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2637/2857 mptcp: options: mpc: avoid printing uninit data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit a234ee8eb9a20d1a272f0d2ceabdb35165071778 ]
When parsing the MP_CAPABLE suboption, this pr_debug() might read and print uninitialised values.
That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing uninit data.
So read these fields only if they have been set.
Note: this was initially reported by Clashiko as an existing issue. The code has been analysed by a human and confirmed. This is a non-urgent fix.
--- net/mptcp/options.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/mptcp/options.c +5 -2
@@ -126,8 +126,11 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr +=2 ; }pr_debug ("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u\n" , - version, flags, opsize, mp_opt->sndr_key, - mp_opt->rcvr_key, mp_opt->data_len, mp_opt->csum); + version, flags, opsize, + opsize >=TCPOLEN_MPTCP_MPC_SYNACK ? mp_opt->sndr_key :0 , + opsize >=TCPOLEN_MPTCP_MPC_ACK ? mp_opt->rcvr_key :0 , + opsize >=TCPOLEN_MPTCP_MPC_ACK_DATA ? mp_opt->data_len :0 , + opsize ==TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM ? mp_opt->csum :0 );break ;case MPTCPOPT_MP_JOIN :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2638/2857 mptcp: options: dss: avoid printing uninit csum
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit 00e2690c9dad0e09cd2a4435b98de6d8efd5fbc2 ]
When parsing the DSS suboption, this pr_debug() might read and print uninitialised checksum value.
That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing uninit data.
So read this csum field only if it has been set.
Note: this was initially reported by Clashiko as an existing issue. The code has been analysed by a human and confirmed. This is a non-urgent fix.
--- net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -259,7 +259,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u\n" , mp_opt->data_seq, mp_opt->subflow_seq, mp_opt->data_len, !!(mp_opt->suboptions &OPTION_MPTCP_CSUMREQD ), - mp_opt->csum); + (mp_opt->suboptions &OPTION_MPTCP_CSUMREQD ) ? mp_opt->csum :0 ); }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2639/2857 net: stmmac: avoid duplicate XSK TX completions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit daac93975b8ff0a0a036a5e3562236c0b40c3e36 ]
stmmac_tx_clean() reports completed AF_XDP TX descriptors through xsk_tx_completed(), but leaves their buffer type as STMMAC_TXBUF_T_XSK_TX. The slots retain that type until they are reused for another buffer type.
On interface close or XDP teardown, dma_free_tx_skbufs() walks the entire TX ring, not just the dirty_tx..cur_tx range. stmmac_free_tx_buffer() counts the stale XSK_TX slots again, causing xsk_tx_completed() to advance the completion-ring producer for buffers that have already been returned. This publishes completion entries without matching outstanding TX reservations and corrupts completion accounting for a socket which stays bound across the teardown.
Reset the XSK buffer type after counting the completion in both stmmac_tx_clean() and stmmac_free_tx_buffer(). XSK TX slots have a NULL skb pointer and no per-slot DMA mapping, so the SKB type represents an empty slot. Pending XSK descriptors keep their type until they are completed or released, and a released slot can no longer be counted again by a later cleanup.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -2
@@ -1534,8 +1534,10 @@ static void stmmac_free_tx_buffer(struct stmmac_priv *priv, tx_q->xdpf[i] =NULL ; } -if (tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_XSK_TX ) +if (tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_XSK_TX ) { tx_q->xsk_frames_done++; + tx_q->tx_skbuff_dma[i].buf_type =STMMAC_TXBUF_T_SKB ; + }if (tx_q->tx_skbuff[i] && tx_q->tx_skbuff_dma[i].buf_type ==STMMAC_TXBUF_T_SKB ) {
@@ -2644,8 +2646,11 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue) tx_q->xdpf[entry] =NULL ; } -if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_XSK_TX ) +if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_XSK_TX ) { tx_q->xsk_frames_done++; +/* Teardown must not count this slot again. */ + tx_q->tx_skbuff_dma[entry].buf_type =STMMAC_TXBUF_T_SKB ; + }if (tx_q->tx_skbuff_dma[entry].buf_type ==STMMAC_TXBUF_T_SKB ) {if (likely (skb)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2640/2857 rtc: mpfs: Fix alarm register word order
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baek Kyu, Kim <[email protected]>
[ Upstream commit d691a96370b6cd7e684e4da1c473c09df963611b ]
mpfs_rtc_readalarm() swaps the low and high words of the alarm time. The RTC core reads this value during device registration to initialize its alarm timer. This can populate the cached alarm and timer queue with an incorrect expiry time, or leave an enabled hardware alarm out of the timer queue if the decoded time appears to be in the past.
Read the low 32 bits from ALARM_LOWER_REG and place the masked high 11 bits from ALARM_UPPER_REG in bits 42:32. This matches the layout used by mpfs_rtc_setalarm() and the low/high assembly in mpfs_rtc_readtime(), so the RTC core imports the programmed alarm time correctly during device registration.
--- drivers/rtc/rtc-mpfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-mpfs.c +2 -2
@@ -131,8 +131,8 @@ static int mpfs_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) alrm->enabled = mode &MODE_WAKE_EN ; - time = (u64 )readl (rtcdev->base +ALARM_LOWER_REG ) <<32 ; - time |= (readl (rtcdev->base +ALARM_UPPER_REG ) &ALARM_UPPER_MASK ); + time =readl (rtcdev->base +ALARM_LOWER_REG ); + time |= ((u64 )readl (rtcdev->base +ALARM_UPPER_REG ) &ALARM_UPPER_MASK ) <<32 ;rtc_time64_to_tm (time, &alrm->time);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2641/2857 rtc: class: Make the time32 hctosys limit configurable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit b253c2e96a80aac8e2bc67b425bf007ed78d4d8c ]
The RTC_HCTOSYS feature faces an impossible dilemma on 32-bit systems:
a) systemd requires RTC_HCTOSYS=y with the correct timestamp for its intended operation
b) broken RTC hardware can produce random future timestamps beyond 2038 at boot time
c) time32 userspace immediately hangs if the time is set to a date beyond 2038 and requires timestamps to be clamped
d) time64 userspace is intended to survive the actual 2038 date and requires timestamps to not be clamped
Commit b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t") introduced this limit to protect time32 userspace from future RTC dates that can break boot and address constraints a), b) and c), but broke d) in the process by limiting RTC_HCTOSYS to the time32 range and falling back to RTC_HCTOSYS=n behavior when the RTC time overflows that.
Make the behavior configurable with a new RTC_HCTOSYS_TIME32_LIMIT option that chooses between breaking c) or d). On systems with COMPAT_32BIT_TIME=n, only RTC_HCTOSYS_TIME32_LIMIT=n is allowed since userspace can be assumed to be fully built for time64. 64-bit kernels running 32-bit userland never had the cutoff and continue to not offer the option.
Warn on rejection with the RTC date and option name so users can identify the cause and find the setting.
[arnd: reword Kconfig text and patch description,
add COMPAT_32BIT_TIME dependency]
----
I ended up rewriting most of the text but kept Karl's ownership as he did the original patch.
--- drivers/rtc/Kconfig | 21 +++++++++++++++++++++ drivers/rtc/class.c | 8 +++++--- 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/rtc/Kconfig +21 -0
@@ -30,6 +30,27 @@ config RTC_HCTOSYS the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. +config RTC_HCTOSYS_TIME32_LIMIT + bool "Reject RTC dates after the 2038 cutoff" + depends on RTC_HCTOSYS && COMPAT_32BIT_TIME && !64BIT + default y + help + Reject RTC dates after 03:14:07 UTC on 19 January 2038 when + initializing the system clock in order to work around broken + RTC implementations that produce nondeterministic timestamps + without a working backup battery. + + A rejected date leaves system time unchanged, normally near + the Unix epoch, and the RTC's hctosys sysfs attribute reads + 0. Userspace must supply the time if no other source has + initialized it. + + Say Y here if the kernel may have to run old time32 userspace on + hardware that can produce unpredictable RTC timestamps. If the + kernel is intended to only run time64 compatible userspace and + continue working past 2038, you must pick N here in order to + have a working RTC_HCTOSYS functionality. + config RTC_HCTOSYS_DEVICE string "RTC used to set the system time" depends on RTC_HCTOSYS
drivers/rtc/class.c +5 -3
@@ -73,12 +73,14 @@ static void rtc_hctosys(struct rtc_device *rtc) tv64.tv_sec =rtc_tm_to_time64 (&tm); -#if BITS_PER_LONG ==32 -if (tv64.tv_sec >INT_MAX ) { +if (IS_ENABLED (CONFIG_RTC_HCTOSYS_TIME32_LIMIT ) && + tv64.tv_sec >INT_MAX ) { +dev_warn (rtc->dev.parent, +"hctosys: rejecting %ptR UTC due to CONFIG_RTC_HCTOSYS_TIME32_LIMIT=y\n" , + &tm); err = -ERANGE ; goto err_read; } -#endif err =do_settimeofday64 (&tv64);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2642/2857 timers: Clear pending_map on CPU hotplug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Hao <[email protected]>
[ Upstream commit e7cad586d73276cbd4466de81b2092287d7475c0 ]
CPU hotplug migration leaves pending_map bits set on the outgoing CPU while its wheel vectors are empty. After re-online, a later next_expiry recalc can treat those empty buckets as pending and temporarily pull next_expiry forward until collect drains the bits.
Clear pending_map under the base lock after migration in timers_dead_cpu().
--- kernel/time/timer.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/time/timer.c +2 -0
@@ -45,6 +45,7 @@#include <linux/compat.h> #include <linux/random.h> #include <linux/sysctl.h> +#include <linux/bitmap.h> #include <linux/uaccess.h> #include <asm/unistd.h>
@@ -2273,6 +2274,7 @@ int timers_dead_cpu(unsigned int cpu)for (i =0 ; i <WHEEL_SIZE ; i++)migrate_timer_list (new_base, old_base->vectors + i); +bitmap_zero (old_base->pending_map,WHEEL_SIZE );raw_spin_unlock (&old_base->lock);raw_spin_unlock_irq (&new_base->lock);put_cpu_ptr (&timer_bases);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2643/2857 ASoC: cs42l56: Remove the ADC Mute Switch control
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit ff404ef11b975baf38c4472c51a6674c239e8021 ]
The ADC Mute Switch control writes bits 2 and 3 of the Misc ADC Control register. These are the ADCA Invert and ADCB Invert bits, which have their own controls. The ADC mute bits are bits 0 and 1, and the DAI mute callback already sets them.
So the control has never muted the ADCs, and nobody can be relying on it. Remove it rather than point it at the mute bits, so the ADCs are muted in one place only.
--- sound/soc/codecs/cs42l56.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/codecs/cs42l56.c +0 -1
@@ -387,7 +387,6 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { CS42L56_PGAB_MUX_VOLUME, 0, 0x34, 0x24, pga_tlv),SOC_DOUBLE_R_TLV ("ADC Volume" ,CS42L56_ADCA_ATTENUATOR ,CS42L56_ADCB_ATTENUATOR ,0 ,0x00 ,1 , adc_tlv), -SOC_DOUBLE ("ADC Mute Switch" ,CS42L56_MISC_ADC_CTL ,2 ,3 ,1 ,1 ),SOC_DOUBLE ("ADC Boost Switch" ,CS42L56_GAIN_BIAS_CTL ,3 ,2 ,1 ,1 ), SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L56_HPA_VOLUME,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2644/2857 dt-bindings: clock: mediatek: Add MT8516 fallbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <[email protected]>
[ Upstream commit 1d48ecb48e2ab9dd2564e735a1c1b29a5eeeb599 ]
MT8516 topckgen and apmixedsys nodes use the common syscon fallback form. Add the MT8516 compatibles to the branches that allow the syscon fallback.
--- .../devicetree/bindings/clock/mediatek,apmixedsys.yaml | 2 +- Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,apmixedsys.yaml +1 -1
@@ -23,7 +23,6 @@ properties: - mediatek,mt7986-apmixedsys - mediatek,mt8135-apmixedsys - mediatek,mt8173-apmixedsys - - mediatek,mt8516-apmixedsys - items: - const: mediatek,mt7623-apmixedsys - const: mediatek,mt2701-apmixedsys
@@ -38,6 +37,7 @@ properties: - mediatek,mt7629-apmixedsys - mediatek,mt8167-apmixedsys - mediatek,mt8183-apmixedsys + - mediatek,mt8516-apmixedsys - const: syscon reg:
Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml +1 -1
@@ -22,7 +22,6 @@ properties: - mediatek,mt7622-topckgen - mediatek,mt8135-topckgen - mediatek,mt8173-topckgen - - mediatek,mt8516-topckgen - items: - const: mediatek,mt7623-topckgen - const: mediatek,mt2701-topckgen
@@ -38,6 +37,7 @@ properties: - mediatek,mt7986-topckgen - mediatek,mt8167-topckgen - mediatek,mt8183-topckgen + - mediatek,mt8516-topckgen - const: syscon reg:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2645/2857 net: openvswitch: skip IPv4 later fragments on TCP/UDP set actions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 14c0350142ab0a10ebeefed03b779df23749e16a ]
An IPv4 later fragment carries no L4 header, but key extraction leaves ip.proto set to the real protocol and the flow may wildcard the frag field, so validate_set() accepts such packets. set_tcp() and set_udp() then treat the first bytes of the fragment payload as an L4 header, rewrite them as ports and patch the bytes at the checksum offset, corrupting the packet.
Skip these actions for OVS_FRAG_TYPE_LATER. IPv6 later fragments are not affected, since their ip.proto is NEXTHDR_FRAGMENT and validate_set() rejects L4 set actions for them.
--- net/openvswitch/actions.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/openvswitch/actions.c +6 -0
@@ -617,6 +617,9 @@ static int set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct udphdr ));if (unlikely (err))
@@ -660,6 +663,9 @@ static int set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct tcphdr ));if (unlikely (err))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2646/2857 net: openvswitch: drop IP fragments on SCTP set action
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 4d0d8f491307f22aea34b22f73351e1cd2ede735 ]
The SCTP checksum is a CRC32c over the whole SCTP packet. set_sctp() updates it as old_csum ^ old_correct_csum ^ new_csum, with the two CRCs computed over the bytes of the current skb only. That is correct only when the skb holds the whole SCTP packet. For a first fragment, and for a later fragment, it holds just a part of it, and the CRC delta of a change at the start of the packet depends on how many bytes follow, so the checksum written is wrong. The receiver drops the reassembled packet.
validate_set() accepts SCTP set action for any flow with ip.proto set to SCTP, regardless of the fragmentation bits, as it only receives the masked key. As the checksum cannot be fixed up without the whole datagram, fail the action for packets that are IP fragments of either family, so the packet is dropped with OVS_DROP_ACTION_ERROR instead of being forwarded with modified ports and an invalid checksum.
--- net/openvswitch/actions.c | 3 +++ 1 file changed, 3 insertions(+)
net/openvswitch/actions.c +3 -0
@@ -696,6 +696,9 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key,__le32 old_correct_csum, new_csum, old_csum;int err; +if (flow_key->ip.frag !=OVS_FRAG_TYPE_NONE ) +return -EINVAL ; + err =skb_ensure_writable (skb, sctphoff +sizeof (struct sctphdr ));if (unlikely (err))return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2647/2857 tcp: tcp_metrics: use the socket netns, not the dst device netns
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 504bdcb8c1566a6f887f9accebe1aa99b502ae97 ]
tcp_get_metrics(), __tcp_get_metrics_req() and tcpm_new() look up and create metrics entries in the netns of the cached dst device rather than in the netns of the socket.
These usually match, but not after the device has been moved to another netns or unregistered: a socket can keep a stale dst in sk_dst_cache until it is checked again, and tcp_update_metrics() reads it with __sk_dst_get() without any dst_check(). Once dst_dev_put() has run, the dst device is blackhole_netdev and the entry is created in init_net. Before that, for instance for routes through nexthop objects whose cached dsts are released from a nested RCU callback, it is the netns the device has just been moved to.
A TCP socket of netns A that enters TIME_WAIT in that window then creates or updates an entry carrying A's addresses and RTT in another netns, where TCP_METRICS_CMD_GET can dump it and where new connections to the same peer inherit those metrics.
The metrics belong to the netns of the socket, so use sock_net() for full sockets and request sockets, and pass it to tcpm_new().
Kernel sockets that do not hold a netns reference can still reach tcp_time_wait() after tcp_net_metrics_exit_batch() has flushed the entries of their dismantling netns, and an entry created then would never be flushed and would keep a dangling tcpm_net. Make tcpm_new() refuse to create entries when check_net() fails. Its callers are in an RCU read-side section, and cleanup_net() waits for a grace period between the refcount reaching zero and the flush, so an entry added after a successful check is always seen by the flush.
--- net/ipv4/tcp_metrics.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/ipv4/tcp_metrics.c +15 -5
@@ -161,16 +161,26 @@ static void tcpm_check_stamp(struct tcp_metrics_block *tm, rcu_dereference_protected(p, lockdep_is_held(&tcp_metrics_lock))static struct tcp_metrics_block *tcpm_new (struct dst_entry *dst, +struct net *net,struct inetpeer_addr *saddr,struct inetpeer_addr *daddr,unsigned int hash) {struct tcp_metrics_block *tm;bool reclaim = false; -struct net *net;spin_lock_bh (&tcp_metrics_lock); - net =dst_dev_net_rcu (dst); + +/* Do not add entries to a dismantling netns: they would not be +* flushed again. Callers are in an RCU read-side section, and +* cleanup_net() waits for a grace period after the netns refcount +* reached zero and before tcp_metrics_flush_all(NULL) runs, so an +* entry added after a successful check_net() is seen by the flush. +*/ +if (unlikely (!check_net (net))) { + tm =NULL ; + goto out_unlock; + }/* While waiting for the spin-lock the cache might have been populated * with this entry and so we have to check again.
@@ -273,7 +283,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req,return NULL ; } - net =dst_dev_net_rcu (dst); + net =sock_net (req_to_sk (req)); hash ^=net_hash_mix (net); hash =hash_32 (hash, tcp_metrics_hash_log);
@@ -318,7 +328,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,else return NULL ; - net =dst_dev_net_rcu (dst); + net =sock_net (sk); hash ^=net_hash_mix (net); hash =hash_32 (hash, tcp_metrics_hash_log);
@@ -326,7 +336,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,if (tm ==TCP_METRICS_RECLAIM_PTR ) tm =NULL ;if (!tm && create) - tm =tcpm_new (dst, &saddr, &daddr, hash); + tm =tcpm_new (dst, net, &saddr, &daddr, hash);else tcpm_check_stamp (tm, dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2648/2857 tls: device: protect async RX resync state during device-down
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rishikesh Jethwani <[email protected]>
[ Upstream commit f89a228125238f8d4c7e2b8161e2a85fe35307b6 ]
tls_device_rx_resync_new_rec() can run in process context with the socket lock held, but without an RCU read lock: from the strparser work item (tls_strp_work()) and from the receive paths (tls_rx_rec_wait(), tls_rx_rec_done()). The resync_async pointer belongs to the driver RX context, which tls_device_down() tears down from the netdev notifier without taking the socket lock; only the softirq entry to the parser is implicitly inside an RCU section.
If the parser passes the TLS_RX_DEV_DEGRADED check before device-down sets it, tls_device_down() can complete synchronize_net() and delete the driver context before the parser accesses resync_async->req or its record log. In the asynchronous stage the parser also writes the record log, so this is a write to freed memory, not only a stale read. The RCU section in tls_device_resync_rx() starts after those accesses and therefore does not prevent the use-after-free.
Found by code inspection; not reproduced. Hitting the window requires the parser to be preempted between the DEGRADED check and the resync_async access across the device-down grace period and the driver's teardown.
--- net/tls/tls_device.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
net/tls/tls_device.c +15 -6
@@ -798,8 +798,15 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (tls_ctx->rx_conf !=TLS_HW )return ; + +/* The parser also runs in process context, without an RCU read lock. +* Protect the driver's resync_async state before checking the flags: +* device-down sets DEGRADED and waits for synchronize_net() before +* freeing it, without taking the socket lock. +*/ +rcu_read_lock ();if (unlikely (test_bit (TLS_RX_DEV_DEGRADED , &tls_ctx->flags))) -return ; + goto out; prot = &tls_ctx->prot_info; rx_ctx =tls_offload_ctx_rx (tls_ctx);
@@ -814,11 +821,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (likely (!is_req_pending) || req_seq != seq || !atomic64_try_cmpxchg (&rx_ctx->resync_req, &resync_req,0 )) -return ; + goto out;break ;case TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT :if (likely (!rx_ctx->resync_nh_do_now)) -return ; + goto out;/* head of next rec is already in, note that the sock_inq will * include the currently parsed message when called from parser
@@ -827,7 +834,7 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (sock_data > rcd_len) {trace_tls_device_rx_resync_nh_delay (sk, sock_data, rcd_len); -return ; + goto out; } rx_ctx->resync_nh_do_now =0 ;
@@ -838,16 +845,18 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) resync_req =atomic64_read (&rx_ctx->resync_async->req); is_req_pending = resync_req;if (likely (!is_req_pending)) -return ; + goto out;if (!tls_device_rx_resync_async (rx_ctx->resync_async, resync_req, &seq, &rcd_delta)) -return ; + goto out;tls_bigint_subtract (rcd_sn, rcd_delta);break ; }tls_device_resync_rx (tls_ctx, sk, seq, rcd_sn); +out: +rcu_read_unlock (); } static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2649/2857 net: hix5hd2: serialize timeout recovery with interface teardown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 87cce46329a811ea3fe108ac721e0a2400d0a3bb ]
The timeout worker calls the driver's close and open methods without RTNL or a running-state check. A timeout queued before an interface is closed can call close again after ndo_stop has disabled NAPI. The second napi_disable() can then wait indefinitely. The worker can also race with an ongoing close.
Take RTNL and skip recovery when the interface is no longer running. Use the netdev core close and open helpers so a failed reopen leaves the interface down, rather than leaving it marked running with NAPI disabled.
After unregister_netdev() has stopped the watchdog, drain the worker before releasing its MDIO and descriptor resources. This wait is outside RTNL, allowing an already queued worker to take RTNL, observe the down state, and finish.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +9 -3
@@ -11,6 +11,7 @@#include <linux/of_net.h> #include <linux/of_mdio.h> #include <linux/reset.h> +#include <linux/rtnetlink.h> #include <linux/clk.h> #include <linux/circ_buf.h>
@@ -889,8 +890,13 @@ static void hix5hd2_tx_timeout_task(struct work_struct *work)struct hix5hd2_priv *priv; priv = container_of(work, struct hix5hd2_priv, tx_timeout_task); -hix5hd2_net_close (priv->netdev); -hix5hd2_net_open (priv->netdev); + +rtnl_lock (); +if (netif_running (priv->netdev)) { +dev_close (priv->netdev); +dev_open (priv->netdev,NULL ); + } +rtnl_unlock (); }static void hix5hd2_net_timeout (struct net_device *dev,unsigned int txqueue)
@@ -1289,6 +1295,7 @@ static int hix5hd2_dev_remove(struct platform_device *pdev)struct hix5hd2_priv *priv =netdev_priv (ndev);unregister_netdev (ndev); +cancel_work_sync (&priv->tx_timeout_task);mdiobus_unregister (priv->bus);mdiobus_free (priv->bus);
@@ -1296,7 +1303,6 @@ static int hix5hd2_dev_remove(struct platform_device *pdev)hix5hd2_destroy_sg_desc_queue (priv);hix5hd2_destroy_hw_desc_queue (priv);of_node_put (priv->phy_node); -cancel_work_sync (&priv->tx_timeout_task);free_netdev (ndev);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2650/2857 net: axienet: release every RX buffer in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit b59787892d04a5647a7e662fbb02cd0abdb1a993 ]
The RX walk in axienet_dma_bd_release() stops at the first descriptor without an skb, assuming that such a slot and all after it were never filled. That holds on the axienet_dma_bd_init() error path, but not once the ring has been running: when axienet_rx_poll() fails to allocate or map a replacement buffer it leaves the slot it emptied with a NULL skb, in the middle of a populated ring, until a later poll refills it. Closing the interface before then leaks the skb and the streaming DMA mapping of every descriptor after that slot, which can be most of the ring, and is most likely under memory pressure.
The walk also frees each skb before unmapping it. With swiotlb, the DMA_FROM_DEVICE unmap copies the bounce buffer back into the skb data that was just freed, and on non-coherent platforms it invalidates cache lines that may already belong to a new owner.
Skip empty slots instead of stopping at the first one. An emptied slot still has a non-zero cntrl but its buffer is already unmapped, so the skip has to cover the unmap too, which it does by coming before it. Then unmap before freeing, as axienet_rx_poll() does.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes after each of ten down/up cycles, each running axienet_dma_bd_release(), so the unmap-then-free order is exercised on every buffer. A failed RX refill was not reproduced, so the skip over an empty slot was not exercised.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +7 -5
@@ -224,13 +224,13 @@ static void axienet_dma_bd_release(struct net_device *ndev)for (i =0 ; i < lp->rx_bd_num; i++) {dma_addr_t phys; -/* A NULL skb means this descriptor has not been initialised -* at all. +/* A NULL skb means the descriptor holds no buffer: it was +* never filled, or axienet_rx_poll() took its skb and could +* not refill it, having already unmapped the old buffer. +* Such slots can sit anywhere in a ring that has been running. */ if (!lp->rx_bd_v[i].skb) -break ; - -dev_kfree_skb (lp->rx_bd_v[i].skb); +continue ;/* For each descriptor, we programmed cntrl with the (non-zero) * descriptor size, after it had been successfully allocated.
@@ -241,6 +241,8 @@ static void axienet_dma_bd_release(struct net_device *ndev)dma_unmap_single (lp->dev, phys, lp->max_frm_size,DMA_FROM_DEVICE ); } + +dev_kfree_skb (lp->rx_bd_v[i].skb); } dma_free_coherent(lp->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2651/2857 ipv6: account route exceptions to the netns of their dst
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ff017b891e89276c15f06dfd7155981d572af77 ]
rt6_insert_exception() and rt6_remove_exception() update rt6_stats->fib_rt_cache of dev_net(rt6i->dst.dev), but the device of an exception dst can move to another netns while the exception is still in its bucket.
This happens when the bucket is flushed from an RCU callback, for instance from nexthop_free_rcu() for the nh_info of a replaced nexthop, whose exceptions still point to live routes. If the device moves to another netns before that callback runs, the decrement hits the other netns, whose u32 counter underflows in /proc/net/rt6_stats, while the counter of the original netns never goes back down.
Account exceptions to the netns their dst was allocated in, derived from dst->ops as ip6_dst_gc() already does, which does not depend on the device. The dst already relies on that netns' ip6_dst_ops being alive when it is destroyed, which happens after the exception is removed.
--- net/ipv6/route.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv6/route.c +11 -2
@@ -1485,6 +1485,15 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,*/ static DEFINE_SPINLOCK (rt6_exception_lock); +/* Exceptions are accounted to the netns their dst was allocated in. +* Unlike dev_net(dst->dev), it does not change when the device moves to +* another netns or when dst_dev_put() points the dst to blackhole_netdev. +*/ +static struct net *rt6_exception_net (const struct rt6_info *rt) +{ + return container_of(rt->dst.ops, struct net, ipv6.ip6_dst_ops); +} +/* Remove rt6_ex from hash table and free the memory * Caller must hold rt6_exception_lock */
@@ -1496,7 +1505,7 @@ static void rt6_remove_exception(struct rt6_exception_bucket *bucket,if (!bucket || !rt6_ex)return ; - net =dev_net (rt6_ex->rt6i->dst.dev); + net =rt6_exception_net (rt6_ex->rt6i); net->ipv6.rt6_stats->fib_rt_cache--;/* purge completely the exception to allow releasing the held resources:
@@ -1756,7 +1765,7 @@ static int rt6_insert_exception(struct rt6_info *nrt, rt6_ex->stamp = jiffies;hlist_add_head_rcu (&rt6_ex->hlist, &bucket->chain); bucket->depth++; - net->ipv6.rt6_stats->fib_rt_cache++; +rt6_exception_net (nrt)->ipv6.rt6_stats->fib_rt_cache++;/* Randomize max depth to avoid some side channels attacks. */ max_depth =FIB6_MAX_DEPTH +prandom_u32_max (FIB6_MAX_DEPTH );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2652/2857 platform/x86: gpd pocket fan: Cancel work before releasing GPIOs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 9962770049c715fc30a7b3274d8f245167c0a410 ]
The fan worker changes the direction of both GPIOs and schedules its next run. Its managed cancellation action is registered before the GPIOs are acquired, so devres releases the GPIOs before cancelling the work. A running worker can therefore change a GPIO after the driver has released it.
Register the work cancellation action after both GPIO acquisitions. This makes devres cancel and drain the worker before releasing either GPIO. No work has been queued yet if GPIO acquisition or action registration fails.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/platform/x86/gpd-pocket-fan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/platform/x86/gpd-pocket-fan.c +5 -4
@@ -153,10 +153,6 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)return -ENOMEM ; fan->dev = &pdev->dev; - ret =devm_delayed_work_autocancel (&pdev->dev, &fan->work, - gpd_pocket_fan_worker); -if (ret) -return ret;/* Note this returns a "weak" reference which we don't need to free */ fan->dts0 =thermal_zone_get_zone_by_name ("soc_dts0" );
@@ -175,6 +171,11 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)if (IS_ERR (fan->gpio1))return PTR_ERR (fan->gpio1); + ret =devm_delayed_work_autocancel (&pdev->dev, &fan->work, + gpd_pocket_fan_worker); +if (ret) +return ret; +gpd_pocket_fan_force_update (fan);platform_set_drvdata (pdev, fan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2653/2857 ipv6: Hold RCU when emitting route hardware flags notification
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 7c9cb1edaf8fd8e1af25e39741e603500986ef66 ]
fib6_info_hw_flags_set() is called by drivers from process context without RTNL or RCU. When the route uses a nexthop object, rt6_nlmsg_size() and rt6_fill_node() access the nexthop's RCU protected nexthop info and group pointers via rcu_dereference_rtnl(), resulting in suspicious RCU usage splats [1].
Fix by holding RCU while sizing and filling the notification, like fib_alias_hw_flags_set() already does. Switch to GFP_ATOMIC for the skb allocation accordingly.
Reproducer:
# echo "10 0" > /sys/bus/netdevsim/new_device # sysctl -wq net.ipv6.fib_notify_on_flag_change=1 # sysctl -wq net.ipv4.nexthop_compat_mode=1 # ip -6 nexthop add id 1 blackhole # ip -6 route add 2001:db8:1::1/128 nhid 1
[1]
WARNING: suspicious RCU usage 7.3.0-rc7-virtme-g191aa41548b2 #38 Not tainted net/ipv4/nexthop.c:1539 suspicious rcu_dereference_check() usage! [...]
Workqueue: events nsim_fib_event_work Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) lockdep_rcu_suspicious.cold (kernel/locking/lockdep.c:6972) nexthop_for_each_fib6_nh (net/ipv4/nexthop.c:1539 (discriminator 16)) rt6_nlmsg_size (net/ipv6/route.c:5728) fib6_info_hw_flags_set (net/ipv6/route.c:6503) nsim_fib6_rt_add (drivers/net/netdevsim/fib.c:671 drivers/net/netdevsim/fib.c:694) nsim_fib6_rt_insert (drivers/net/netdevsim/fib.c:759) nsim_fib_event_work (drivers/net/netdevsim/fib.c:856 drivers/net/netdevsim/fib.c:889 drivers/net/netdevsim/fib.c:1493) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) </TASK>
--- net/ipv6/route.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv6/route.c +6 -1
@@ -6333,7 +6333,9 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,if (!net->ipv6.sysctl.fib_notify_on_flag_change)return ; - skb =nlmsg_new (rt6_nlmsg_size (f6i),GFP_KERNEL ); +rcu_read_lock (); + + skb =nlmsg_new (rt6_nlmsg_size (f6i),GFP_ATOMIC );if (!skb) { err = -ENOBUFS ; goto errout;
@@ -6346,10 +6348,13 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i, goto errout; } +rcu_read_unlock (); +rtnl_notify (skb, net,0 ,RTNLGRP_IPV6_ROUTE ,NULL ,GFP_KERNEL );return ; errout: +rcu_read_unlock ();rtnl_set_sk_err (net,RTNLGRP_IPV6_ROUTE , err); }EXPORT_SYMBOL (fib6_info_hw_flags_set);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2654/2857 team: reject CAN, IEEE 802.15.4 and 6LoWPAN devices in team_port_add
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9043be310c6a4c5e57f7bba4b9870554eac7aa96 ]
When the first port has a non-Ethernet type, team_setup_by_port() copies port_dev->type to the team device while netdev_priv() of the team device still holds a struct team. Several L2 stacks identify their devices by dev->type alone and then access type specific data that the team driver never sets up:
- CAN protocols rely on the CAN mid-layer private data (ml_priv)
- IEEE 802.15.4 code dereferences ieee802154_ptr and the mlme ops in ml_priv
- the 6LoWPAN netdev notifier writes through lowpan_dev(dev) on NETDEV_DOWN and reads it on NETDEV_UP/NETDEV_CHANGE
Enslaving such a device (e.g. vxcan, wpan0, lowpan0) therefore leads to NULL pointer dereferences or to writes into struct team.
This is the same problem that syzbot reported for the bonding driver with a vxcan device enslaved to a bond master, which crashed in can_rx_unregister() and was fixed by commit 8ba68464e478 ("bonding:
refuse to enslave CAN devices"). The team driver has the same gap.
Reject ARPHRD_CAN, ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR and ARPHRD_6LOWPAN devices in team_port_add().
--- drivers/net/team/team.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/team/team.c +11 -0
@@ -1169,6 +1169,17 @@ static int team_port_add(struct team *team, struct net_device *port_dev,return -EINVAL ; } +if (port_dev->type ==ARPHRD_CAN || + port_dev->type ==ARPHRD_IEEE802154 || + port_dev->type ==ARPHRD_IEEE802154_MONITOR || + port_dev->type ==ARPHRD_6LOWPAN ) { +NL_SET_ERR_MSG (extack, +"CAN, IEEE 802.15.4 and 6LoWPAN devices can't be added as a team port" ); +netdev_err (dev,"Device %s is CAN, IEEE 802.15.4 or 6LoWPAN. These device types can't be added as a team port\n" , + portname); +return -EINVAL ; + } +if (netif_is_team_port (port_dev)) {NL_SET_ERR_MSG (extack,"Device is already a port of a team device" ); netdev_err(dev, "Device %s is already a port "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2655/2857 ibmveth: fix netpoll races with RX replenish
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 8d9ecac6b96e61d0e6d126c60644829fd9f66952 ]
ibmveth_poll_controller() runs RX replenish outside NAPI and without a lock, racing NAPI's replenish on another CPU. Both can fill the same slot, so an skb and its DMA mapping leak and PHYP can write into an unmapped buffer. netpoll calls it from netconsole and from netpoll-enabled bonds.
ibmveth_open() also enables NAPI before the RX resources exist. ibmveth_change_mtu(), veth_pool_store(), ibmveth_set_csum_offload() and ibmveth_set_tso() call close() and open() directly, so while open() is still setting up, netpoll and the direct ibmveth_interrupt() calls can replenish NULL pools and read freed memory.
Remove the callback, as Eric Dumazet did for many drivers after commit ac3d9dd034e5 ("netpoll: make ndo_poll_controller() optional"), including ibmvnic in commit 0c3b9d1b37df ("ibmvnic: remove ndo_poll_controller"). netpoll then polls NAPI itself with budget 0. napi->poll_owner serializes that with NAPI, but not with a NAPI poll that was already running when netpoll was set up, so skip RX replenish at budget 0, which netpoll uses for TX only. TX completes synchronously, so ibmveth_poll() has nothing else to do for netpoll.
Enable NAPI just before request_irq(), once everything ibmveth_poll() touches exists.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection of poll_one_napi() and the direct close()/open() callers; neither race was reproduced. Tested on a POWER10 LPAR with netconsole over ibmveth: a ping flood (678,470 packets, no loss) during a printk flood, and MTU changes and buffer pool toggles under traffic, with no warnings. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +13 -15
@@ -540,8 +540,6 @@ static int ibmveth_open(struct net_device *netdev)netdev_dbg (netdev,"open starting\n" ); -napi_enable (&adapter->napi); -for (i =0 ; i <IBMVETH_NUM_BUFF_POOLS ; i++) rxq_entries += adapter->rx_buff_pool[i].size;
@@ -629,10 +627,18 @@ static int ibmveth_open(struct net_device *netdev) } } +/* NAPI can run as soon as it is enabled, from netpoll during the +* direct close()/open() pairs or from a direct ibmveth_interrupt() +* call, so enable it only once everything ibmveth_poll() touches +* exists. +*/ +napi_enable (&adapter->napi); +netdev_dbg (netdev,"registering irq 0x%x\n" , netdev->irq); rc =request_irq (netdev->irq, ibmveth_interrupt,0 , netdev->name, netdev);if (rc !=0 ) { +napi_disable (&adapter->napi);netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -677,7 +683,6 @@ static int ibmveth_open(struct net_device *netdev) out_free_buffer_list:free_page ((unsigned long )adapter->buffer_list_addr); out: -napi_disable (&adapter->napi);return rc; }
@@ -1420,7 +1425,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) } } -ibmveth_replenish_task (adapter); +/* netpoll polls with budget 0 for TX only, and is not serialized +* with a NAPI poll that was already running when it was set up +*/ +if (budget) +ibmveth_replenish_task (adapter);if (frames_processed < budget) {napi_complete_done (napi, frames_processed);
@@ -1556,14 +1565,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)return -EINVAL ; } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void ibmveth_poll_controller (struct net_device *dev) -{ -ibmveth_replenish_task (netdev_priv (dev)); -ibmveth_interrupt (dev->irq, dev); -} -#endif -/** * ibmveth_get_desired_dma - Calculate IO memory desired by the driver *
@@ -1665,9 +1666,6 @@ static const struct net_device_ops ibmveth_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ibmveth_set_mac_addr, .ndo_features_check = ibmveth_features_check, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = ibmveth_poll_controller, -#endif };static int ibmveth_probe (struct vio_dev *dev,const struct vio_device_id *id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2656/2857 ibmveth: return the error when set_channels cannot add TX queues
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 16abfa871dc840e55f1726408c5994c66a9773e2 ]
When ibmveth_set_channels() cannot allocate a TX buffer for a new queue, it falls back to the old queue count, and the successful netif_set_real_num_tx_queues() call then overwrites rc. ethtool -L reports success while the queue count is unchanged.
Return the allocation error when the fallback succeeds.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection. Tested on a POWER10 LPAR with the TX buffer allocation forced to fail by a test-only module parameter (not part of this patch):
ethtool -L tx 8 now fails with -ENOMEM and the device keeps its four queues and passes traffic. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmveth.c +4 -1
@@ -1010,7 +1010,7 @@ static int ibmveth_set_channels(struct net_device *netdev,struct ibmveth_adapter *adapter =netdev_priv (netdev);unsigned int old = netdev->real_num_tx_queues, goal = channels->tx_count; -int rc, i; +int rc, i, alloc_rc =0 ;/* If ndo_open has not been called yet then don't allocate, just set * desired netdev_queue's and return
@@ -1035,6 +1035,7 @@ static int ibmveth_set_channels(struct net_device *netdev,/* if something goes wrong, free everything we just allocated */ netdev_err (netdev,"Failed to allocate more tx queues, returning to %d queues\n" , old); + alloc_rc = rc; goal = old; old = i;break ;
@@ -1045,6 +1046,8 @@ static int ibmveth_set_channels(struct net_device *netdev, old); goal = old; old = i; + }else if (alloc_rc) { + rc = alloc_rc; }/* Free any that are no longer needed */ for (i = old; i > goal; i--) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2657/2857 ibmveth: wait for in-flight transmits in ibmveth_close()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit c807573ea58e615339a9c72675c45c157ffe245c ]
ibmveth_close() frees the TX buffers after netif_tx_stop_all_queues(), which does not wait for an ibmveth_start_xmit() already running on another CPU. That transmit can copy into a freed buffer and hand PHYP a stale DMA address.
MTU, csum/TSO and buffer pool changes call ibmveth_close() directly while traffic flows. ifdown and the reset work go through dev_close(), which waits for running transmits only when the qdisc has an enqueue function, so with noqueue they race the same way.
Use netif_tx_disable(), which waits for running transmits.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection; the race was not reproduced. Tested on a POWER10 LPAR with MTU changes during a ping flood, with no warnings. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmveth.c +1 -1
@@ -697,7 +697,7 @@ static int ibmveth_close(struct net_device *netdev)napi_disable (&adapter->napi); -netif_tx_stop_all_queues (netdev); +netif_tx_disable (netdev);h_vio_signal (adapter->vdev->unit_address,VIO_IRQ_DISABLE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2658/2857 ibmveth: wait for the RX poll to return before freeing the RX queue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 3f872b34368c7c1d2a8900950e0fee4cb4dd9a34 ]
napi_disable() returns once ibmveth_poll() has called napi_complete_done(), but the poll is not finished: it then re-enables the interrupt and calls ibmveth_rxq_pending_buffer(), which reads the RX queue. ibmveth_close() can free that queue in the meantime, and the late enable can leave the interrupt unmasked after close() masked it. The request_irq() failure path in ibmveth_open() frees the same memory after napi_disable() too.
Call synchronize_net() after napi_disable() on both paths. Every caller of ibmveth_poll() runs it with bottom halves or interrupts disabled, so this waits for the poll to return.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection; also raised by the Sashiko review of the first version of this series. The race was not reproduced. Tested on a POWER10 LPAR under an incoming ping flood with 30 rapid link down/up cycles and 30 rapid MTU cycles (1500 <-> 9000); ran cleanly with no warnings or faults. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/ibm/ibmveth.c +6 -0
@@ -639,6 +639,7 @@ static int ibmveth_open(struct net_device *netdev) netdev);if (rc !=0 ) {napi_disable (&adapter->napi); +synchronize_net ();netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -696,6 +697,11 @@ static int ibmveth_close(struct net_device *netdev)netdev_dbg (netdev,"close starting\n" );napi_disable (&adapter->napi); +/* napi_disable() returns once ibmveth_poll() has called +* napi_complete_done(), but the poll still re-enables the +* interrupt and reads the RX queue after that. +*/ +synchronize_net ();netif_tx_disable (netdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2659/2857 ksmbd: fix link speed query in fsctl_query_iface_info_ioctl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit 2bc1d25fc8597fa6cbf6b1ff92653881939a6436 ]
fsctl_query_iface_info_ioctl() used to call netdev->ethtool_ops->get_link_ksettings() directly and never checked the return value. If the callback fails, cmd.base.speed may be left uninitialized. Also, SPEED_UNKNOWN (-1) is treated as a numeric link speed and would be converted into a bogus link speed.
Use __ethtool_get_link_ksettings() to acquire the per-netdev ops lock when needed. Fall back to 1Gbps when the query fails, or when the reported speed is 0 or SPEED_UNKNOWN.
--- fs/smb/server/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +3 -4
@@ -7730,6 +7730,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,struct sockaddr_storage_rsp *sockaddr_storage;unsigned int flags;unsigned long long speed; +struct ethtool_link_ksettings cmd;rtnl_lock ();for_each_netdev (&init_net, netdev) {
@@ -7764,10 +7765,8 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, nii_rsp->Next =cpu_to_le32 (152 ); nii_rsp->Reserved =0 ; -if (netdev->ethtool_ops->get_link_ksettings) { -struct ethtool_link_ksettings cmd; - - netdev->ethtool_ops->get_link_ksettings (netdev, &cmd); +if (!__ethtool_get_link_ksettings (netdev, &cmd) && + cmd.base.speed && cmd.base.speed !=SPEED_UNKNOWN ) { speed = cmd.base.speed; }else { ksmbd_debug(SMB, "%s %s\n", netdev->name,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2660/2857 ksmbd: fix unlocked IPv6 addr_list walk in fsctl_query_iface_info_ioctl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit a63bb4d91c784f63ad7c063717dff7920d8445be ]
fsctl_query_iface_info_ioctl() walks idev6->addr_list with a plain list_for_each_entry() while holding only rtnl_lock(). rtnl does not serialize all writers of this list: the DAD-failure path (addrconf_dad_failure -> ipv6_add_addr) can insert addresses without holding RTNL. It updates idev->addr_list with list_add_tail_rcu() under write_lock_bh(&idev->lock), so it can race with the unlocked walk.
addr_list is RCU managed, so walk it with list_for_each_entry_rcu() under rcu_read_lock(), matching the other lockless readers of the list.
--- fs/smb/server/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +3 -1
@@ -7808,13 +7808,15 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,if (!idev6)continue ; -list_for_each_entry (ifa, &idev6->addr_list, if_list) { +rcu_read_lock (); +list_for_each_entry_rcu (ifa, &idev6->addr_list, if_list) {if (ifa->flags & (IFA_F_TENTATIVE |IFA_F_DEPRECATED ))continue ;memcpy (ipv6_addr, ifa->addr.s6_addr,16 );break ; } +rcu_read_unlock (); sockaddr_storage->addr6.ScopeId =0 ; nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2661/2857 ksmbd: fix invalid Next offset in interface info replies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit 2c50a4a5e75db55880eca43c035649cb51fcb52a ]
fsctl_query_iface_info_ioctl() assigns nii_rsp to the next output slot before checking whether the interface has an in_device or inet6_dev. If either lookup returns NULL, the loop continues without advancing nbytes, leaving nii_rsp pointing at an uncommitted slot. If no later entry is committed, clearing nii_rsp->Next updates that slot instead of the last returned entry, leaving the latter with a nonzero Next offset.
Fix this by using nbytes to locate the last committed entry and clear its Next field, but only when the response contains at least one entry.
--- fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +8 -2
@@ -7823,9 +7823,15 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, }rtnl_unlock (); -/* zero if this is last one */ -if (nii_rsp) +/* +* nii_rsp may point to an entry not included in nbytes if the IPv4 +* or IPv6 device lookup failed. Clear Next in the last returned entry. +*/ +if (nbytes >0 ) { + nii_rsp = (struct network_interface_info_ioctl_rsp *) + &rsp->Buffer[nbytes -sizeof (*nii_rsp)]; nii_rsp->Next =0 ; + } rsp->PersistentFileId =SMB2_NO_FID ; rsp->VolatileFileId =SMB2_NO_FID ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2662/2857 ksmbd: Correct typos in multiple comments across various files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shen Lichuan <[email protected]>
[ Upstream commit 9e676e571d39eb6189bf6d55a9c401ba2dd13410 ]
Fixed some confusing typos that were currently identified witch codespell, the details are as follows:
-in the code comments:fs/smb/common/smb2pdu.h:9: specfication ==> specification fs/smb/common/smb2pdu.h:494: usally ==> usually fs/smb/common/smb2pdu.h:1064: Attrubutes ==> Attributes fs/smb/server/connection.c:28: cleand ==> cleaned fs/smb/server/ksmbd_netlink.h:216: struture ==> structure fs/smb/server/oplock.c:799: conains ==> contains fs/smb/server/oplock.c:1487: containted ==> contained fs/smb/server/server.c:282: proccessing ==> processing fs/smb/server/smb_common.c:491: comforms ==> conforms fs/smb/server/xattr.h:102: ATTRIBUITE ==> ATTRIBUTE
Stable-dep-of: e8486c5cfbdd ("smb/server: fix trailing period in generated short names")
--- fs/smb/common/smb2pdu.h | 6 +++--- fs/smb/server/connection.c | 2 +- fs/smb/server/ksmbd_netlink.h | 2 +- fs/smb/server/oplock.c | 4 ++-- fs/smb/server/server.c | 2 +- fs/smb/server/smb_common.c | 2 +- fs/smb/server/xattr.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-)
fs/smb/common/smb2pdu.h +3 -3
@@ -6,7 +6,7 @@* Note that, due to trying to use names similar to the protocol specifications, * there are many mixed case field names in the structures below. Although * this does not match typical Linux kernel style, it is necessary to be -* able to match against the protocol specfication. +* able to match against the protocol specification. * * SMB2 commands * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
@@ -480,7 +480,7 @@ struct smb2_encryption_neg_context {__le16 ContextType;/* 2 */ __le16 DataLength;__le32 Reserved; -/* CipherCount usally 2, but can be 3 when AES256-GCM enabled */ +/* CipherCount usually 2, but can be 3 when AES256-GCM enabled */ __le16 CipherCount;/* AES128-GCM and AES128-CCM by default */ __le16 Ciphers[]; } __packed;
@@ -1036,7 +1036,7 @@ struct smb2_change_notify_rsp {#define IL_IMPERSONATION cpu_to_le32(0x00000002)#define IL_DELEGATE cpu_to_le32(0x00000003) -/* File Attrubutes */ +/* File Attributes */ #define FILE_ATTRIBUTE_READONLY 0x00000001#define FILE_ATTRIBUTE_HIDDEN 0x00000002#define FILE_ATTRIBUTE_SYSTEM 0x00000004
fs/smb/server/connection.c +1 -1
@@ -63,7 +63,7 @@ void ksmbd_conn_put(struct ksmbd_conn *conn)/** * ksmbd_conn_free() - free resources of the connection instance * -* @conn: connection instance to be cleand up +* @conn: connection instance to be cleaned up * * During the thread termination, the corresponding conn instance * resources(sock/memory) are released and finally the conn object is freed.
fs/smb/server/ksmbd_netlink.h +1 -1
@@ -214,7 +214,7 @@ struct ksmbd_tree_connect_response { };/* -* IPC Request struture to disconnect tree connection. +* IPC Request structure to disconnect tree connection. */ struct ksmbd_tree_disconnect_request {__u64 session_id;/* session id */
fs/smb/server/oplock.c +2 -2
@@ -869,7 +869,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)/** * smb2_lease_break_noti() - break lease when a new client request * write lease -* @opinfo: conains lease state information +* @opinfo: contains lease state information * * Return: 0 on success, otherwise error */
@@ -1577,7 +1577,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease) }/** -* parse_lease_state() - parse lease context containted in file open request +* parse_lease_state() - parse lease context contained in file open request * @open_req: buffer containing smb2 file open(create) request * @is_dir: whether leasing file is directory *
fs/smb/server/server.c +1 -1
@@ -312,7 +312,7 @@ static void handle_ksmbd_work(struct work_struct *wk)/** * queue_ksmbd_work() - queue a smb request to worker thread queue -* for proccessing smb command and sending response +* for processing smb command and sending response * @conn: connection instance * * read remaining data from socket create and submit work.
fs/smb/server/smb_common.c +1 -1
@@ -491,7 +491,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,* @shortname: destination short filename * * Return: shortname length or 0 when source long name is '.' or '..' -* TODO: Though this function comforms the restriction of 8.3 Filename spec, +* TODO: Though this function conforms the restriction of 8.3 Filename spec, * but the result is different with Windows 7's one. need to check. */ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,
fs/smb/server/xattr.h +1 -1
@@ -99,7 +99,7 @@ struct xattr_ntacl {__u8 posix_acl_hash[XATTR_SD_HASH_SIZE ];/* 64bytes hash for posix acl */ }; -/* DOS ATTRIBUITE XATTR PREFIX */ +/* DOS ATTRIBUTE XATTR PREFIX */ #define DOS_ATTRIBUTE_PREFIX "DOSATTRIB"#define DOS_ATTRIBUTE_PREFIX_LEN (sizeof(DOS_ATTRIBUTE_PREFIX) - 1)#define XATTR_NAME_DOS_ATTRIBUTE (XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2663/2857 smb/server: fix trailing period in generated short names
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit e8486c5cfbdd07811afa4196060bafbf78ccdae2 ]
Reproducer:
1. touch /mnt/file
2. smbinfo filealternatenameinfo /mnt/file
Alternate Name: FILE~9!.
See MS-FSCC 2.1.5.2.1. The base filename MUST be 1-8 characters in length and MUST NOT contain a "." period character.
--- fs/smb/server/smb_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/smb/server/smb_common.c +1 -3
@@ -491,8 +491,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,* @shortname: destination short filename * * Return: shortname length or 0 when source long name is '.' or '..' -* TODO: Though this function conforms the restriction of 8.3 Filename spec, -* but the result is different with Windows 7's one. need to check. */ int ksmbd_extract_shortname (struct ksmbd_conn *conn,const char *longname,char *shortname)
@@ -556,7 +554,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,if (dot_present)memcpy (out + baselen +4 , extension,4 );else - out[baselen +4 ] ='\0' ; + out[baselen +3 ] ='\0' ;smbConvertToUTF16 ((__le16 *)shortname, out,PATH_MAX , conn->local_nls,0 ); len =strlen (out) *2 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2664/2857 ksmbd: reject foreign RPC pipe handles on IPC$ read and write
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohammed Alquraini <[email protected]>
[ Upstream commit da25995071e5e0f3aa9a41160b00b2f833127b3e ]
RPC pipe handles on IPC$ are allocated from a single server-global IDA, and ksmbd.mountd looks a pipe up by handle alone, with no session information. smb2_read_pipe() and smb2_write_pipe() take the handle straight from the client request (VolatileFileId) and pass it to the daemon without checking that the requesting session opened it. An authenticated user can therefore issue an SMB2 READ or WRITE on IPC$ with another session's handle and receive that session's in-flight DCERPC response, or write attacker-chosen bytes into its pipe stream. A tree connect to IPC$, which every RPC client already has, is the only requirement.
Validate ownership before the transfer, the way the sibling pipe paths already do: under sess->rpc_lock, ksmbd_session_rpc_method() returns 0 for a handle the session did not open. smb2_get_info_file_pipe() and the FSCTL_PIPE_TRANSCEIVE ioctl already reject such handles; read and write were the remaining gap. Reject them with STATUS_FILE_CLOSED, as the ioctl path does.
--- fs/smb/server/smb2pdu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
fs/smb/server/smb2pdu.c +20 -0
@@ -6463,6 +6463,16 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) id = req->VolatileFileId; +lockdep_assert_not_held (&work->sess->rpc_lock); +down_read (&work->sess->rpc_lock); +if (!ksmbd_session_rpc_method (work->sess, id)) { +up_read (&work->sess->rpc_lock); + rsp->hdr.Status =STATUS_FILE_CLOSED ; +smb2_set_err_rsp (work); +return -ENOENT ; + } +up_read (&work->sess->rpc_lock); + rpc_resp =ksmbd_rpc_read (work->sess, id);if (rpc_resp) {void *aux_payload_buf;
@@ -6773,6 +6783,16 @@ static noinline int smb2_write_pipe(struct ksmbd_work *work) goto out; } +lockdep_assert_not_held (&work->sess->rpc_lock); +down_read (&work->sess->rpc_lock); +if (!ksmbd_session_rpc_method (work->sess, id)) { +up_read (&work->sess->rpc_lock); + rsp->hdr.Status =STATUS_FILE_CLOSED ; +smb2_set_err_rsp (work); +return -ENOENT ; + } +up_read (&work->sess->rpc_lock); + data_buf = (char *)(((char *)&req->hdr.ProtocolId) + data_offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2665/2857 ksmbd: reject FILE_ATTRIBUTE_TEMPORARY on directories
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Andreas Michalopoulos <[email protected]>
[ Upstream commit 8323aab48525b83f750e712f66e6e9387b550cf4 ]
Setting FILE_ATTRIBUTE_TEMPORARY on a directory with SMB2 SET_INFO (FileBasicInformation) succeeds: ksmbd keeps the attribute and, with "store dos attributes" enabled, also writes it to the DOS attribute xattr.
MS-FSA (FileBasicInformation) says the request must fail with STATUS_INVALID_PARAMETER when FILE_ATTRIBUTE_TEMPORARY is set on a directory, and Samba rejects it too. smbtorture's smb2.create.dosattr_tmp_dir checks this and fails against ksmbd.
Return -EINVAL, which is sent as STATUS_INVALID_PARAMETER, when a directory is asked to become TEMPORARY. Do the check before any timestamp is changed, so a rejected request leaves the open file and the inode unchanged.
--- fs/smb/server/smb2pdu.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/smb/server/smb2pdu.c +5 -0
@@ -5967,6 +5967,11 @@ static int set_file_basic_info(struct ksmbd_file *fp, inode =file_inode (filp); user_ns =file_mnt_user_ns (filp); +/* MS-FSA FileBasicInformation: a directory can't be marked TEMPORARY */ +if (S_ISDIR (inode->i_mode) && + (file_info->Attributes &FILE_ATTRIBUTE_TEMPORARY_LE )) +return -EINVAL ; +if (file_info->CreationTime) fp->create_time =le64_to_cpu (file_info->CreationTime);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2666/2857 net: skbuff: move alloc_cpu into a potential hole
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 4398f3f6d1380d9f71a484e1e5d869ba0eaf23d5 ]
alloc_cpu is currently between 4 byte fields, so it's almost guaranteed to create a 2B hole. It has a knock on effect of creating a 4B hole after @end (and @end and @tail being in different cachelines).
None of this matters hugely, but for kernel configs which don't enable all the features there may well be a 2B hole after the bitfield. Move alloc_cpu there.
Stable-dep-of: 78d4bd22ec9d ("net: skbuff: don't copy alloc_cpu in skb header copies")
--- include/linux/skbuff.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/skbuff.h +2 -1
@@ -993,6 +993,8 @@ struct sk_buff {__u16 tc_index;/* traffic control index */ #endif +u16 alloc_cpu; + union { __wsum csum; struct {
@@ -1011,7 +1013,6 @@ struct sk_buff { unsigned int sender_cpu; };#endif -u16 alloc_cpu;#ifdef CONFIG_NETWORK_SECMARK __u32 secmark;#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2667/2857 net: skbuff: dont copy alloc_cpu in skb header copies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 78d4bd22ec9df490135303c00e190ac43d5c334a ]
Commit 68822bdf76f1 ("net: generalize skb freeing deferral to per-cpu lists") added alloc_cpu to struct sk_buff and placed it in the headers group copied by __copy_skb_header().
This is wrong for newly allocated skbs. For example, skb_segment() allocates a new skb and records the current CPU in alloc_cpu, but __copy_skb_header() overwrites it with the value from the original skb.
If the original skb was allocated on another CPU, the segment may later be treated as remotely allocated and unnecessarily deferred there when it is freed.
Move alloc_cpu out of the headers group so it is preserved across header copies. Copy it explicitly in skb_clone(), which allocates the skb object directly instead of going through __alloc_skb().
This was discovered while investigating a throughput regression with software IPsec. The load used 512 IPsec tunnels carrying traffic over VXLAN, with 512 parallel iperf3 flows and an MTU of 4500.
Before the fix:
16.09% queued_spin_lock_slowpath
|
--15.90%--_raw_spin_lock_irqsave
|
--9.37%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cqAfter the fix:
6.84% queued_spin_lock_slowpath
|
--6.57%--_raw_spin_lock_irqsave
|
--5.00%--__slab_free
kfree
skb_release_data
napi_consume_skb
mlx5e_poll_tx_cq--- include/linux/skbuff.h | 4 ++-- net/core/skbuff.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/skbuff.h +2 -2
@@ -993,8 +993,6 @@ struct sk_buff {__u16 tc_index;/* traffic control index */ #endif -u16 alloc_cpu; - union { __wsum csum; struct {
@@ -1042,6 +1040,8 @@ struct sk_buff { ); /* end headers group */ +u16 alloc_cpu; +/* These elements must be at the end, see alloc_skb() for details. */ sk_buff_data_t tail;sk_buff_data_t end;
net/core/skbuff.c +1 -1
@@ -1160,7 +1160,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)#ifdef CONFIG_NET_RX_BUSY_POLL CHECK_SKB_FIELD (napi_id);#endif -CHECK_SKB_FIELD (alloc_cpu);#ifdef CONFIG_XPS CHECK_SKB_FIELD (sender_cpu);#endif
@@ -1192,6 +1191,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)C (pfmemalloc);C (pp_recycle); n->destructor =NULL ; +C (alloc_cpu);C (tail);C (end);C (head);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2668/2857 ocfs2: reserve xattr value tree metadata only once
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 5365f1f417b36627f825aacf9844ae24b671b525 ]
ocfs2_calc_xattr_set_need() asks for the new value's extent tree twice when it replaces an inline value smaller than a value root with one large enough to be stored outside. The "stored outside" branch reserves the tree and then falls through to meta_guess instead of going out:
if (!ocfs2_xattr_is_local(xe)) {
...
xv = (struct ocfs2_xattr_value_root *)
(base + name_offset + name_len);
value_size = OCFS2_XATTR_ROOT_SIZE;
} else
xv = &def_xv.xv;
if (old_clusters >= new_clusters) {
...
goto out;
} else {
meta_add += ocfs2_extend_meta_needed(&xv->xr_list);
...
if (value_size >= OCFS2_XATTR_ROOT_SIZE)
goto out;
}On the fall-through xv is def_xv, so what gets added here is the two blocks ocfs2_extend_meta_needed() wants for an empty value root -- and both sides of meta_guess reserve that same tree again. The create side has done so since commit 3ed2be719eb9 ("ocfs2: allow for more than one data extent when creating xattr"), which ported this reservation to the create case without noticing it was already on the way in, and the existing-block side since commit 0cdc7dde00ec ("ocfs2: fix missing metadata reservation for large xattrs"). Both were chasing the same RESTART_META failure in ocfs2_xattr_extend_allocation(), for xattr create and then for xattr update.
ocfs2_init_xattr_set_ctxt() hands the total straight to ocfs2_reserve_new_metadata_blocks(), so the surplus is two blocks held for the whole transaction. A setxattr that would otherwise fit can come back -ENOSPC on a filesystem whose metadata allocator is nearly exhausted.
Move the reservation into the branch that stops there, leaving meta_guess as the only place that reserves for a value tree the fall through is about to create. The paths that do go out keep reserving against the value root they already have, which for an external old value is the on-disk one and so can legitimately ask for more than two blocks.
Both sides of meta_guess have to come out even on their own now that the copy covering for them is gone. The existing-block side only started reserving the value tree in the commit this one is tagged against. The create side has reserved the tree since 3ed2be719eb9, but only the tree:
the block ocfs2_create_xattr_block() claims came out of the same two, and on the fall-through it was the duplicate removed here that made up the difference. So "ocfs2: reserve metadata for a new xattr block and its value tree" has to land first -- without it the create side reserves 2 where 3 are needed and the value tree is back to RESTART_META. That one fixes a shortfall of its own on the path that reaches meta_guess directly, where there was never a duplicate to cover it, so it is worth taking alone; this patch is not.
--- fs/ocfs2/xattr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/ocfs2/xattr.c +15 -2
@@ -3203,12 +3203,21 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, credits +=ocfs2_remove_extent_credits (inode->i_sb); goto out; }else { - meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); clusters_add += new_clusters - old_clusters; credits +=ocfs2_calc_extend_credits (inode->i_sb, &xv->xr_list); -if (value_size >=OCFS2_XATTR_ROOT_SIZE ) +/* +* The old value occupies at least as much room as a +* value root, whether it sat outside or inline, so the +* new root fits where it was and no new xattr block or +* bucket is needed -- only the metadata to extend the +* tree hanging off it. A smaller one is replaced +* outright, which meta_guess below reserves for. +*/ +if (value_size >=OCFS2_XATTR_ROOT_SIZE ) { + meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); goto out; + } } }else {/*
@@ -3260,6 +3269,10 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,* Reserve metadata for the new xattr's value extent tree. * The not_found path above adds credits for this tree but * omits meta_add, leaving meta_ac NULL for large values. +* +* This is all of meta_ac on this side beyond the xattr tree +* above: no xattr block is allocated here, and a new bucket or +* index block is paid for out of data_ac. */ if (xi->xi_value_len >OCFS2_XATTR_INLINE_SIZE ) meta_add +=ocfs2_extend_meta_needed (&def_xv.xv.xr_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2669/2857 ocfs2: initialize status waiters before publishing them
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit f6bfa6c458288d72948af95391b205f3eb775721 ]
o2net_prep_nsw() publishes its stack waiter in nn_status_idr and nn_status_list under nn_lock, then initializes the wait queue and completion status after releasing the lock. A concurrent disconnect can find that waiter through o2net_complete_nodes_nsw() and call wake_up() before the wait queue has a valid lock and list head. The sender can also overwrite a completion status with its initial value.
Initialize the wait queue and status before publishing the waiter. nn_lock then orders publication against completion, and no reader can observe a partially initialized object. Leave the IDR allocation and its failure handling unchanged.
A controlled case-modified test kernel used a synthetic connection to enter the real send path and overlap publication with disconnect. The candidate completion and wake-up code were unchanged. Its Oops includes:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:__wake_up_common+0xa0/0x1f0 Call Trace: <TASK> __wake_up+0x36/0x60 o2net_complete_nsw_locked+0x222/0x370 o2net_set_nn_state+0x917/0xea0 o2net_disconnect_node+0xd0/0x190 o2net_validate_control_write+0x454/0x500 full_proxy_write+0x11f/0x180 vfs_write+0x25a/0x1010 ksys_write+0x111/0x200 do_syscall_64+0x114/0x620 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Modules linked in:
--- fs/ocfs2/cluster/tcp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/cluster/tcp.c +5 -3
@@ -300,6 +300,11 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) {int ret; +/* Initialize all completion-visible state before publishing the waiter. */ +init_waitqueue_head (&nsw->ns_wq); + nsw->ns_sys_status =O2NET_ERR_NONE ; + nsw->ns_status =0 ; +spin_lock (&nn->nn_lock); ret =idr_alloc (&nn->nn_status_idr, nsw,0 ,0 ,GFP_ATOMIC );if (ret >=0 ) {
@@ -310,9 +315,6 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)if (ret <0 )return ret; -init_waitqueue_head (&nsw->ns_wq); - nsw->ns_sys_status =O2NET_ERR_NONE ; - nsw->ns_status =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2670/2857 platform/x86: ibm_rtl: Fix potential OOB read at signature search
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f1d81af2521ad504a20481fef12c358d26e6c3a6 ]
The loop for signature search fetches 22 bytes of struct ibm_rtl_table at each check, while the loop count is calculated in 4 bytes unit, which means that, at the last entry, it fetches over the limit.
Rewrite the loop to use the byte offset and correct the boundary condition check for avoiding the potential OOB access.
--- drivers/platform/x86/ibm_rtl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/ibm_rtl.c +4 -4
@@ -223,9 +223,9 @@ static const struct dmi_system_id ibm_rtl_dmi_table[] __initconst = { };static int __init ibm_rtl_init (void ) { -unsigned long ebda_addr, ebda_size; +unsigned long ebda_addr, ebda_size, offset;unsigned int ebda_kb; -int ret = -ENODEV , i; +int ret = -ENODEV ;if (force)pr_warn ("module loaded by force\n" );
@@ -260,9 +260,9 @@ static int __init ibm_rtl_init(void) {return -ENOMEM ;/* search for the _RTL_ signature at the start of the table */ -for (i =0 ; i < ebda_size/sizeof (unsigned int ); i++) { +for (offset =0 ; offset +sizeof (*rtl_table) <= ebda_size; offset +=4 ) {struct ibm_rtl_table __iomem * tmp; - tmp = (struct ibm_rtl_table __iomem *) (ebda_map + i*sizeof (unsigned int )); + tmp = (struct ibm_rtl_table __iomem *) (ebda_map + offset);if ((readq (&tmp->signature) &RTL_MASK ) ==RTL_SIGNATURE ) {phys_addr_t addr;unsigned int plen;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2671/2857 gtp: set a valid genl command in PDP context get and dump replies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit 758d8928d2c5d6703da827577cef86d643155236 ]
gtp_genl_fill_info() stamps the reply with the command its callers pass in. gtp_genl_get_pdp() and gtp_genl_dump_pdp() pass nlmsg_type, which in a genl message is the dynamically assigned family id rather than a GTP_CMD_* value, so replies to a PDP context get or dump carry a meaningless command number.
libgtpnl ignores the command and is unaffected, but parsers that check it (for example the ynl tooling) treat the reply as an unknown command and discard it. Pass GTP_CMD_GETPDP, as gtp_tunnel_notify() already passes a real command on the notification path. No uapi change.
--- drivers/net/gtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/gtp.c +2 -2
@@ -1684,7 +1684,7 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info) } err =gtp_genl_fill_info (skb2,NETLINK_CB (skb).portid, info->snd_seq, -0 , info->nlhdr->nlmsg_type, pctx); +0 ,GTP_CMD_GETPDP , pctx);if (err <0 ) goto err_unlock_free;
@@ -1731,7 +1731,7 @@ static int gtp_genl_dump_pdp(struct sk_buff *skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, - cb->nlh->nlmsg_type, pctx)) { + GTP_CMD_GETPDP, pctx)) { cb->args[0 ] = i; cb->args[1 ] = j; cb->args[2 ] = (unsigned long )gtp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2672/2857 gtp: hold RCU for the device lookup when adding a PDP context
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit fe3e1a42fb7eb18d8c55d714b50a3d51f8cd6ffe ]
gtp_genl_new_pdp() calls gtp_find_dev(), which looks the device up with dev_get_by_index_rcu(). Since commit e2d1baca2b33 ("gtp: remove useless rcu_read_lock()"), this only runs under the rtnl lock, and kernels with CONFIG_PROVE_RCU_LIST warn:
WARNING: suspicious RCU usage
net/core/dev.c:1047 RCU-list traversed in non-reader section!!
...
dev_get_by_index_rcu
gtp_find_dev
gtp_genl_new_pdp
Hold the RCU read lock around the lookup only: gtp_pdp_add() allocates with GFP_KERNEL, and the rtnl lock keeps the device alive afterwards.
Found with the gtp selftest on a debug kernel.
--- drivers/net/gtp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/gtp.c +3 -0
@@ -1496,7 +1496,10 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)rtnl_lock (); +/* the rtnl lock keeps the device alive once found */ +rcu_read_lock (); gtp =gtp_find_dev (sock_net (skb->sk), info->attrs); +rcu_read_unlock ();if (!gtp) { err = -ENODEV ; goto out_unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2673/2857 ASoC: wm8994: fix MCLK gating for AIF clocks sourced from MCLK2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 872215109fc880de7a03fa30437346f9212649e8 ]
aif_mclk_set() masks the AIFnCLK_SRC field of the AIFn clocking register, but compares the result with unshifted field values. The MCLK2 source (0x08) therefore never matches, so MCLK2 is never enabled for an AIF clocked from it, and the AIF relies on other users of that clock to keep it running.
On the Exynos4412 Trats2 board, AIF1 and SYSCLK run from MCLK2, the 32768Hz PMIC clock, while the codec is idle. That clock is shared with the WLAN and Bluetooth chips, which enable it only once their drivers are loaded. Until then the codec runs from a stopped clock: FLL1 fails to lock when configured from that state, and the codec floods the kernel log with FIFO error interrupts once a digital path is powered up:
wm8994-codec wm8994-codec: Timed out waiting for FLL lock wm8994-codec wm8994-codec: FIFO error
Booting with clk_ignore_unused, which keeps that clock running from the bootloader, makes both issues disappear.
Fixing just the comparison is not enough. The AIF clock source can be changed while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. Looking up the clock again on disable can then release a different MCLK than the one enabled, leaking the enable count of one clock and underflowing the other.
Shift the field value before decoding it, and remember which MCLK has been enabled for each AIF, so that the same clock is released on disable. While at it, report the MCLK number 1-based in the error message.
--- sound/soc/codecs/wm8994.c | 28 ++++++++++++++++++---------- sound/soc/codecs/wm8994.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
sound/soc/codecs/wm8994.c +18 -10
@@ -1062,13 +1062,24 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablunsigned int offset, val, clk_idx;int ret; +/* +* The AIF clock source may be changed while the AIF clock is +* running, so release the MCLK which has been enabled for it +* instead of the one currently selected. +*/ +if (!enable) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] =NULL ; +return 0 ; + } +if (aif) offset =4 ;else offset =0 ; val =snd_soc_component_read (component,WM8994_AIF1_CLOCKING_1 + offset); - val &=WM8994_AIF1CLK_SRC_MASK ; + val = (val &WM8994_AIF1CLK_SRC_MASK ) >>WM8994_AIF1CLK_SRC_SHIFT ;switch (val) {case 0 :
@@ -1081,16 +1092,13 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn 0 ; } -if (enable) { - ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); -if (ret <0 ) { -dev_err (component->dev,"Failed to enable MCLK%d\n" , - clk_idx); -return ret; - } - }else { -clk_disable_unprepare (wm8994->mclk[clk_idx].clk); + ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); +if (ret <0 ) { +dev_err (component->dev,"Failed to enable MCLK%d\n" , + clk_idx +1 ); +return ret; } + wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -81,6 +81,7 @@ struct wm8994_priv {struct wm_hubs_data hubs;struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ]; +struct clk *aif_mclk[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2674/2857 ASoC: wm8994: dont lose the AIF clock ratio when staying at 32kHz SYSCLK
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 693574504051a19383640cfb99524a6b69e4624f ]
When SYSCLK drops below 50kHz, the AIFnCLK rate ratio is saved and temporarily lowered to 128fs for accessory detection, then restored once SYSCLK gets fast enough again. The ratio is however saved again on each clock reconfiguration done while SYSCLK is still slow, which overwrites the original ratio with the 128fs one.
This happens on the Exynos4412 Trats2 board, which set MCLK2 as SYSCLK twice during the card probe and then configure FLL1 while still running from MCLK2. Once SYSCLK is switched to FLL1, the 128fs ratio is "restored", so AIF1 is left configured for 48kHz at 128fs while being clocked at 256fs. If any digital path is powered up before a stream reconfigures the AIF, the codec raises FIFO error interrupts every 10ms, flooding the kernel log:
wm8994-codec wm8994-codec: FIFO error
Save the original ratio only when entering the low SYSCLK mode. While at it, move the code duplicated in _wm8994_set_fll() and wm8994_set_dai_sysclk() to a common helper.
--- sound/soc/codecs/wm8994.c | 94 +++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 54 deletions(-)
sound/soc/codecs/wm8994.c +40 -54
@@ -2210,6 +2210,44 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll,return 0 ; } +/* +* If SYSCLK is less than 50kHz adjust AIFnCLK dividers for detection, +* restoring the original ones once SYSCLK is fast enough again. +*/ +static void wm8994_update_aif_clk_rate (struct snd_soc_component *component) +{ +struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); + +if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { +/* Don't overwrite the saved dividers with the 128fs ones */ +if (!wm8994->aifdiv[0 ]) { +dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); + + wm8994->aifdiv[0 ] =snd_soc_component_read (component, +WM8994_AIF1_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + wm8994->aifdiv[1 ] =snd_soc_component_read (component, +WM8994_AIF2_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + } + +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK ,0x1 ); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK ,0x1 ); + }else if (wm8994->aifdiv[0 ]) { +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK , + wm8994->aifdiv[0 ]); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK , + wm8994->aifdiv[1 ]); + + wm8994->aifdiv[0 ] =0 ; + wm8994->aifdiv[1 ] =0 ; + } +} +static int _wm8994_set_fll (struct snd_soc_component *component,int id,int src,unsigned int freq_in,unsigned int freq_out) {
@@ -2444,33 +2482,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
@@ -2588,33 +2600,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2675/2857 ASoC: wm8994: fix MCLK index used for setting MCLK rate
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 7916b55b100973b5fb5b974e8f7c8ae9f3ac1d2e ]
wm8994_set_dai_sysclk() passes the AIF index (dai->id - 1) to wm8994_set_mclk_rate(), which uses it to index the MCLK clocks and their cached rates. As a result, selecting MCLK2 as the AIF1 clock source sets and reads back the rate of MCLK1 instead, and the rate of MCLK1 is then stored as the MCLK2 rate.
On the Exynos4412 Trats2 board, where MCLK1 is a fixed 24MHz clock and MCLK2 a 32768Hz clock used when the codec is idle, this gives:
wm8994-codec wm8994-codec: AIF1 using MCLK2 at 24000000Hz
so the driver assumes a 12MHz SYSCLK while it actually runs at 32kHz. This skips the 128fs AIF clock ratio setup for low SYSCLK rates and makes the mic detection rate configuration use the wrong clock rate.
Pass the MCLK index matching the selected clock source instead.
--- sound/soc/codecs/wm8994.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm8994.c +2 -2
@@ -2542,7 +2542,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,case WM8994_SYSCLK_MCLK1 : wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK1 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK1 , &freq);if (ret <0 )return ret;
@@ -2555,7 +2555,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,/* TODO: Set GPIO AF */ wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK2 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK2 , &freq);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2676/2857 ASoC: soc-utils.c: add asoc_dummy_dlc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit d2a4e0d7409705a0b6010ee537c5114eac31bd13 ]
ASoC uses dummy Component, sharing snd_soc_dai_link_component for it is better idea. This patch adds it.
Stable-dep-of: d9c23ac1217a ("ASoC: samsung: midas_wm1811: run FLL1 at the AIF1 configured rate when idle")
--- include/sound/soc.h | 1 + sound/soc/soc-utils.c | 7 +++++++ 2 files changed, 8 insertions(+)
include/sound/soc.h +1 -0
@@ -875,6 +875,7 @@ asoc_link_to_platform(struct snd_soc_dai_link *link, int n) {#define COMP_DUMMY () { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", }extern struct snd_soc_dai_link_component null_dailink_component[0 ]; +extern struct snd_soc_dai_link_component asoc_dummy_dlc;struct snd_soc_codec_conf {
sound/soc/soc-utils.c +7 -0
@@ -225,6 +225,13 @@ int snd_soc_component_is_dummy(struct snd_soc_component *component) (component->driver == &dummy_codec)); } +struct snd_soc_dai_link_component asoc_dummy_dlc = { + .of_node =NULL , + .dai_name ="snd-soc-dummy-dai" , + .name ="snd-soc-dummy" , +}; +EXPORT_SYMBOL_GPL (asoc_dummy_dlc); +static int snd_soc_dummy_probe (struct platform_device *pdev) {int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2677/2857 ASoC: soc.h: convert asoc_xxx() to snd_soc_xxx()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 1d5a2b5dd0a8d2b2b535b5266699429dbd48e62f ]
ASoC is using 2 type of prefix (asoc_xxx() vs snd_soc_xxx()), but there is no particular reason about that [1].
To reduce confusing, standarding these to snd_soc_xxx() is sensible.
This patch adds asoc_xxx() macro to keep compatible for a while. It will be removed if all drivers were switched to new style.
Stable-dep-of: d9c23ac1217a ("ASoC: samsung: midas_wm1811: run FLL1 at the AIF1 configured rate when idle")
--- include/sound/soc-card.h | 4 ++-- include/sound/soc.h | 42 ++++++++++++++++++++++++++-------------- sound/soc/soc-utils.c | 4 ++-- 3 files changed, 32 insertions(+), 18 deletions(-)
include/sound/soc-card.h +2 -2
@@ -100,8 +100,8 @@ struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,struct snd_soc_pcm_runtime *rtd;for_each_card_rtds (card, rtd) { -if (!strcmp (asoc_rtd_to_codec (rtd,0 )->name, dai_name)) -return asoc_rtd_to_codec (rtd,0 ); +if (!strcmp (snd_soc_rtd_to_codec (rtd,0 )->name, dai_name)) +return snd_soc_rtd_to_codec (rtd,0 ); }return NULL ;
include/sound/soc.h +28 -14
102 lines not on this page · raw message
sound/soc/soc-utils.c +2 -2
@@ -225,12 +225,12 @@ int snd_soc_component_is_dummy(struct snd_soc_component *component) (component->driver == &dummy_codec)); } -struct snd_soc_dai_link_component asoc_dummy_dlc = { +struct snd_soc_dai_link_component snd_soc_dummy_dlc = { .of_node =NULL , .dai_name ="snd-soc-dummy-dai" , .name ="snd-soc-dummy" , }; -EXPORT_SYMBOL_GPL (asoc_dummy_dlc); +EXPORT_SYMBOL_GPL (snd_soc_dummy_dlc);static int snd_soc_dummy_probe (struct platform_device *pdev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2678/2857 ASoC: samsung: Use snd_soc_substream_to_rtd() for accessing private_data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 3e726593107d134221f666b4f2be612b278c3ddb ]
Do not open-code snd_soc_substream_to_rtd().
Stable-dep-of: d9c23ac1217a ("ASoC: samsung: midas_wm1811: run FLL1 at the AIF1 configured rate when idle")
--- sound/soc/samsung/midas_wm1811.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/samsung/midas_wm1811.c +1 -1
@@ -129,7 +129,7 @@ static int midas_stop_fll1(struct snd_soc_pcm_runtime *rtd)static int midas_aif1_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params) { -struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);unsigned int pll_out;/* AIF1CLK should be at least 3MHz for "optimal performance" */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2679/2857 ASoC: samsung: midas_wm1811: run FLL1 at the AIF1 configured rate when idle
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit d9c23ac1217ab094e6bd9ab95e159ec72c8baca5 ]
When the codec is brought up without an active stream, for example because the mixer state restored by alsactl powers up a digital path, midas_start_fll1() sets FLL1 to the default 11.2896MHz rate. The codec's AIF1 however keeps the configuration of the last stream, or its reset default of 48kHz at 256fs before the first stream, which needs a 12.288MHz AIF1 clock. The digital paths then run with AIF1 clocked at a rate not matching its configuration.
Remember the FLL1 rate requested by the last hw_params() call, which matches the AIF1 configuration kept in the codec, and use it when no specific rate is requested. Change the default rate used before the first stream to 12.288MHz, matching the codec's default AIF1 configuration.
--- sound/soc/samsung/midas_wm1811.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/soc/samsung/midas_wm1811.c +10 -4
@@ -26,7 +26,8 @@*/ #define MCLK1_RATE 24000000U#define MCLK2_RATE 32768U -#define DEFAULT_FLL1_RATE 11289600U +/* Matches the codec's default AIF1 configuration: 48kHz, 256fs */ +#define DEFAULT_FLL1_RATE 12288000Ustruct midas_priv {struct regulator *reg_mic_bias;
@@ -34,6 +35,7 @@ struct midas_priv {struct gpio_desc *gpio_fm_sel;struct gpio_desc *gpio_lineout_sel;unsigned int fll1_rate; +unsigned int aif1clk_rate;struct snd_soc_jack headset_jack; };
@@ -60,11 +62,12 @@ static int midas_start_fll1(struct snd_soc_pcm_runtime *rtd, unsigned int rate)if (!rate) rate = priv->fll1_rate;/* -* If no new rate is requested, set FLL1 to a sane default for jack -* detection. +* If no new rate is requested, set FLL1 to the rate the codec's AIF1 +* is currently configured for, as its digital paths can be powered +* up without an active stream. */ if (!rate) - rate =DEFAULT_FLL1_RATE ; + rate = priv->aif1clk_rate ?:DEFAULT_FLL1_RATE ;if (rate != priv->fll1_rate && priv->fll1_rate) {/* while reconfiguring, switch to MCLK2 for SYSCLK */
@@ -130,6 +133,7 @@ static int midas_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) {struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream); +struct midas_priv *priv =snd_soc_card_get_drvdata (rtd->card);unsigned int pll_out;/* AIF1CLK should be at least 3MHz for "optimal performance" */
@@ -138,6 +142,8 @@ static int midas_aif1_hw_params(struct snd_pcm_substream *substream,else pll_out =params_rate (params) *256 ; + priv->aif1clk_rate = pll_out; +return midas_start_fll1 (rtd, pll_out); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2680/2857 sh: Emulate one-byte cmpxchg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul E. McKenney <[email protected]>
[ Upstream commit c81a748edefd098ea21dd35d4bba03f69412fc26 ]
Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh.
[ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] [ paulmck: Apply feedback from Naresh Kamboju. ]
[ Apply Geert Uytterhoeven feedback. ]
Stable-dep-of: f45711b39e03 ("sh: Select BINFMT_FLAT_NO_DATA_START_OFFSET for !MMU")
--- arch/sh/Kconfig | 1 + arch/sh/include/asm/cmpxchg.h | 3 +++ 2 files changed, 4 insertions(+)
arch/sh/Kconfig +1 -0
@@ -16,6 +16,7 @@ config SUPERH select ARCH_HIBERNATION_POSSIBLE if MMU select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION + select ARCH_NEED_CMPXCHG_1_EMU select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT select GENERIC_ATOMIC64
arch/sh/include/asm/cmpxchg.h +3 -0
@@ -9,6 +9,7 @@#include <linux/compiler.h> #include <linux/types.h> +#include <linux/cmpxchg-emu.h> #if defined(CONFIG_GUSA_RB )#include <asm/cmpxchg-grb.h>
@@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old, unsigned long new, int size) {switch (size) { +case 1 : +return cmpxchg_emu_u8 (ptr, old, new);case 4 :return __cmpxchg_u32 (ptr, old, new); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2681/2857 sh: Select BINFMT_FLAT_NO_DATA_START_OFFSET for !MMU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waldemar Brodkorb <[email protected]>
[ Upstream commit f45711b39e03ff5e80b60dcc1fd34b3fc7d3d36c ]
binfmt_flat offsets the in-memory start of the data segment by MAX_SHARED_LIBS words and then aligns it to FLAT_DATA_ALIGN, so FLAT_FLAG_RAM binaries end up with a gap between text and data (commit 2217b9826246 ("binfmt_flat: revert "binfmt_flat: don't offset the data start"")).
SH position-independent code finds the GOT with a PC-relative mova of _GLOBAL_OFFSET_TABLE_, which assumes data follows text directly, as elf2flt lays out the image. With the gap, the GOT register points below the real GOT, so every GOT load reads the neighbouring slot and gets a wrong pointer. On a J2 (sh2eb, no MMU) this made userland crash or hang right after start-up. In my case the data was moved up by 0x20 bytes.
Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") added CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET for architectures that cannot tolerate such a gap; currently only riscv !MMU selects it. Select it on SH as well when building without an MMU.
Tested on a J2 board (Numato Mimas V2, sh2eb, no MMU) with Linux 7.3 and FLAT binaries built with elf2flt: with this change the data segment starts exactly at the end of text and init runs.
Without the patch bootup fails with:
[ 12.080472] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.123609] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.175153] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
--- arch/sh/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/sh/Kconfig +1 -0
@@ -17,6 +17,7 @@ config SUPERH select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION select ARCH_NEED_CMPXCHG_1_EMU + select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT select GENERIC_ATOMIC64
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2682/2857 perf c2c: Fix memory leaks on output fields
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 7d0fe18bc905a4bf59271e2f7ecc95479caebd7b ]
The perf_hpp_list was not freed after use. Let's add it for the main c2c hists list in perf c2c report and a local list in print_pareto().
Previously it was detected by ASAN like below.
=================================================================
==42183==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 1064 byte(s) in 7 object(s) allocated from:
#0 0x7f17334ef24f in calloc (/lib64/libasan.so.8+0xef24f) (BuildId: 61e8165ca90f7a4f06b73f064a938c76deaae079)
#1 0x0000005fa099 in zalloc ../../lib/zalloc.c:8
#2 0x0000004faf6d in get_format tools/perf/builtin-c2c.c:1978
#3 0x0000004fb45e in c2c_hists__init_output tools/perf/builtin-c2c.c:2004
#4 0x0000004fb7de in __hpp_list__parse tools/perf/builtin-c2c.c:2047
#5 0x0000004fbae9 in hpp_list__parse tools/perf/builtin-c2c.c:2085
#6 0x0000004fee13 in print_pareto tools/perf/builtin-c2c.c:2563
#7 0x0000004ffcd7 in perf_c2c__hists_fprintf tools/perf/builtin-c2c.c:2708
#8 0x000000500ab5 in perf_c2c_display tools/perf/builtin-c2c.c:2949
#9 0x0000005045c3 in perf_c2c__report tools/perf/builtin-c2c.c:3522
#10 0x000000505caa in cmd_c2c tools/perf/builtin-c2c.c:3676
#11 0x0000005df50e in run_builtin tools/perf/perf.c:383
#12 0x0000005df9b1 in handle_internal_command tools/perf/perf.c:436
#13 0x0000005dfd7f in run_argv tools/perf/perf.c:480
#14 0x0000005e02d6 in main tools/perf/perf.c:581
#15 0x7f1729450680 in __libc_start_call_main (/lib64/libc.so.6+0x3680) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c)
#16 0x7f1729450797 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3797) (BuildId: 85075e2ae2e13352a1413d41c327dacf6461526c)
#17 0x000000409c34 in _start (tools/perf/perf+0x409c34) (BuildId: 36a64600776d92e4ab7dfd5ca20c92280d72a645)SUMMARY: AddressSanitizer: 1064 byte(s) leaked in 7 allocation(s).
--- tools/perf/builtin-c2c.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/perf/builtin-c2c.c +13 -3
@@ -2087,6 +2087,11 @@ static int c2c_hists__reinit(struct c2c_hists *c2c_hists,return hpp_list__parse (&c2c_hists->list, output, sort); } +static void c2c_hists__exit (struct c2c_hists *c2c_hists) +{ +perf_hpp__reset_output_field (&c2c_hists->list); +} +#define DISPLAY_LINE_LIMIT 0.001static u8 filter_display (u32 val,u32 sum)
@@ -2490,7 +2495,7 @@ static void print_pareto(FILE *out) ret =hpp_list__parse (&hpp_list, cl_output,NULL );if (WARN_ONCE (ret,"failed to setup sort entries\n" )) -return ; + goto out; nd =rb_first_cached (&c2c.hists.hists.entries);
@@ -2504,6 +2509,9 @@ static void print_pareto(FILE *out) c2c_he = container_of(he, struct c2c_hist_entry, he);print_cacheline (c2c_he->hists, he, &hpp_list, out); } + +out: +perf_hpp__reset_output_field (&hpp_list); }static void print_c2c_info (FILE *out,struct perf_session *session)
@@ -3105,12 +3113,12 @@ static int perf_c2c__report(int argc, const char **argv) err =setup_nodes (session);if (err) {pr_err ("Failed setup nodes\n" ); - goto out_session; + goto out_hists; } err =mem2node__init (&c2c.mem2node, &session->header.env);if (err) - goto out_session; + goto out_hists; err =setup_callchain (session->evlist);if (err)
@@ -3197,6 +3205,8 @@ static int perf_c2c__report(int argc, const char **argv) out_mem2node:mem2node__exit (&c2c.mem2node); +out_hists: +c2c_hists__exit (&c2c.hists); out_session:perf_session__delete (session); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2683/2857 blk-mq-rdma: remove queue mapping helper for rdma devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
[ Upstream commit edde9e70bb48301c853299f1bd7c0aa0745a38ea ]
No rdma device exposes its irq vectors affinity today. So the only mapping that we have left, is the default blk_mq_map_queues, which we fallback to anyways. Also fixup the only consumer of this helper (nvme-rdma).
Remove this now dead code.
Stable-dep-of: 9588769af5fc ("nvme-fabrics: reset io_queues before computing the queue mapping")
--- block/Kconfig | 5 ----- block/Makefile | 1 - block/blk-mq-rdma.c | 44 ------------------------------------- drivers/nvme/host/rdma.c | 7 ++---- include/linux/blk-mq-rdma.h | 11 ---------- 5 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 block/blk-mq-rdma.c delete mode 100644 include/linux/blk-mq-rdma.h
block/Kconfig +0 -5
@@ -216,11 +216,6 @@ config BLK_MQ_VIRTIO depends on VIRTIO default y -config BLK_MQ_RDMA - bool - depends on INFINIBAND - default y - config BLK_PM def_bool PM
block/Makefile +0 -1
@@ -30,7 +30,6 @@ obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o obj-$(CONFIG_BLK_DEV_INTEGRITY_T10) += t10-pi.o obj-$(CONFIG_BLK_MQ_PCI) += blk-mq-pci.o obj-$(CONFIG_BLK_MQ_VIRTIO) += blk-mq-virtio.o -obj-$(CONFIG_BLK_MQ_RDMA) += blk-mq-rdma.o obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o obj-$(CONFIG_BLK_WBT) += blk-wbt.o obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o
block/blk-mq-rdma.c deleted +0 -44
44 lines not on this page · raw message
drivers/nvme/host/rdma.c +2 -5
@@ -12,7 +12,6 @@#include <linux/string.h> #include <linux/atomic.h> #include <linux/blk-mq.h> -#include <linux/blk-mq-rdma.h> #include <linux/blk-integrity.h> #include <linux/types.h> #include <linux/list.h>
@@ -2164,10 +2163,8 @@ static void nvme_rdma_map_queues(struct blk_mq_tag_set *set) ctrl->io_queues[HCTX_TYPE_DEFAULT ]; set->map[HCTX_TYPE_READ ].queue_offset =0 ; } -blk_mq_rdma_map_queues (&set->map[HCTX_TYPE_DEFAULT ], - ctrl->device->dev,0 ); -blk_mq_rdma_map_queues (&set->map[HCTX_TYPE_READ ], - ctrl->device->dev,0 ); +blk_mq_map_queues (&set->map[HCTX_TYPE_DEFAULT ]); +blk_mq_map_queues (&set->map[HCTX_TYPE_READ ]);if (opts->nr_poll_queues && ctrl->io_queues[HCTX_TYPE_POLL ]) {/* map dedicated poll queues only if we have queues left */
include/linux/blk-mq-rdma.h deleted +0 -11
@@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_BLK_MQ_RDMA_H -#define _LINUX_BLK_MQ_RDMA_H - -struct blk_mq_tag_set ; -struct ib_device ; - -void blk_mq_rdma_map_queues (struct blk_mq_queue_map *map, -struct ib_device *dev,int first_vec); - -#endif /* _LINUX_BLK_MQ_RDMA_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2684/2857 nvme-fabrics: add queue setup helpers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit a249d3066de62ce2ed68fdf6445556658ecba222 ]
tcp and rdma transports have lots of duplicate code setting up the different queue mappings. Add common helpers.
Stable-dep-of: 9588769af5fc ("nvme-fabrics: reset io_queues before computing the queue mapping")
--- drivers/nvme/host/fabrics.c | 76 ++++++++++++++++++++++++++++++ drivers/nvme/host/fabrics.h | 11 +++++ drivers/nvme/host/rdma.c | 79 ++----------------------------- drivers/nvme/host/tcp.c | 92 ++----------------------------------- 4 files changed, 96 insertions(+), 162 deletions(-)
drivers/nvme/host/fabrics.c +76 -0
@@ -959,6 +959,82 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,return ret; } +void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues, +u32 io_queues[HCTX_MAX_TYPES ]) +{ +if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { +/* +* separate read/write queues +* hand out dedicated default queues only after we have +* sufficient read queues. +*/ + io_queues[HCTX_TYPE_READ ] = opts->nr_io_queues; + nr_io_queues -= io_queues[HCTX_TYPE_READ ]; + io_queues[HCTX_TYPE_DEFAULT ] = +min (opts->nr_write_queues, nr_io_queues); + nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; + }else { +/* +* shared read/write queues +* either no write queues were requested, or we don't have +* sufficient queue count to have dedicated default queues. +*/ + io_queues[HCTX_TYPE_DEFAULT ] = +min (opts->nr_io_queues, nr_io_queues); + nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; + } + +if (opts->nr_poll_queues && nr_io_queues) { +/* map dedicated poll queues only if we have queues left */ + io_queues[HCTX_TYPE_POLL ] = +min (opts->nr_poll_queues, nr_io_queues); + } +} +EXPORT_SYMBOL_GPL (nvmf_set_io_queues); + +void nvmf_map_queues (struct blk_mq_tag_set *set,struct nvme_ctrl *ctrl, +u32 io_queues[HCTX_MAX_TYPES ]) +{ +struct nvmf_ctrl_options *opts = ctrl->opts; + +if (opts->nr_write_queues && io_queues[HCTX_TYPE_READ ]) { +/* separate read/write queues */ + set->map[HCTX_TYPE_DEFAULT ].nr_queues = + io_queues[HCTX_TYPE_DEFAULT ]; + set->map[HCTX_TYPE_DEFAULT ].queue_offset =0 ; + set->map[HCTX_TYPE_READ ].nr_queues = + io_queues[HCTX_TYPE_READ ]; + set->map[HCTX_TYPE_READ ].queue_offset = + io_queues[HCTX_TYPE_DEFAULT ]; + }else { +/* shared read/write queues */ + set->map[HCTX_TYPE_DEFAULT ].nr_queues = + io_queues[HCTX_TYPE_DEFAULT ]; + set->map[HCTX_TYPE_DEFAULT ].queue_offset =0 ; + set->map[HCTX_TYPE_READ ].nr_queues = + io_queues[HCTX_TYPE_DEFAULT ]; + set->map[HCTX_TYPE_READ ].queue_offset =0 ; + } + +blk_mq_map_queues (&set->map[HCTX_TYPE_DEFAULT ]); +blk_mq_map_queues (&set->map[HCTX_TYPE_READ ]); +if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL ]) { +/* map dedicated poll queues only if we have queues left */ + set->map[HCTX_TYPE_POLL ].nr_queues = io_queues[HCTX_TYPE_POLL ]; + set->map[HCTX_TYPE_POLL ].queue_offset = + io_queues[HCTX_TYPE_DEFAULT ] + + io_queues[HCTX_TYPE_READ ]; +blk_mq_map_queues (&set->map[HCTX_TYPE_POLL ]); + } + +dev_info (ctrl->device, +"mapped %d/%d/%d default/read/poll queues.\n" , + io_queues[HCTX_TYPE_DEFAULT ], + io_queues[HCTX_TYPE_READ ], + io_queues[HCTX_TYPE_POLL ]); +} +EXPORT_SYMBOL_GPL (nvmf_map_queues); +static int nvmf_check_required_opts (struct nvmf_ctrl_options *opts,unsigned int required_opts) {
drivers/nvme/host/fabrics.h +11 -0
@@ -196,6 +196,13 @@ static inline void nvmf_complete_timed_out_request(struct request *rq) } } +static inline unsigned int nvmf_nr_io_queues (struct nvmf_ctrl_options *opts) +{ +return min (opts->nr_io_queues,num_online_cpus ()) + +min (opts->nr_write_queues,num_online_cpus ()) + +min (opts->nr_poll_queues,num_online_cpus ()); +} +int nvmf_reg_read32 (struct nvme_ctrl *ctrl,u32 off,u32 *val);int nvmf_reg_read64 (struct nvme_ctrl *ctrl,u32 off,u64 *val);int nvmf_reg_write32 (struct nvme_ctrl *ctrl,u32 off,u32 val);
@@ -209,5 +216,9 @@ int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size);bool nvmf_should_reconnect (struct nvme_ctrl *ctrl);bool nvmf_ip_options_match (struct nvme_ctrl *ctrl,struct nvmf_ctrl_options *opts); +void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues, +u32 io_queues[HCTX_MAX_TYPES ]); +void nvmf_map_queues (struct blk_mq_tag_set *set,struct nvme_ctrl *ctrl, +u32 io_queues[HCTX_MAX_TYPES ]);#endif /* _NVME_FABRICS_H */
drivers/nvme/host/rdma.c +4 -75
100 lines not on this page · raw message
drivers/nvme/host/tcp.c +5 -87
115 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2685/2857 nvme-fabrics: reset io_queues before computing the queue mapping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 9588769af5fc8ac12290d48ce1014a78916681fc ]
nvmf_set_io_queues only sets the io_queues entries of the queue types it hands out, but the array is reused on every reconnect. When the controller grants fewer queues on a reconnect, stale entries survive and nvmf_map_queues maps CPUs to hardware contexts that don't exist anymore, which crashes blk_mq_map_swqueue with a NULL pointer dereference. E.g. with nr_io_queues=8, nr_write_queues=8 and nr_poll_queues=8, 24 queues are mapped 8/8/8 (default/read/poll). If the controller grants only 16 queues on the reconnect, the poll map still starts at hardware context 16.
Clear the array before computing the new mapping.
--- drivers/nvme/host/fabrics.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/host/fabrics.c +2 -0
@@ -962,6 +962,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues,u32 io_queues[HCTX_MAX_TYPES ]) { +memset (io_queues,0 ,sizeof (*io_queues) *HCTX_MAX_TYPES ); +if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) {/* * separate read/write queues
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2686/2857 nvme-fabrics: limit each queue type to the number of online CPUs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 99fd0cbae84988e0af34784aa18ddd51ae094ade ]
nvmf_nr_io_queues limits each queue type to the number of online CPUs when asking for I/O queues, but nvmf_set_io_queues hands out the granted queues without these limits, and only nr_io_queues is clamped when parsing the options.
E.g. with 2 CPUs, nr_io_queues=2, nr_write_queues=10 and nr_poll_queues=10, 2 + 2 + 2 = 6 queues are requested, but handed out as 4 default, 2 read and 0 poll queues. blk_mq_map_queues can't create more CPU masks than there are CPUs, so default queues 2 and 3 take over the CPUs of default queues 0 and 1, and connecting the I/O queue of default queue 1 fails with -EXDEV.
Apply the same limits in nvmf_set_io_queues. A queue type with more queues than online CPUs always has a hardware context without an online CPU, so no working setup changes. The options are not modified, so the limits follow CPU hotplug on reconnect.
--- drivers/nvme/host/fabrics.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/nvme/host/fabrics.c +15 -6
@@ -962,18 +962,27 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,void nvmf_set_io_queues (struct nvmf_ctrl_options *opts,u32 nr_io_queues,u32 io_queues[HCTX_MAX_TYPES ]) { +/* +* Each queue type is mapped to the CPUs separately, so a type with +* more queues than online CPUs has hardware contexts without an online +* CPU. Use the same limits as nvmf_nr_io_queues. +*/ +u32 nr_io =min (opts->nr_io_queues,num_online_cpus ()); +u32 nr_write =min (opts->nr_write_queues,num_online_cpus ()); +u32 nr_poll =min (opts->nr_poll_queues,num_online_cpus ()); +memset (io_queues,0 ,sizeof (*io_queues) *HCTX_MAX_TYPES ); -if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { +if (nr_write && nr_io < nr_io_queues) {/* * separate read/write queues * hand out dedicated default queues only after we have * sufficient read queues. */ - io_queues[HCTX_TYPE_READ ] = opts->nr_io_queues; + io_queues[HCTX_TYPE_READ ] = nr_io; nr_io_queues -= io_queues[HCTX_TYPE_READ ]; io_queues[HCTX_TYPE_DEFAULT ] = -min (opts->nr_write_queues, nr_io_queues); +min (nr_write, nr_io_queues); nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; }else {/*
@@ -982,14 +991,14 @@ void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,* sufficient queue count to have dedicated default queues. */ io_queues[HCTX_TYPE_DEFAULT ] = -min (opts->nr_io_queues, nr_io_queues); +min (nr_io, nr_io_queues); nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT ]; } -if (opts->nr_poll_queues && nr_io_queues) { +if (nr_poll && nr_io_queues) {/* map dedicated poll queues only if we have queues left */ io_queues[HCTX_TYPE_POLL ] = -min (opts->nr_poll_queues, nr_io_queues); +min (nr_poll, nr_io_queues); } }EXPORT_SYMBOL_GPL (nvmf_set_io_queues);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2687/2857 nvme-fabrics: clear the poll map if no poll queues are mapped
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit 36ede1aa85d5d74c39ed375a906f6eadb15cee5b ]
blk_mq_alloc_tag_set sets the nr_queues of every map to nr_hw_queues. When nr_poll_queues is set but no queues are left for polling, nvmf_map_queues skips the poll map and leaves it this way, with all CPUs mapped to hctx 0. The queue then claims poll support, polled I/O ends up on hctx 0, which isn't a poll queue, and hctx 0 is marked as a poll hctx, so even the Connect command of the first I/O queue is marked as polled.
Clear the poll map when no poll queues are mapped, so polled I/O is rejected with -EOPNOTSUPP.
--- drivers/nvme/host/fabrics.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/nvme/host/fabrics.c +7 -0
@@ -1036,6 +1036,13 @@ void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, io_queues[HCTX_TYPE_DEFAULT ] + io_queues[HCTX_TYPE_READ ];blk_mq_map_queues (&set->map[HCTX_TYPE_POLL ]); + }else { +/* +* blk_mq_alloc_tag_set sets nr_queues of all maps to +* nr_hw_queues. Clear the poll map, otherwise the queue claims +* poll support and polled I/O ends up on hctx 0. +*/ + set->map[HCTX_TYPE_POLL ].nr_queues =0 ; } dev_info(ctrl->device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2688/2857 ionic: fix port_info use-after-free on firmware recovery
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit d90d1a768b3b022c52beafb3a4701ee2ee3d2b5e ]
ionic_port_init() allocates port_info when the pointer is NULL, but its error path frees it without checking whether this call allocated it. Before commit ddc5911b9bd2 ("ionic: call ionic_port_init after fw-upgrade") the function returned early when the buffer already existed, so the two were symmetric.
Since then a failed PORT_INIT on either recovery path - fw_up or reset_done - frees a buffer an earlier init owns, while the netdev is registered and the ethtool ops are reading it.
Free only what this call allocated.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +9 -4
@@ -661,6 +661,7 @@ int ionic_port_init(struct ionic *ionic) {struct ionic_identity *ident = &ionic->ident;struct ionic_dev *idev = &ionic->idev; +bool allocated = false;size_t sz;int err;
@@ -672,6 +673,8 @@ int ionic_port_init(struct ionic *ionic) GFP_KERNEL);if (!idev->port_info)return -ENOMEM ; + + allocated = true; } sz =min (sizeof (ident->port.config),sizeof (idev->dev_cmd_regs->data));
@@ -688,10 +691,12 @@ int ionic_port_init(struct ionic *ionic)mutex_unlock (&ionic->dev_cmd_lock);if (err) {dev_err (ionic->dev,"Failed to init port\n" ); -dma_free_coherent (ionic->dev, idev->port_info_sz, - idev->port_info, idev->port_info_pa); - idev->port_info =NULL ; - idev->port_info_pa =0 ; +if (allocated) { +dma_free_coherent (ionic->dev, idev->port_info_sz, + idev->port_info, idev->port_info_pa); + idev->port_info =NULL ; + idev->port_info_pa =0 ; + } }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2689/2857 veth: schedule the peers NAPI after XDP_TX when only GRO is enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Gao <[email protected]>
[ Upstream commit f16b8c6a656e62bfa7bb6a3b876f9ccdaf53bd43 ]
veth_xdp_xmit() queues XDP_TX frames on the peer's ring if the peer has NAPI. A peer with GRO enabled and no XDP program also has NAPI.
veth_xdp_flush() then schedules the peer's NAPI, but only if the peer's xdp_prog is set, so for such a peer the frames are never processed. Nothing else schedules that NAPI by default.
Once the ring is full, every XDP_TX frame is dropped, and so are the skbs that veth_xmit() queues on the same ring.
Commit 0e672f306a28 ("veth: check for NAPI instead of xdp_prog before xmit of XDP frame") changed the check in veth_xdp_xmit() but not the one in veth_xdp_flush(). Make veth_xdp_flush() check the napi pointer instead of xdp_prog, as veth_xdp_xmit() does.
--- drivers/net/veth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/veth.c +1 -1
@@ -555,7 +555,7 @@ static void veth_xdp_flush(struct veth_rq *rq, struct veth_xdp_tx_bq *bq) rcv_priv =netdev_priv (rcv); rcv_rq = &rcv_priv->rq[veth_select_rxq (rcv)];/* xdp_ring is initialized on receive side? */ -if (unlikely (!rcu_access_pointer (rcv_rq->xdp_prog))) +if (unlikely (!rcu_access_pointer (rcv_rq->napi))) goto out;__veth_xdp_flush (rcv_rq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2690/2857 net: shrink the payload-only part of skb dataref to one bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 4957ea03bf2696f5da12c09144f48d040696ecc2 ]
skb_shinfo(skb)->dataref is split in two 16-bit halves: the lower one counts all references, the upper one the payload-only (nohdr) references.
__skb_clone() increments dataref without bound, and skb_cloned() only checks the low 16 bits. With 65,537 references the low half reads 1, the head looks private, and pskb_expand_head() (or skb_unclone(), skb_cow(), ...) frees it while clones still point to it.
An unprivileged user can reach this from a user and network namespace:
about 32,770 AF_PACKET sockets on lo bring dataref to 0x10001, then any pskb_expand_head() on the receive path (here a pull of a large IPv6 Hop-by-Hop header) frees the shared head:
BUG: KASAN: slab-use-after-free in _copy_to_iter+0x187/0x1330 Read of size 1590 at addr ff110001104a9002 by task dataref_wrap/87 skb_copy_datagram_iter+0x60/0x190 packet_recvmsg+0x1f5/0x12b0 __sys_recvfrom+0x18d/0x290 Freed by task 87: kfree+0xf3/0x3b0 pskb_expand_head+0x344/0xeb0 __pskb_pull_tail+0xf9/0x1bf0 ipv6_parse_hopopts+0x377/0x4f0 ip6_rcv_core+0xc67/0x1620
The upper half never holds more than 1. It is only set by __skb_header_release(), with atomic_set() on an skb owning its head (TCP/SCTP output, and GRO which never sees cloned skbs). __skb_clone() clears nohdr, and __copy_skb_header() does not copy it.
Move SKB_DATAREF_SHIFT to 30, so that the reference count gets 30 bits, and dataref stays positive. Wrapping it would need 2^30 live clones of a single skb, which socket buffer limits and memory make unreachable.
This issue was found by Anthropic using Claude, and validated by Ada Logics.
--- include/linux/skbuff.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/skbuff.h +4 -4
@@ -610,9 +610,9 @@ struct skb_shared_info {* * Transport layers send out clones of payload skbs they hold for * retransmissions. To allow lower layers of the stack to prepend their headers -* we split &skb_shared_info.dataref into two halves. -* The lower 16 bits count the overall number of references. -* The higher 16 bits indicate how many of the references are payload-only. +* we split &skb_shared_info.dataref into two parts. +* The lower 30 bits count the overall number of references. +* Bit 30 indicates whether one of the references is payload-only. * skb_header_cloned() checks if skb is allowed to add / write the headers. * * The creator of the skb (e.g. TCP) marks its skb as &sk_buff.nohdr
@@ -632,7 +632,7 @@ struct skb_shared_info {* Having multiple payload-only skbs with different lengths of hdr_len is not * possible. The payload-only skbs should never leave their owner. */ -#define SKB_DATAREF_SHIFT 16 +#define SKB_DATAREF_SHIFT 30#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2691/2857 tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Travis Howard <[email protected]>
[ Upstream commit a55eb6a622141352131aa6156bbd6ce5da79d9b5 ]
The Datto SIRIS 5 1U Server is a Dell OEMR XL R640 (Dell's OEM-ready variant of the PowerEdge R640) sold under Datto's identity. Its DMI strings report sys_vendor "datto" and product_name "SIRIS 5 1U Server", so it does not match the existing "PowerEdge R640" entry in tg3_restart_aer_quirk_table.
As on the PowerEdge R640, a system restart triggers a fatal PCIe AER on the BCM5720 during ACPI _PTS for S5, which the iDRAC logs as PCI1318 and which hangs the reboot. Power off is unaffected.
Clearing the same PCI_EXP_DEVCTL error-reporting bits on both BCM5720 functions from userspace immediately before restart allows the system to reboot normally, confirming the quirk applies to this platform.
--- drivers/net/ethernet/broadcom/tg3.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +6 -0
@@ -18147,6 +18147,12 @@ static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R750"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "datto"), + DMI_MATCH(DMI_PRODUCT_NAME, "SIRIS 5 1U Server"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2692/2857 ata: libata-core: Ignore forced transfer modes the host does not support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rand Deeb <[email protected]>
[ Upstream commit ea5a5af9159cc89e8bcb7a95336e02c8b70aa3d2 ]
The libata.force parameter can force a transfer mode (pio0-6, mwdma0-4, udma0-7) for a port or device. ata_force_xfermask() applies it in ata_do_set_mode() right after ata_dev_xfermask() has limited the device masks to what the host supports. It replaces those masks with the forced mode without checking the host masks, so a mode the controller does not support is passed to the driver's ->set_piomode() or ->set_dmamode().
Several PATA drivers rely on the host masks to keep the mode number in range when indexing their timing tables. ata_piix, pata_efar, pata_it8213, pata_oldpiix, pata_radisys and pata_rdc declare ATA_PIO4 and ATA_MWDMA12_ONLY, index a five-entry PIO timing table with pio_mode - XFER_PIO_0, and index a three-entry needed_pio[] table with dma_mode - XFER_MW_DMA_0. Booting with libata.force=pio5, pio6, mwdma3 or mwdma4 makes them read past those tables, use the values read as further indices into the timing table, and write the result to the controller's timing registers.
Make ata_force_xfermask() skip, with a warning, a forced transfer mode that is not in the port's PIO, MWDMA or UDMA mask, and keep looking for an earlier matching libata.force entry, as it already does for entries that do not apply to the device. With libata.force=pio4,1.0:pio5 on a PIO4 host, device 1.0 now gets pio4 instead of pio5. Forcing a mode the host supports still works as before, including a mode that ata_dev_xfermask() removed for the device or cable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/ata/libata-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/ata/libata-core.c +12 -0
@@ -415,6 +415,7 @@ static void ata_force_link_limits(struct ata_link *link)*/ static void ata_force_xfermask (struct ata_device *dev) { +struct ata_port *ap = dev->link->ap;int devno = dev->link->pmp + dev->devno;int alt_devno = devno;int i;
@@ -439,6 +440,17 @@ static void ata_force_xfermask(struct ata_device *dev)ata_unpack_xfermask (fe->param.xfer_mask, &pio_mask, &mwdma_mask, &udma_mask); + +/* Make sure that the port supports the specified xfer modes. */ +if (!(pio_mask & ap->pio_mask) && + !(mwdma_mask & ap->mwdma_mask) && + !(udma_mask & ap->udma_mask)) { +ata_dev_warn (dev, +"FORCE: ignoring unsupported xfer_mask %s\n" , + fe->param.name); +continue ; + } +if (udma_mask) dev->udma_mask = udma_mask;else if (mwdma_mask) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2693/2857 tipc: fix use-after-free of broadcast reception link at node release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 473167593f42551ce6b00c05cee8cd20309d45ac ]
When the last reference to a tipc_node is dropped, the node itself is deferred to the RCU callback tipc_node_free(), but the nested broadcast reception link, n->bc_entry.link, is kfree()d synchronously in tipc_node_kref_release(), before call_rcu(), and the pointer is never cleared. Readers that obtained the node from node_list and then dereference bc_entry.link deep into the link (tipc_link_name() in tipc_nl_node_reset_link_stats(), bcl->name/stats in tipc_nl_add_bc_link() on the link dump path) therefore touch freed memory although the enclosing node stays alive for a full grace period. The sibling per-bearer links get "kfree + NULL" under the node write lock in tipc_node_clear_links(); the broadcast entry was missed.
The race is reachable through the node cleanup timer: once a peer has been unreachable for NODE_CLEANUP_AFTER (300 s), tipc_node_timeout() -> tipc_node_cleanup() unlinks the node under the write lock, and the final tipc_node_put() at the caller runs outside node_list_lock, so the kfree executes in timer softirq context, concurrently with genl dump/ reset walkers that hold only rcu_read_lock(). (A netlink "peer remove" cannot race those walkers itself: tipc_genl_family has no parallel_ops, so all doit/dumpit calls serialize on the global genl lock.)
Reproduced in a QEMU/KVM guest running v7.3.0 with KASAN and PREEMPT(full): 10 TIPC peer namespaces on veth bearers, bearer removal staggered so the 300 s node cleanup timers expire while other tasks loop link dumps with the broadcast filter and reset-link-stats lookups. KASAN hit within two cleanup cycles:
BUG: KASAN: slab-use-after-free in strlen+0x85/0xa0 Read of size 1 at addr ffff88800b54a004 by task poc_eth/371 strlen+0x85/0xa0 tipc_nl_add_bc_link+0x2f9/0xd40 __tipc_nl_add_node_links+0x10c/0x140 tipc_nl_node_dump_link+0x8d5/0xd50 Freed by task 0: kfree+0x121/0x380 tipc_node_timeout+0xa33/0xcf0 run_timer_softirq+0x144/0x250 sysvec_apic_timer_interrupt
with the freed object being the kmalloc-1k tipc_link allocated by tipc_link_bc_create() during peer discovery. The same defect fires in strcmp() called from tipc_nl_node_reset_link_stats().
Move the kfree of n->bc_entry.link into the tipc_node_free() RCU callback so the broadcast link lives exactly as long as the enclosing node. All readers are covered: the netlink walkers are inside rcu_read_lock(), and the packet reception path reaches the node via tipc_node_find(), whose kref defers kref_release itself.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection.
--- net/tipc/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/node.c +1 -1
@@ -305,6 +305,7 @@ static void tipc_node_free(struct rcu_head *rp)#ifdef CONFIG_TIPC_CRYPTO tipc_crypto_stop (&n->crypto_rx);#endif +kfree (n->bc_entry.link);kfree (n); }
@@ -312,7 +313,6 @@ static void tipc_node_kref_release(struct kref *kref) { struct tipc_node *n = container_of(kref, struct tipc_node, kref); -kfree (n->bc_entry.link);call_rcu (&n->rcu, tipc_node_free); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2694/2857 ASoC: wm8994: follow AIF clock source changes in MCLK gating
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 8731e33a3b98ea1ccade059b3a1ce06b7dd66b17 ]
The AIF clock source can be changed by configure_aif_clock() while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. aif_mclk_set() only enables the MCLK selected at the time the AIF clock is turned on, so an MCLK selected later this way is never enabled, and the codec may run from a stopped clock.
Track whether the AIF clock is running and, if so, enable the newly selected MCLK in configure_aif_clock() before switching to it, then release the previously enabled one.
--- sound/soc/codecs/wm8994.c | 27 +++++++++++++++++++++++++++ sound/soc/codecs/wm8994.h | 1 + 2 files changed, 28 insertions(+)
sound/soc/codecs/wm8994.c +27 -0
@@ -162,9 +162,12 @@ static void wm8958_micd_set_rate(struct snd_soc_component *component)static int configure_aif_clock (struct snd_soc_component *component,int aif) {struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); +struct clk *mclk =NULL ; +bool switch_mclk;int rate;int reg1 =0 ;int offset; +int ret;if (aif) offset =4 ;
@@ -173,11 +176,13 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)switch (wm8994->sysclk[aif]) {case WM8994_SYSCLK_MCLK1 : + mclk = wm8994->mclk[WM8994_MCLK1 ].clk; rate = wm8994->mclk_rate[0 ];break ;case WM8994_SYSCLK_MCLK2 : reg1 |=0x8 ; + mclk = wm8994->mclk[WM8994_MCLK2 ].clk; rate = wm8994->mclk_rate[1 ];break ;
@@ -195,6 +200,20 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)return -EINVAL ; } +/* +* If the AIF clock is running, enable the new MCLK before switching +* to it and release the previous one afterwards. +*/ + switch_mclk = wm8994->aif_clk_on[aif] && mclk != wm8994->aif_mclk[aif]; +if (switch_mclk) { + ret =clk_prepare_enable (mclk); +if (ret <0 ) { +dev_err (component->dev, +"Failed to enable MCLK for AIF%d\n" , aif +1 ); +return ret; + } + } +if (rate >=13500000 ) { rate /=2 ; reg1 |=WM8994_AIF1CLK_DIV ;
@@ -209,6 +228,11 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)WM8994_AIF1CLK_SRC_MASK |WM8994_AIF1CLK_DIV , reg1); +if (switch_mclk) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] = mclk; + } +return 0 ; }
@@ -1070,6 +1094,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablif (!enable) {clk_disable_unprepare (wm8994->aif_mclk[aif]); wm8994->aif_mclk[aif] =NULL ; + wm8994->aif_clk_on[aif] = false;return 0 ; }
@@ -1089,6 +1114,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enabl clk_idx =WM8994_MCLK2 ;break ;default : + wm8994->aif_clk_on[aif] = true;return 0 ; }
@@ -1099,6 +1125,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn ret; } wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk; + wm8994->aif_clk_on[aif] = true;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -82,6 +82,7 @@ struct wm8994_priv {struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ];struct clk *aif_mclk[2 ]; +bool aif_clk_on[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2695/2857 eventpoll: propagate wakeup source creation failure in ep_modify()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Chen <[email protected]>
[ Upstream commit 9f2b8f4a452db79741c06e6ea91448347f4a975c ]
When EPOLL_CTL_MOD adds EPOLLWAKEUP, ep_modify() ignores the return value of ep_create_wakeup_source(). If allocation fails, it returns success with EPOLLWAKEUP set but no per-item wakeup source, so the requested suspend protection is missing.
This can happen without fault injection on SELinux systems: creating the wakeup source's sysfs nodes can require GFP_KERNEL_ACCOUNT allocations for security.selinux xattrs, which can fail when the caller's memory cgroup is over its limit.
Create the wakeup source before updating the event mask and data, and return the error if creation fails. Leave any newly created per-epoll source in place until ep_free(), as ep_insert() does on failure.
--- fs/eventpoll.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
fs/eventpoll.c +13 -5
@@ -1587,11 +1587,22 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, {int pwake =0 ;poll_table pt; +int error;lockdep_assert_irqs_enabled ();init_poll_funcptr (&pt,NULL ); +/* +* Create the wakeup source before committing the new event mask. +* Leave the old mask and data unchanged if allocation fails. +*/ +if ((event->events &EPOLLWAKEUP ) && !ep_has_wakeup_source (epi)) { + error =ep_create_wakeup_source (epi); +if (error) +return error; + } +/* * Set the new event interest mask before calling f_op->poll(); * otherwise we might miss an event that happens between the
@@ -1599,12 +1610,9 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,*/ epi->event.events = event->events;/* need barrier below */ epi->event.data = event->data;/* protected by mtx */ -if (epi->event.events &EPOLLWAKEUP ) { -if (!ep_has_wakeup_source (epi)) -ep_create_wakeup_source (epi); - }else if (ep_has_wakeup_source (epi)) { +if (!(epi->event.events &EPOLLWAKEUP ) && +ep_has_wakeup_source (epi))ep_destroy_wakeup_source (epi); - }/* * The following barrier has two effects:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2696/2857 signal: skip blocked signals in dequeue_synchronous_signal()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 4bd3a0e8e53decd614853fbb487a268f139f679e ]
dequeue_synchronous_signal() checks whether an unblocked synchronous signal is pending, but its queue scan can select a different blocked entry with a positive si_code. This can deliver a signal while it is still blocked.
Check the blocked mask for each queued entry. Forced faults are unblocked when necessary by force_sig_info_to_task(), and the existing pending bookkeeping is unchanged.
--- kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/signal.c +3 -2
@@ -725,12 +725,13 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)return 0 ;/* -* Return the first synchronous signal in the queue. +* Return the first unblocked synchronous signal in the queue. */ list_for_each_entry (q, &pending->list, list) {/* Synchronous signals have a positive si_code */ if ((q->info.si_code >SI_USER ) && - (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK )) { + (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK ) && + !sigismember (&tsk->blocked, q->info.si_signo)) { sync = q; goto next; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2697/2857 nsproxy: Fix cred leak in the error path of prepare_nsset()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit e08601d3a7b2236f4915497dca353dcf117bab5c ]
A task that calls setns() with CLONE_NEWUSER together with CLONE_NEWNS and at least one more namespace flag leaks a struct cred (and the user_namespace, ucounts and group_info references it holds) whenever the call fails at the fs_struct copy. On a kernel with CONFIG_USER_NS the leak is one cred per failed setns(); under memory pressure, or driven by a fault-injecting attacker, it accumulates and pins user namespaces that can then never be freed.
prepare_nsset() sets nsset->flags only on the success path:
if (flags & CLONE_NEWUSER)
nsset->cred = prepare_creds();
...
} else if (flags & CLONE_NEWNS) {
nsset->fs = copy_fs_struct(me->fs);
if (!nsset->fs)
goto out; /* flags still 0 here */
}
nsset->flags = flags;
return 0;
out:
put_nsset(nsset);put_nsset() decides what to release from nsset->flags:
if (flags & CLONE_NEWUSER) put_cred(nsset_cred(nsset));
On the copy_fs_struct() failure arm prepare_creds() has already allocated the cred, but nsset->flags is still the zero from the caller's "struct nsset nsset = {}", so put_nsset() does not see CLONE_NEWUSER and never drops it. The caller (__do_sys_setns) returns the error without touching nsset, so the cred is lost.
Set nsset->flags at the start of prepare_nsset(), before anything can fail, so every error exit through put_nsset() releases what was taken. commit_nsset(), which clears nsset->cred on success, is unaffected.
Reproduced on x86_64 under QEMU with failslab aimed at the fs_struct cache and kmemleak enabled: 500 calls ofsetns(pidfd, CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWUTS) each fail with -ENOMEM and leave 851 unreferenced cred objects allocated from prepare_creds() via setns() before the fix, and none after (the program is in the notes below).
Found by formal verification of kernel/nsproxy.c.
--- kernel/nsproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/nsproxy.c +1 -1
@@ -313,6 +313,7 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) {struct task_struct *me = current; + nsset->flags = flags; nsset->nsproxy =create_new_namespaces (0 , me,current_user_ns (), me->fs);if (IS_ERR (nsset->nsproxy))return PTR_ERR (nsset->nsproxy);
@@ -333,7 +334,6 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) goto out; } - nsset->flags = flags;return 0 ; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2698/2857 ACPICA: Initialize parser_state.aml_end in acpi_install_method()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Hu <[email protected]>
[ Upstream commit ec696f34774db985841bac9a2df179c0040ef073 ]
In AcpiInstallMethod(), the local ParserState is stack-allocated and only ParserState.Aml was initialized. Parser helpers called by this path read ParserState.AmlEnd for bounds checking: AcpiPsPeekOpcode() reads it before validating the first AML opcode, and AcpiPsGetNextPackageEnd() reads it indirectly via AcpiPsGetNextPackageLength(). The subsequent package-limit check also compares against ParserState.AmlEnd. Because AmlEnd was never set, these checks operated on an uninitialized value, which Coverity flagged as an uninitialized read (CID 1684785) and which could lead to incorrect parser bounds decisions.
Coverity report:
*** CID 1684785: Memory - illegal accesses (UNINIT)
/src/acpica/source/components/namespace/nsxfname.c: 712 in AcpiInstallMethod()
ParserState.Aml += AcpiPsGetOpcodeSize (Opcode);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1684785: Memory - illegal accesses (UNINIT)
Using uninitialized value "ParserState.AmlEnd" when calling
"AcpiPsGetNextPackageEnd".
ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState);Initialize ParserState.AmlEnd to the end of the table (Buffer + Table->Length) so the parser bounds checks operate on a valid limit.
--- drivers/acpi/acpica/nsxfname.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/nsxfname.c +1 -0
@@ -503,6 +503,7 @@ acpi_status acpi_install_method(u8 *buffer)/* First AML opcode in the table must be a control method */ parser_state.aml = buffer +sizeof (struct acpi_table_header ); + parser_state.aml_end = buffer + table->length; opcode =acpi_ps_peek_opcode (&parser_state);if (opcode !=AML_METHOD_OP ) {return (AE_BAD_PARAMETER );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2699/2857 ksmbd: select CRYPTO_AES
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Andreas Michalopoulos <[email protected]>
[ Upstream commit 2c36c4a86104d763ee798d4a89e2d3384b4cd626 ]
ksmbd allocates "gcm(aes)" and "ccm(aes)" AEAD transforms for SMB3 encryption, but SMB_SERVER only selects CRYPTO_GCM and CRYPTO_CCM, not an AES cipher. With a configuration in which nothing else enables CRYPTO_AES, ksmbd builds but cannot allocate the transforms, and every session that uses encryption fails:
ksmbd: Failed to alloc encrypt aead : -2
ksmbd: crypto alloc failed
Select CRYPTO_AES, as the SMB client already does.
--- fs/smb/server/Kconfig | 1 + 1 file changed, 1 insertion(+)
fs/smb/server/Kconfig +1 -0
@@ -16,6 +16,7 @@ config SMB_SERVER select CRYPTO_AEAD2 select CRYPTO_CCM select CRYPTO_GCM + select CRYPTO_AES select ASN1 select OID_REGISTRY select CRC32
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2700/2857 ASoC: amd: raven: Fix memory leak in acp3x_dma_close()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e0b17f84f6e3fa1201b8e2857094023c42ce5636 ]
acp3x_dma_open() allocates a struct i2s_stream_instance for each substream, but acp3x_dma_close() never frees it, leaking it on every open/close cycle.
Free it in acp3x_dma_close().
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/amd/raven/acp3x-pcm-dma.c +2 -0
@@ -354,6 +354,8 @@ static int acp3x_dma_close(struct snd_soc_component *component, } } +kfree (ins); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2701/2857 cpuidle: haltpoll: Only define guest_halt_poll_ns tracepoint when used
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 107b87efc8fcd6a597f1b534f116385620770e56 ]
Tracepoints that are defined take up around 5K each, even if they are not used. When a tracepoint is used only in code when a specific config is enabled, their definition must also be only defined when the same config is enabled otherwise it wastes memory.
The tracepoint guest_halt_poll_ns is only used when CONFIG_CPU_IDLE_GOV_HALTPOLL is enabled. Guard the definition of that tracepoint with the same config.
--- include/trace/events/power.h | 3 +++ 1 file changed, 3 insertions(+)
include/trace/events/power.h +3 -0
@@ -523,6 +523,7 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,TP_ARGS (name, type, new_value) ); +#ifdef CONFIG_CPU_IDLE_GOV_HALTPOLL TRACE_EVENT(guest_halt_poll_ns, TP_PROTO(bool grow, unsigned int new, unsigned int old),
@@ -551,6 +552,8 @@ TRACE_EVENT(guest_halt_poll_ns, trace_guest_halt_poll_ns(true, new, old)#define trace_guest_halt_poll_ns_shrink (new, old) \ trace_guest_halt_poll_ns(false, new, old) +#endif /* CONFIG_CPU_IDLE_GOV_HALTPOLL */ +#endif /* _TRACE_POWER_H */ /* This part must be outside protection */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2702/2857 regulator: irq_helper: replace use of system_wq with system_dfl_wq
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Crivellari <[email protected]>
[ Upstream commit b6f4bd64f453183954184ffbc2b89d73ed8fb135 ]
Currently if a user enqueues 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 consistency cannot be addressed without refactoring the API.
This continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues and a new alloc_workqueue flag:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
This specific workload do not benefit from a per-cpu workqueue, so use the default unbound workqueue (system_dfl_wq) instead.
Stable-dep-of: 8a6d73e316f9 ("regulator: irq: freeze deferred hardware access during suspend")
--- drivers/regulator/irq_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/irq_helpers.c +1 -1
@@ -146,7 +146,7 @@ static void regulator_notifier_isr_work(struct work_struct *work) reschedule:if (!d->high_prio) -mod_delayed_work (system_wq, &h->isr_work, +mod_delayed_work (system_dfl_wq, &h->isr_work,msecs_to_jiffies (tmo));else mod_delayed_work(system_highpri_wq, &h->isr_work,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2703/2857 regulator: irq: freeze deferred hardware access during suspend
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 8a6d73e316f95e398a1de1d1f58314b6d3e7f641 ]
The regulator IRQ helper delays status checks and recovery callbacks on non-freezable workqueues. Those callbacks may access regulator hardware after the backing bus has been suspended.
Use system_freezable_wq for normal-priority callbacks. Allocate a freezable high-priority workqueue when requested so the high_prio contract is preserved while hardware access is frozen across suspend.
--- drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-)
drivers/regulator/irq_helpers.c +22 -16
@@ -15,6 +15,7 @@#include <linux/regmap.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/workqueue.h> #include <linux/regulator/driver.h> #include "internal.h"
@@ -27,6 +28,7 @@ struct regulator_irq {int irq;int retry_cnt;struct delayed_work isr_work; +struct workqueue_struct *wq; };/*
@@ -145,12 +147,7 @@ static void regulator_notifier_isr_work(struct work_struct *work)return ; reschedule: -if (!d->high_prio) -mod_delayed_work (system_dfl_wq, &h->isr_work, -msecs_to_jiffies (tmo)); -else -mod_delayed_work (system_highpri_wq, &h->isr_work, -msecs_to_jiffies (tmo)); +mod_delayed_work (h->wq, &h->isr_work,msecs_to_jiffies (tmo)); }static irqreturn_t regulator_notifier_isr (int irq,void *data)
@@ -248,13 +245,8 @@ static irqreturn_t regulator_notifier_isr(int irq, void *data) }if (d->irq_off_ms) { -if (!d->high_prio) -schedule_delayed_work (&h->isr_work, -msecs_to_jiffies (d->irq_off_ms)); -else -mod_delayed_work (system_highpri_wq, - &h->isr_work, -msecs_to_jiffies (d->irq_off_ms)); +mod_delayed_work (h->wq, &h->isr_work, +msecs_to_jiffies (d->irq_off_ms)); }return IRQ_HANDLED ;
@@ -363,13 +355,25 @@ void *regulator_irq_helper(struct device *dev,init_rdev_errors (h); -if (h->desc.irq_off_ms) +if (h->desc.irq_off_ms) { +if (h->desc.high_prio) { + h->wq =alloc_workqueue ("regulator_irq_highpri" , +WQ_FREEZABLE |WQ_HIGHPRI ,0 ); +if (!h->wq) +return ERR_PTR (-ENOMEM ); + }else { + h->wq = system_freezable_wq; + } +INIT_DELAYED_WORK (&h->isr_work, regulator_notifier_isr_work); + } ret =request_threaded_irq (h->irq,NULL , regulator_notifier_isr,IRQF_ONESHOT | irq_flags, h->desc.name, h);if (ret) {dev_err (dev,"Failed to request IRQ %d\n" , irq); +if (h->desc.irq_off_ms && h->desc.high_prio) +destroy_workqueue (h->wq);return ERR_PTR (ret); }
@@ -393,8 +397,11 @@ void regulator_irq_helper_cancel(void **handle)struct regulator_irq *h = *handle;free_irq (h->irq, h); -if (h->desc.irq_off_ms) +if (h->desc.irq_off_ms) {cancel_delayed_work_sync (&h->isr_work); +if (h->desc.high_prio) +destroy_workqueue (h->wq); + } h =NULL ; }
@@ -436,4 +443,3 @@ int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid,return 0 ; }EXPORT_SYMBOL_GPL (regulator_irq_map_event_simple); -
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2704/2857 sctp: reject forged cookie peer_addr with unknown address family
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingyuan Mo <[email protected]>
[ Upstream commit 9802123ceca818aa69284c615114ca55b9cc94a1 ]
When cookie authentication is disabled, COOKIE-ECHO peer_addr is attacker-controlled. An invalid sa_family made sctp_get_af_specific() return NULL and crash in sctp_transport_init() on af_specific->sockaddr_len. Validate it with af->addr_valid() in sctp_unpack_cookie(), which also rejects a mismatched family, e.g. an AF_INET6 peer_addr on an IPv4 socket that would later crash in sctp_v6_get_dst() on inet6_sk(sk)->opt. Validate a copy of peer_addr, since addr_valid() rewrites a v4-mapped v6 address in place and the cookie still lives in the received skb, which is not guaranteed to be unshared. Store the validated copy in the new association and pass it to sctp_process_init() instead of the raw cookie, so a v4-mapped v6 address is normalised to AF_INET before the association and its primary transport are built from it.
For that, sctp_v6_addr_valid() has to return 0 for a non-v4-mapped address when it is called with a socket that is not PF_INET6, so that IPv6 addresses are never used on IPv4 sockets. The check is done after the v4-mapped handling, so v4-mapped addresses passed to an IPv4 socket through the socket API keep being accepted. As addr_valid() now also checks sk_family and ipv6_only_sock, simplify the address handling in sctp_process_param() with it, as it additionally filters out non-unicast addresses. As a side effect, a v4-mapped address in an IPv6 address parameter is now normalised to AF_INET before the transport is created, matching what the socket API paths already do.
Also add the missing !af check in sctp_process_init(), as sctp_get_af_specific(AF_INET6) returns NULL on CONFIG_IPV6=n builds.
BUG: KASAN: null-ptr-deref in sctp_transport_new+0xa7/0x350 Read of size 4 at addr 00000000000000b4 by task poc/682 Call Trace: <IRQ> sctp_transport_new+0xa7/0x350 sctp_assoc_add_peer+0x153/0x850 sctp_process_init+0xf9/0x1180 sctp_sf_do_5_1D_ce+0x464/0xbc0 sctp_do_sm+0x114/0x2990 sctp_endpoint_bh_rcv+0x280/0x430 sctp_inq_push+0xdd/0x100 sctp_rcv+0x17f5/0x1ae0 sctp4_rcv+0x2b/0x40 ip_protocol_deliver_rcu+0x25b/0x270 ip_local_deliver+0xd1/0xe0 </IRQ> Kernel panic - not syncing: Fatal exception in interrupt
--- net/sctp/ipv6.c | 6 +++++- net/sctp/sm_make_chunk.c | 24 +++++++++++++----------- net/sctp/sm_statefuns.c | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-)
net/sctp/ipv6.c +5 -1
@@ -710,7 +710,8 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp)* SCTP. * * Output: -* Return 0 - If the address is a non-unicast or an illegal address. +* Return 0 - If the address is a non-unicast or an illegal address, +* or a non-v4-mapped address on a non-PF_INET6 socket. * Return 1 - If the address is a unicast. */ static int sctp_v6_addr_valid(union sctp_addr *addr,
@@ -734,6 +735,9 @@ static int sctp_v6_addr_valid(union sctp_addr *addr,if (!(ret &IPV6_ADDR_UNICAST ))return 0 ; +if (sp &&sctp_opt2sk (sp)->sk_family !=PF_INET6 ) +return 0 ; +return 1 ; }
net/sctp/sm_make_chunk.c +13 -11
@@ -1760,7 +1760,9 @@ struct sctp_association *sctp_unpack_cookie(__u8 *digest = ep->digest;struct sctp_chunkhdr *ch;unsigned int len, chlen; +union sctp_addr paddr;enum sctp_scope scope; +struct sctp_af *af;ktime_t kt;/* Header size is static data prior to the actual cookie, including
@@ -1880,6 +1882,11 @@ struct sctp_association *sctp_unpack_cookie( goto fail; } + paddr = bear_cookie->peer_addr; + af =sctp_get_af_specific (paddr.sa.sa_family); +if (!af || !af->addr_valid (&paddr,sctp_sk (ep->base.sk),NULL )) + goto malformed; +/* Make a new base association. */ scope =sctp_scope (sctp_source (chunk)); retval =sctp_association_new (ep, ep->base.sk, scope, gfp);
@@ -1893,6 +1900,7 @@ struct sctp_association *sctp_unpack_cookie(/* Populate the association from the cookie. */ memcpy (&retval->c, bear_cookie,sizeof (*bear_cookie)); + retval->c.peer_addr = paddr;if (sctp_assoc_set_bind_addr_from_cookie (retval, bear_cookie,GFP_ATOMIC ) <0 ) {
@@ -2417,8 +2425,8 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, (param.p->type == SCTP_PARAM_IPV4_ADDRESS || param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { af =sctp_get_af_specific (param_type2af (param.p->type)); -if (!af->from_addr_param (&addr, param.addr, - chunk->sctp_hdr->source,0 )) +if (!af || !af->from_addr_param (&addr, param.addr, + chunk->sctp_hdr->source,0 ))continue ;if (sctp_cmp_addr_exact (sctp_source (chunk), &addr)) src_match =1 ;
@@ -2590,17 +2598,11 @@ static int sctp_process_param(struct sctp_association *asoc,*/ switch (param.p->type) {case SCTP_PARAM_IPV6_ADDRESS : -if (PF_INET6 != asoc->base.sk->sk_family) -break ; - goto do_addr_param; -case SCTP_PARAM_IPV4_ADDRESS : -/* v4 addresses are not allowed on v6-only socket */ -if (ipv6_only_sock (asoc->base.sk)) -break ; -do_addr_param: af =sctp_get_af_specific (param_type2af (param.p->type)); -if (!af->from_addr_param (&addr, param.addr,htons (asoc->peer.port),0 )) +if (!af || !af->from_addr_param (&addr, param.addr, +htons (asoc->peer.port),0 ) || + !af->addr_valid (&addr,sctp_sk (asoc->base.sk),NULL ))break ; scope =sctp_scope (peer_addr);if (sctp_in_scope (net, &addr, scope))
net/sctp/sm_statefuns.c +1 -1
@@ -813,7 +813,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,* effects--it is safe to run them here. */ if (!sctp_process_init (new_asoc, chunk, - &chunk->subh.cookie_hdr->c.peer_addr, + &new_asoc->c.peer_addr, peer_init,GFP_ATOMIC )) goto nomem_init;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2705/2857 cgroup/cpuset: check effective mems for a movable-only configuration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit 4c047bd0499602161959478b90e66f4c8e523c9b ]
check_insane_mems_config() warns and enables cpusets_insane_config_key when a cpuset's tasks can allocate only from movable memory.
In cgroup v2 the request may name a memoryless node, which has no zones and cpusets reports it as a movable-only nodemask.
For example, with node 2 a CPU-only node:
# echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control
# mkdir /sys/fs/cgroup/test
# echo 2 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/cpuset.mems.effective
0-1
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=2)!This is a bit confusing, especially consider mems.effective ends up with a valid nodemask by-design (cpuset.mems is treated as-if it were empty).
Check each new effective mask in update_nodemasks_hier() instead, as the hotplug path already does. The allocator's bail-out tests the task's mems_allowed, which comes from the effective mask.
A request naming a movable-only not present in the parent's nodemask no longer warns (since, again, the cpuset.mems gets overridden and treated as empty). However, it will warn if the parent's mems include the node later.
For Example, with node 3 a movable-only node:
# echo 0 > /sys/fs/cgroup/test/cpuset.mems
# echo 3 > /sys/fs/cgroup/test/child/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
0
# dmesg
{ empty }
# echo 0,3 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
3
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=3)!--- kernel/cgroup/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +2 -2
@@ -1925,6 +1925,8 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)continue ;rcu_read_unlock (); +check_insane_mems_config (new_mems); +spin_lock_irq (&callback_lock); cp->effective_mems = *new_mems;spin_unlock_irq (&callback_lock);
@@ -1995,8 +1997,6 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,if (retval <0 ) goto done; -check_insane_mems_config (&trialcs->mems_allowed); -spin_lock_irq (&callback_lock); cs->mems_allowed = trialcs->mems_allowed;spin_unlock_irq (&callback_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2706/2857 ALSA: sh: aica: Fix spu_memset() stride
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 0d01f90b07e877ef31f9959e9b0bc6bcca9b99df ]
spu_memset() writes one 32-bit word per iteration, but advances the destination offset by only one byte. spu_reset() calls it with 0x200000 / 4 words to clear the 2 MiB of sound RAM, so:
- three out of four writel() calls target an unaligned address. The SH4 can't do that. Each one traps and is emulated by the unaligned access fixup. This call to spu_memset() causes 393216 unaligned accesses, visible in /proc/cpu/alignment.
- the clear covered only about 512 KiB of sound RAM, not 2 MiB.
Advance the offset by the size of the written word, to clear the full sound RAM using aligned writes.
--- sound/sh/aica.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/sh/aica.c +1 -1
@@ -95,7 +95,7 @@ static void spu_memset(u32 toi, u32 what, int length)local_irq_save (flags);writel (what, toi +SPU_MEMORY_BASE );local_irq_restore (flags); - toi++; + toi +=sizeof (what); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2707/2857 net: sparx5/lan969x: do not read past skb->len when injecting a frame
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 9642ce6cb51ebd596d0a02074ba9b2a387e974b0 ]
sparx5_inject() writes the frame to the injection FIFO one 32-bit word at a time, and pads frames shorter than 60 bytes with zero words.
Before this patch, the last word is loaded whole even when skb->len is not a multiple of four, so 1 to 3 bytes past the end of the frame are read. For a frame shorter than 60 bytes those bytes are also transmitted, as VLD_BYTES marks the whole last word valid and the padding starts at the next word.
Write the trailing bytes from a zeroed word. The number of words written and VLD_BYTES are unchanged.
Found by an AI code review agent, and reproduced on lan969x and sparx5 with register injection: bytes 57 to 59 of a 57 byte frame were not zero. With the fix they are zero, and traffic still passes on both chips.
--- .../net/ethernet/microchip/sparx5/sparx5_packet.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +12 -3
@@ -168,8 +168,8 @@ static int sparx5_inject(struct sparx5 *sparx5,struct sk_buff *skb, struct net_device *ndev) { + u32 val, w, count, last;int grp =INJ_QUEUE ; -u32 val, w, count;u8 *buf; val =spx5_rd (sparx5,QS_INJ_STATUS );
@@ -188,14 +188,23 @@ static int sparx5_inject(struct sparx5 *sparx5,for (w =0 ; w <IFH_LEN ; w++)spx5_wr (ifh[w], sparx5,QS_INJ_WR (grp)); -/* Write words, round up */ - count =DIV_ROUND_UP (skb->len,4 ); +/* Write the whole words of the frame */ + count = skb->len /4 ; buf = skb->data;for (w =0 ; w < count; w++, buf +=4 ) { val =get_unaligned ((const u32 *)buf);spx5_wr (val, sparx5,QS_INJ_WR (grp)); } +/* Write the last 1 to 3 bytes, zero padded to a whole word */ + last = skb->len %4 ; +if (last) { + val =0 ; +memcpy (&val, buf, last); +spx5_wr (val, sparx5,QS_INJ_WR (grp)); + w++; + } +/* Add padding */ while (w < (60 /4 )) {spx5_wr (0 , sparx5,QS_INJ_WR (grp));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2708/2857 net: fix frag_list leak in skb_segment_list() error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 546daf344420b5dce27eded3ad15be12628dd185 ]
skb_segment_list() detaches the frag_list from the head skb and moves its members one by one to the skb->next chain. On error, err_linearize frees that chain with kfree_skb_list(skb->next), relying on the members not yet processed to still be linked after the current one.
This does not hold when the current member was shared: it is replaced by skb_clone(), and __skb_clone() clears ->next. If __skb_linearize() then fails on that clone, the remaining members are no longer reachable from skb->next nor from skb_shinfo(skb)->frag_list, and they leak.
The skb_shared() error branch already relinks nskb->next to list_skb before jumping to err_linearize. Do it unconditionally right after nskb is added to the chain, so every error exit sees the remaining members. On the last member list_skb is NULL, which still terminates the chain.
--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/skbuff.c +6 -3
@@ -4103,10 +4103,13 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,else tail->next = nskb; -if (unlikely (err)) { - nskb->next = list_skb; +/* nskb may be a clone with a NULL ->next: keep the remaining +* members linked so that err_linearize frees them. +*/ + nskb->next = list_skb; + +if (unlikely (err)) goto err_linearize; - } tail = nskb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2709/2857 net/rds: include the scope id in the sendmsg connection cache check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit b7dfff5e3eb3984d42026a6d653ec2a3d5cec729 ]
rds_sendmsg() reuses the connection cached in rs->rs_conn when its peer address and ToS match the request. The interface index is part of a connection's identity as well: rds_conn_create_outgoing() passes the request's scope_id down as dev_if, and rds_conn_lookup() compares c_dev_if, so sends to the same link-local address through two interfaces are two different connections. The cache-hit test never looked at it.
A socket bound to a non-link-local address has rs_bound_scope_id 0, and the scope check at the top of rds_sendmsg() accepts any non-zero destination scope for such a socket. So after a send to fe80::x%ifA, a send to fe80::x%ifB hits the cached ifA connection and the datagram leaves through ifA, to whichever peer answers to that address there.
Compare c_dev_if with the request's scope_id in the cache test, so that such a send takes the lookup path and finds, or creates, the ifB connection - the same key the lookup uses. A send without a destination takes its scope from the socket, and the connection it created was keyed on that same scope, so the comparison holds for it too; the next patch gives that send the connected peer's own scope.
Found by inspection while reworking this cache for the connection lifetime series on net-next; not observed in the field.
--- net/rds/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/send.c +2 -1
@@ -1309,7 +1309,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)/* rds_conn_create has a spinlock that runs with IRQ off. * Caching the conn in the socket helps a lot. */ if (rs->rs_conn &&ipv6_addr_equal (&rs->rs_conn->c_faddr, &daddr) && - rs->rs_tos == rs->rs_conn->c_tos) { + rs->rs_tos == rs->rs_conn->c_tos && + rs->rs_conn->c_dev_if == scope_id) { conn = rs->rs_conn; }else { conn = rds_conn_create_outgoing(sock_net(sock->sk),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2710/2857 net/rds: keep the connected peers scope id apart from the bound one
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 3fe64a5f670dbd6c7c84c2345b0b9726b3b79b31 ]
rds_connect() has nowhere to keep the scope of a link-local peer, so it stores it in rs_bound_scope_id, the scope of the socket's own bound address, for rds_bind() to check a later link-local bind against. That field is then also what a send without a destination uses as the request's scope, what getpeername() and recvmsg() report as the peer's scope, and what a later bind() overwrites:rds_add_bound() stores the bound address's scope unconditionally, which for a non-link-local address is 0.
So after connect(fe80::x%ifA) followed by bind(global), a send() with no destination asks for fe80::x with scope 0. rds_conn_lookup() keys on the interface, so that finds or creates a connection with c_dev_if 0, which the TCP transport then tries to connect through sin6_scope_id 0 and tcp_v6_connect() rejects for a link-local peer:
the connected socket's data is queued on a connection that can never come up. In the other order, bind(global) then connect(fe80::x%ifB), the connect leaves a global-bound socket with rs_bound_scope_id ifB, so sends to other link-local peers are refused as off-link and sends to global peers inherit a meaningless interface.
Give the connected peer its own rs_conn_scope_id. rds_connect() records it there and leaves the bound scope alone, rds_bind()'s connected-socket check compares against it, and the destination-less send takes its scope from it - falling back to the bound scope for a non-link-local peer, so that send() and sendto() to the connected peer compute the same scope, and so the same connection. getpeername() reports the connected peer with its own scope. recvmsg() used to report every sender with the socket's bound scope; a connected socket receives from any peer, so neither the bound scope nor the connected peer's scope is right for an arbitrary sender. It now reports a link-local sender with the interface recorded on its connection, c_dev_if: the TCP accept path takes it from the incoming socket, and the IB passive side resolves it from the local address, the closest the CM gets to the arrival interface. Any other sender is reported with scope 0, the inet6 convention. Either way, a reply to the address an application was given reaches the same connection.
Found by inspection while reworking the sendmsg connection cache; not observed in the field.
--- net/rds/af_rds.c | 15 +++++++++------ net/rds/bind.c | 4 ++-- net/rds/rds.h | 2 ++ net/rds/recv.c | 11 ++++++++++- net/rds/send.c | 6 +++++- 5 files changed, 28 insertions(+), 10 deletions(-)
net/rds/af_rds.c +9 -6
@@ -135,8 +135,7 @@ static int rds_getname(struct socket *sock, struct sockaddr *uaddr, sin6->sin6_port = rs->rs_conn_port; sin6->sin6_addr = rs->rs_conn_addr; sin6->sin6_flowinfo =0 ; -/* scope_id is the same as in the bound address. */ - sin6->sin6_scope_id = rs->rs_bound_scope_id; + sin6->sin6_scope_id = rs->rs_conn_scope_id; uaddr_len =sizeof (*sin6); } }else {
@@ -568,6 +567,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, }ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &rs->rs_conn_addr); rs->rs_conn_port = sin->sin_port; + rs->rs_conn_scope_id =0 ;break ;#if IS_ENABLED (CONFIG_IPV6 )
@@ -612,11 +612,14 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, ret = -EINVAL ;break ; } -/* Remember the connected address scope ID. It will -* be checked against the binding local address when -* the socket is bound. +/* Remember the connected address scope ID. It is +* checked against the binding local address when +* the socket is bound, and gives a send without a +* destination its scope. */ - rs->rs_bound_scope_id = sin6->sin6_scope_id; + rs->rs_conn_scope_id = sin6->sin6_scope_id; + }else { + rs->rs_conn_scope_id =0 ; } rs->rs_conn_addr = sin6->sin6_addr; rs->rs_conn_port = sin6->sin6_port;
net/rds/bind.c +2 -2
@@ -233,8 +233,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)* non-link local address (scope_id is 0). */ if (!ipv6_addr_any (&rs->rs_conn_addr) && scope_id && - rs->rs_bound_scope_id && - scope_id != rs->rs_bound_scope_id) { + rs->rs_conn_scope_id && + scope_id != rs->rs_conn_scope_id) { ret = -EINVAL ; goto out; }
net/rds/rds.h +2 -0
@@ -613,6 +613,8 @@ struct rds_sock {struct in6_addr rs_conn_addr;#define rs_conn_addr_v4 rs_conn_addr.s6_addr32[3]__be16 rs_conn_port; +/* scope of rs_conn_addr when it is link-local, 0 otherwise */ +__u32 rs_conn_scope_id;struct rds_transport *rs_transport;/*
net/rds/recv.c +10 -1
@@ -754,7 +754,16 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, sin6->sin6_port = inc->i_hdr.h_sport; sin6->sin6_addr = inc->i_saddr; sin6->sin6_flowinfo =0 ; - sin6->sin6_scope_id = rs->rs_bound_scope_id; +/* A link-local sender is reported with the +* interface recorded on its connection (the +* accepting socket's device for TCP, the one +* resolved for the local address on IB); any +* other sender has no scope. +*/ + sin6->sin6_scope_id = + (ipv6_addr_type (&inc->i_saddr) & +IPV6_ADDR_LINKLOCAL ) ? + inc->i_conn->c_dev_if :0 ; msg->msg_namelen =sizeof (*sin6); } }
net/rds/send.c +5 -1
@@ -1222,7 +1222,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)lock_sock (sk); daddr = rs->rs_conn_addr; dport = rs->rs_conn_port; - scope_id = rs->rs_bound_scope_id; +/* The connected peer's scope for a link-local peer, else +* the bound scope, as an explicit send to that peer would +* compute below. +*/ + scope_id = rs->rs_conn_scope_id ?: rs->rs_bound_scope_id;release_sock (sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2711/2857 selftests/net: Add SHA256 computation over data sent in tcp_mmap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaoyan Li <[email protected]>
[ Upstream commit 5c5945dc695c54f2b55a934a10b6c4e220f9c140 ]
Add option to compute and send SHA256 over data sent (-i).
This is to ensure the correctness of data received. Data is randomly populated from /dev/urandom.
Tested:
./tcp_mmap -s -z -i
./tcp_mmap -z -H $ADDR -i
SHA256 is correct
./tcp_mmap -s -i
./tcp_mmap -H $ADDR -i
SHA256 is correct
Stable-dep-of: 5536d5553f27 ("selftests/net: tcp_mmap: remove unused -k option and keepflag")
--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tcp_mmap.c | 102 ++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 12 deletions(-)
tools/testing/selftests/net/Makefile +1 -1
@@ -79,7 +79,7 @@ TEST_FILES := settings include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma -$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread +$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto $(OUTPUT)/tcp_inq: LDLIBS += -lpthread $(OUTPUT)/bind_bhash: LDLIBS += -lpthread
tools/testing/selftests/net/tcp_mmap.c +91 -11
222 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2712/2857 selftests/net: tcp_mmap: remove unused -k option and keepflag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Thelen <[email protected]>
[ Upstream commit 5536d5553f274c8baa77c44854c9091657213970 ]
Commit aacb0c2e524c ("selftests: net: tcp_mmap must use TCP_ZEROCOPY_RECEIVE") removed the only read of keepflag in child_thread(), leaving the file-scope keepflag variable set by the -k option in main() but never read. This triggers a Clang 23 warning:
tcp_mmap.c:91:12: error: variable 'keepflag' set but not used [-Werror,-Wunused-but-set-global]
Remove the unused keepflag variable and the dead -k getopt option.
--- tools/testing/selftests/net/tcp_mmap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
tools/testing/selftests/net/tcp_mmap.c +1 -5
@@ -85,7 +85,6 @@ static int rcvbuf; /* Default: autotuning. Can be set with -r <integer> optionstatic int sndbuf;/* Default: autotuning. Can be set with -w <integer> option */ static int zflg;/* zero copy option. (MSG_ZEROCOPY for sender, mmap() for receiver */ static int xflg;/* hash received data (simple xor) (-h option) */ -static int keepflag;/* -k option: receiver shall keep all received file in memory (no munmap() calls) */ static int integrity;/* -i option: sender and receiver compute sha256 over the data.*/ static size_t chunk_size =512 *1024 ;
@@ -439,7 +438,7 @@ int main(int argc, char *argv[])int sflg =0 ;int mss =0 ; -while ((c =getopt (argc, argv,"46p:svr:w:H:zxkP:M:C:a:i" )) !=-1 ) { +while ((c =getopt (argc, argv,"46p:svr:w:H:zxP:M:C:a:i" )) !=-1 ) {switch (c) {case '4' : cfg_family =PF_INET ;
@@ -473,9 +472,6 @@ int main(int argc, char *argv[])case 'x' : xflg =1 ;break ; -case 'k' : - keepflag =1 ; -break ;case 'P' : max_pacing_rate =atoi (optarg) ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2713/2857 tls: move tls_cipher_size_desc to net/tls/tls.h
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit fd0fc6fdd8896a195cb7b0210a5ee46774718fc8 ]
It's only used in net/tls/*, no need to bloat include/net/tls.h.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- include/net/tls.h | 10 ---------- net/tls/tls.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
include/net/tls.h +0 -10
@@ -51,16 +51,6 @@struct tls_rec ; -struct tls_cipher_size_desc { -unsigned int iv; -unsigned int key; -unsigned int salt; -unsigned int tag; -unsigned int rec_seq; -}; - -extern const struct tls_cipher_size_desc tls_cipher_size_desc[]; -/* Maximum data size carried in a TLS record */ #define TLS_MAX_PAYLOAD_SIZE ((size_t)1 << 14)
net/tls/tls.h +10 -0
@@ -50,6 +50,16 @@#define TLS_DEC_STATS (net, field) \ SNMP_DEC_STATS((net)->mib.tls_statistics, field) +struct tls_cipher_size_desc { +unsigned int iv; +unsigned int key; +unsigned int salt; +unsigned int tag; +unsigned int rec_seq; +}; + +extern const struct tls_cipher_size_desc tls_cipher_size_desc[]; +/* TLS records are maintained in 'struct tls_rec'. It stores the memory pages * allocated or mapped for each TLS record. After encryption, the records are * stores in a linked list.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2714/2857 tls: add TLS_CIPHER_ARIA_GCM_* to tls_cipher_size_desc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 200e23165109a173ffde3310dffa5ef5e502d97f ]
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls_main.c | 2 ++ 1 file changed, 2 insertions(+)
net/tls/tls_main.c +2 -0
@@ -73,6 +73,8 @@ const struct tls_cipher_size_desc tls_cipher_size_desc[] = {CIPHER_SIZE_DESC (TLS_CIPHER_CHACHA20_POLY1305 ),CIPHER_SIZE_DESC (TLS_CIPHER_SM4_GCM ),CIPHER_SIZE_DESC (TLS_CIPHER_SM4_CCM ), +CIPHER_SIZE_DESC (TLS_CIPHER_ARIA_GCM_128 ), + CIPHER_SIZE_DESC(TLS_CIPHER_ARIA_GCM_256), };static const struct proto *saved_tcpv6_prot;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2715/2857 tls: reduce size of tls_cipher_size_desc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 037303d6760751fdb95ba62cf448ecbc1ac29c98 ]
tls_cipher_size_desc indexes ciphers by their type, but we're not using indices 0..50 of the array. Each struct tls_cipher_size_desc is 20B, so that's a lot of unused memory. We can reindex the array starting at the lowest used cipher_type.
Introduce the get_cipher_size_desc helper to find the right item and avoid out-of-bounds accesses, and make tls_cipher_size_desc's size explicit so that gcc reminds us to update TLS_CIPHER_MIN/MAX when we add a new cipher.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls.h | 13 ++++++++++++- net/tls/tls_device.c | 4 ++-- net/tls/tls_device_fallback.c | 8 ++++---- net/tls/tls_main.c | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-)
net/tls/tls.h +12 -1
@@ -58,7 +58,18 @@ struct tls_cipher_size_desc {unsigned int rec_seq; }; -extern const struct tls_cipher_size_desc tls_cipher_size_desc[]; +#define TLS_CIPHER_MIN TLS_CIPHER_AES_GCM_128 +#define TLS_CIPHER_MAX TLS_CIPHER_ARIA_GCM_256 +extern const struct tls_cipher_size_desc tls_cipher_size_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ]; + +static inline const struct tls_cipher_size_desc *get_cipher_size_desc (u16 cipher_type) +{ +if (cipher_type <TLS_CIPHER_MIN || cipher_type >TLS_CIPHER_MAX ) +return NULL ; + +return &tls_cipher_size_desc[cipher_type -TLS_CIPHER_MIN ]; +} +/* TLS records are maintained in 'struct tls_rec'. It stores the memory pages * allocated or mapped for each TLS record. After encryption, the records are
net/tls/tls_device.c +2 -2
@@ -924,7 +924,7 @@ tls_device_reencrypt(struct sock *sk, struct tls_context *tls_ctx)default :return -EINVAL ; } - cipher_sz = &tls_cipher_size_desc[tls_ctx->crypto_recv.info.cipher_type]; + cipher_sz =get_cipher_size_desc (tls_ctx->crypto_recv.info.cipher_type); rxm =strp_msg (tls_strp_msg (sw_ctx)); orig_buf = kmalloc(rxm->full_len + TLS_HEADER_SIZE + cipher_sz->iv,
@@ -1120,7 +1120,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) rc = -EINVAL ; goto release_netdev; } - cipher_sz = &tls_cipher_size_desc[crypto_info->cipher_type]; + cipher_sz =get_cipher_size_desc (crypto_info->cipher_type);/* Sanity-check the rec_seq_size for stack allocations */ if (cipher_sz->rec_seq >TLS_MAX_REC_SEQ_SIZE ) {
net/tls/tls_device_fallback.c +4 -4
@@ -69,7 +69,7 @@ static int tls_enc_record(struct aead_request *aead_req,default :return -EINVAL ; } - cipher_sz = &tls_cipher_size_desc[prot->cipher_type]; + cipher_sz =get_cipher_size_desc (prot->cipher_type); buf_size =TLS_HEADER_SIZE + cipher_sz->iv; len =min_t (int, *in_len, buf_size);
@@ -310,7 +310,7 @@ static void fill_sg_out(struct scatterlist sg_out[3], void *buf, void *dummy_buf) {const struct tls_cipher_size_desc *cipher_sz = - &tls_cipher_size_desc[tls_ctx->crypto_send.info.cipher_type]; +get_cipher_size_desc (tls_ctx->crypto_send.info.cipher_type);sg_set_buf (&sg_out[0 ], dummy_buf, sync_size);sg_set_buf (&sg_out[1 ], nskb->data + tcp_payload_offset, payload_len);
@@ -348,7 +348,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx,default : goto free_req; } - cipher_sz = &tls_cipher_size_desc[tls_ctx->crypto_send.info.cipher_type]; + cipher_sz =get_cipher_size_desc (tls_ctx->crypto_send.info.cipher_type); buf_len = cipher_sz->salt + cipher_sz->iv +TLS_AAD_SPACE_SIZE + sync_size + cipher_sz->tag; buf =kmalloc (buf_len,GFP_ATOMIC );
@@ -495,7 +495,7 @@ int tls_sw_fallback_init(struct sock *sk, rc = -EINVAL ; goto free_aead; } - cipher_sz = &tls_cipher_size_desc[crypto_info->cipher_type]; + cipher_sz =get_cipher_size_desc (crypto_info->cipher_type); rc =crypto_aead_setkey (offload_ctx->aead_send, key, cipher_sz->key);if (rc)
net/tls/tls_main.c +2 -2
@@ -58,7 +58,7 @@ enum { TLS_NUM_PROTS, }; -#define CIPHER_SIZE_DESC (cipher) [cipher] = { \ +#define CIPHER_SIZE_DESC (cipher) [cipher - TLS_CIPHER_MIN] = { \ .iv = cipher ## _IV_SIZE, \ .key = cipher ## _KEY_SIZE, \ .salt = cipher ## _SALT_SIZE, \
@@ -66,7 +66,7 @@ enum { .rec_seq = cipher ## _REC_SEQ_SIZE, \ } -const struct tls_cipher_size_desc tls_cipher_size_desc[] = { +const struct tls_cipher_size_desc tls_cipher_size_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ] = {CIPHER_SIZE_DESC (TLS_CIPHER_AES_GCM_128 ),CIPHER_SIZE_DESC (TLS_CIPHER_AES_GCM_256 ),CIPHER_SIZE_DESC (TLS_CIPHER_AES_CCM_128 ),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2716/2857 tls: rename tls_cipher_size_desc to tls_cipher_desc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 8db44ab26bebe969851468bea6072d9a094b2ace ]
We're going to add other fields to it to fully describe a cipher, so the "_size" name won't match the contents.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls.h | 8 +++---- net/tls/tls_device.c | 34 ++++++++++++++-------------- net/tls/tls_device_fallback.c | 42 +++++++++++++++++------------------ net/tls/tls_main.c | 20 ++++++++--------- 4 files changed, 52 insertions(+), 52 deletions(-)
net/tls/tls.h +4 -4
@@ -50,7 +50,7 @@#define TLS_DEC_STATS (net, field) \ SNMP_DEC_STATS((net)->mib.tls_statistics, field) -struct tls_cipher_size_desc { +struct tls_cipher_desc {unsigned int iv;unsigned int key;unsigned int salt;
@@ -60,14 +60,14 @@ struct tls_cipher_size_desc {#define TLS_CIPHER_MIN TLS_CIPHER_AES_GCM_128#define TLS_CIPHER_MAX TLS_CIPHER_ARIA_GCM_256 -extern const struct tls_cipher_size_desc tls_cipher_size_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ]; +extern const struct tls_cipher_desc tls_cipher_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ]; -static inline const struct tls_cipher_size_desc *get_cipher_size_desc (u16 cipher_type) +static inline const struct tls_cipher_desc *get_cipher_desc (u16 cipher_type) {if (cipher_type <TLS_CIPHER_MIN || cipher_type >TLS_CIPHER_MAX )return NULL ; -return &tls_cipher_size_desc[cipher_type -TLS_CIPHER_MIN ]; +return &tls_cipher_desc[cipher_type -TLS_CIPHER_MIN ]; }
net/tls/tls_device.c +17 -17
@@ -910,7 +910,7 @@ static int tls_device_reencrypt(struct sock *sk, struct tls_context *tls_ctx) { struct tls_sw_context_rx *sw_ctx = tls_sw_ctx_rx(tls_ctx); -const struct tls_cipher_size_desc *cipher_sz; +const struct tls_cipher_desc *cipher_desc;int err, offset, copy, data_len, pos;struct sk_buff *skb, *skb_iter;struct scatterlist sg[1 ];
@@ -924,10 +924,10 @@ tls_device_reencrypt(struct sock *sk, struct tls_context *tls_ctx)default :return -EINVAL ; } - cipher_sz =get_cipher_size_desc (tls_ctx->crypto_recv.info.cipher_type); + cipher_desc =get_cipher_desc (tls_ctx->crypto_recv.info.cipher_type); rxm =strp_msg (tls_strp_msg (sw_ctx)); - orig_buf =kmalloc (rxm->full_len +TLS_HEADER_SIZE + cipher_sz->iv, + orig_buf =kmalloc (rxm->full_len +TLS_HEADER_SIZE + cipher_desc->iv, sk->sk_allocation);if (!orig_buf)return -ENOMEM ;
@@ -943,8 +943,8 @@ tls_device_reencrypt(struct sock *sk, struct tls_context *tls_ctx)sg_init_table (sg,1 );sg_set_buf (&sg[0 ], buf, - rxm->full_len +TLS_HEADER_SIZE + cipher_sz->iv); - err =skb_copy_bits (skb, offset, buf,TLS_HEADER_SIZE + cipher_sz->iv); + rxm->full_len +TLS_HEADER_SIZE + cipher_desc->iv); + err =skb_copy_bits (skb, offset, buf,TLS_HEADER_SIZE + cipher_desc->iv);if (err) goto free_buf;
@@ -955,7 +955,7 @@ tls_device_reencrypt(struct sock *sk, struct tls_context *tls_ctx)else err =0 ; - data_len = rxm->full_len - cipher_sz->tag; + data_len = rxm->full_len - cipher_desc->tag;if (skb_pagelen (skb) > offset) { copy =min_t (int,skb_pagelen (skb) - offset, data_len);
@@ -1072,7 +1072,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) {struct tls_context *tls_ctx =tls_get_ctx (sk);struct tls_prot_info *prot = &tls_ctx->prot_info; -const struct tls_cipher_size_desc *cipher_sz; +const struct tls_cipher_desc *cipher_desc;struct tls_record_info *start_marker_record;struct tls_offload_context_tx *offload_ctx;struct tls_crypto_info *crypto_info;
@@ -1120,31 +1120,31 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx) rc = -EINVAL ; goto release_netdev; } - cipher_sz =get_cipher_size_desc (crypto_info->cipher_type); + cipher_desc =get_cipher_desc (crypto_info->cipher_type);/* Sanity-check the rec_seq_size for stack allocations */ -if (cipher_sz->rec_seq >TLS_MAX_REC_SEQ_SIZE ) { +if (cipher_desc->rec_seq >TLS_MAX_REC_SEQ_SIZE ) { rc = -EINVAL ; goto release_netdev; } prot->version = crypto_info->version; prot->cipher_type = crypto_info->cipher_type; - prot->prepend_size =TLS_HEADER_SIZE + cipher_sz->iv; - prot->tag_size = cipher_sz->tag; + prot->prepend_size =TLS_HEADER_SIZE + cipher_desc->iv; + prot->tag_size = cipher_desc->tag; prot->overhead_size = prot->prepend_size + prot->tag_size; - prot->iv_size = cipher_sz->iv; - prot->salt_size = cipher_sz->salt; - ctx->tx.iv =kmalloc (cipher_sz->iv + cipher_sz->salt,GFP_KERNEL ); + prot->iv_size = cipher_desc->iv; + prot->salt_size = cipher_desc->salt; + ctx->tx.iv =kmalloc (cipher_desc->iv + cipher_desc->salt,GFP_KERNEL );if (!ctx->tx.iv) { rc = -ENOMEM ; goto release_netdev; } -memcpy (ctx->tx.iv + cipher_sz->salt, iv, cipher_sz->iv); +memcpy (ctx->tx.iv + cipher_desc->salt, iv, cipher_desc->iv); - prot->rec_seq_size = cipher_sz->rec_seq; - ctx->tx.rec_seq =kmemdup (rec_seq, cipher_sz->rec_seq,GFP_KERNEL ); + prot->rec_seq_size = cipher_desc->rec_seq; + ctx->tx.rec_seq =kmemdup (rec_seq, cipher_desc->rec_seq,GFP_KERNEL );if (!ctx->tx.rec_seq) { rc = -ENOMEM ; goto free_iv;
net/tls/tls_device_fallback.c +21 -21
119 lines not on this page · raw message
net/tls/tls_main.c +10 -10
@@ -58,7 +58,7 @@ enum { TLS_NUM_PROTS, }; -#define CIPHER_SIZE_DESC (cipher) [cipher - TLS_CIPHER_MIN] = { \ +#define CIPHER_DESC (cipher) [cipher - TLS_CIPHER_MIN] = { \ .iv = cipher ## _IV_SIZE, \ .key = cipher ## _KEY_SIZE, \ .salt = cipher ## _SALT_SIZE, \
@@ -66,15 +66,15 @@ enum { .rec_seq = cipher ## _REC_SEQ_SIZE, \ } -const struct tls_cipher_size_desc tls_cipher_size_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ] = { -CIPHER_SIZE_DESC (TLS_CIPHER_AES_GCM_128 ), -CIPHER_SIZE_DESC (TLS_CIPHER_AES_GCM_256 ), -CIPHER_SIZE_DESC (TLS_CIPHER_AES_CCM_128 ), -CIPHER_SIZE_DESC (TLS_CIPHER_CHACHA20_POLY1305 ), -CIPHER_SIZE_DESC (TLS_CIPHER_SM4_GCM ), -CIPHER_SIZE_DESC (TLS_CIPHER_SM4_CCM ), -CIPHER_SIZE_DESC (TLS_CIPHER_ARIA_GCM_128 ), -CIPHER_SIZE_DESC (TLS_CIPHER_ARIA_GCM_256 ), +const struct tls_cipher_desc tls_cipher_desc[TLS_CIPHER_MAX +1 -TLS_CIPHER_MIN ] = { +CIPHER_DESC (TLS_CIPHER_AES_GCM_128 ), +CIPHER_DESC (TLS_CIPHER_AES_GCM_256 ), +CIPHER_DESC (TLS_CIPHER_AES_CCM_128 ), +CIPHER_DESC (TLS_CIPHER_CHACHA20_POLY1305 ), +CIPHER_DESC (TLS_CIPHER_SM4_GCM ), +CIPHER_DESC (TLS_CIPHER_SM4_CCM ), +CIPHER_DESC (TLS_CIPHER_ARIA_GCM_128 ), +CIPHER_DESC (TLS_CIPHER_ARIA_GCM_256 ), };static const struct proto *saved_tcpv6_prot;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2717/2857 tls: extend tls_cipher_desc to fully describe the ciphers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 176a3f50bc6a327c82c6b051b0bedd19917081a2 ]
- add nonce, usually equal to iv_size but not for chacha
- add offsets into the crypto_info for each field
- add algorithm name
- add offloadable flag
Also add helpers to access each field of a crypto_info struct described by a tls_cipher_desc.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls.h | 32 ++++++++++++++++++++++++++++++++ net/tls/tls_main.c | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 64 insertions(+), 9 deletions(-)
net/tls/tls.h +32 -0
@@ -51,11 +51,19 @@ SNMP_DEC_STATS((net)->mib.tls_statistics, field)struct tls_cipher_desc { +unsigned int nonce;unsigned int iv;unsigned int key;unsigned int salt;unsigned int tag;unsigned int rec_seq; +unsigned int iv_offset; +unsigned int key_offset; +unsigned int salt_offset; +unsigned int rec_seq_offset; +char *cipher_name; +bool offloadable; +size_t crypto_info; };#define TLS_CIPHER_MIN TLS_CIPHER_AES_GCM_128
@@ -70,6 +78,30 @@ static inline const struct tls_cipher_desc *get_cipher_desc(u16 cipher_type)return &tls_cipher_desc[cipher_type -TLS_CIPHER_MIN ]; } +static inline char *crypto_info_iv (struct tls_crypto_info *crypto_info, +const struct tls_cipher_desc *cipher_desc) +{ +return (char *)crypto_info + cipher_desc->iv_offset; +} + +static inline char *crypto_info_key (struct tls_crypto_info *crypto_info, +const struct tls_cipher_desc *cipher_desc) +{ +return (char *)crypto_info + cipher_desc->key_offset; +} + +static inline char *crypto_info_salt (struct tls_crypto_info *crypto_info, +const struct tls_cipher_desc *cipher_desc) +{ +return (char *)crypto_info + cipher_desc->salt_offset; +} + +static inline char *crypto_info_rec_seq (struct tls_crypto_info *crypto_info, +const struct tls_cipher_desc *cipher_desc) +{ +return (char *)crypto_info + cipher_desc->rec_seq_offset; +} +/* TLS records are maintained in 'struct tls_rec'. It stores the memory pages * allocated or mapped for each TLS record. After encryption, the records are
net/tls/tls_main.c +32 -9
55 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2718/2857 tls: get crypto_info size from tls_cipher_desc in do_tls_setsockopt_conf
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 5f309ade49c7068b1149ecf825c4c16e56a3b865 ]
We can simplify do_tls_setsockopt_conf using tls_cipher_desc. Also use get_cipher_desc's result to check if the cipher_type coming from userspace is valid.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls_main.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-)
net/tls/tls_main.c +8 -31
@@ -686,7 +686,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,struct tls_crypto_info *crypto_info;struct tls_crypto_info *alt_crypto_info;struct tls_context *ctx =tls_get_ctx (sk); -size_t optsize; +const struct tls_cipher_desc *cipher_desc;int rc =0 ;int conf;
@@ -738,46 +738,23 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, } } -switch (crypto_info->cipher_type) { -case TLS_CIPHER_AES_GCM_128 : - optsize =sizeof (struct tls12_crypto_info_aes_gcm_128 ); -break ; -case TLS_CIPHER_AES_GCM_256 : { - optsize =sizeof (struct tls12_crypto_info_aes_gcm_256 ); -break ; + cipher_desc =get_cipher_desc (crypto_info->cipher_type); +if (!cipher_desc) { + rc = -EINVAL ; + goto err_crypto_info; } -case TLS_CIPHER_AES_CCM_128 : - optsize =sizeof (struct tls12_crypto_info_aes_ccm_128 ); -break ; -case TLS_CIPHER_CHACHA20_POLY1305 : - optsize =sizeof (struct tls12_crypto_info_chacha20_poly1305 ); -break ; -case TLS_CIPHER_SM4_GCM : - optsize =sizeof (struct tls12_crypto_info_sm4_gcm ); -break ; -case TLS_CIPHER_SM4_CCM : - optsize =sizeof (struct tls12_crypto_info_sm4_ccm ); -break ; + +switch (crypto_info->cipher_type) {case TLS_CIPHER_ARIA_GCM_128 : -if (crypto_info->version !=TLS_1_2_VERSION ) { - rc = -EINVAL ; - goto err_crypto_info; - } - optsize =sizeof (struct tls12_crypto_info_aria_gcm_128 ); -break ;case TLS_CIPHER_ARIA_GCM_256 :if (crypto_info->version !=TLS_1_2_VERSION ) { rc = -EINVAL ; goto err_crypto_info; } - optsize =sizeof (struct tls12_crypto_info_aria_gcm_256 );break ; -default : - rc = -EINVAL ; - goto err_crypto_info; } -if (optlen != optsize) { +if (optlen != cipher_desc->crypto_info) { rc = -EINVAL ; goto err_crypto_info; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2719/2857 net: tls: Pass union tls_crypto_context pointer to memzero_explicit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit 0d9e699d3421b5db83eb0cb7a708882440ee78ef ]
Pass union tls_crypto_context pointer, rather than struct tls_crypto_info pointer, to memzero_explicit().
The address of the pointer is the same before and after.
But the new construct means that the size of the dereferenced pointer type matches the size being zeroed. Which aids static analysis.
As reported by Smatch:
.../tls_main.c:842 do_tls_setsockopt_conf() error: memzero_explicit() 'crypto_info' too small (4 vs 56)
No functional change intended.
Compile tested only.
Stable-dep-of: c43c1c24f3cd ("tls: avoid field-spanning write when copying crypto info")
--- net/tls/tls_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/tls/tls_main.c +6 -3
@@ -687,6 +687,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,struct tls_crypto_info *alt_crypto_info;struct tls_context *ctx =tls_get_ctx (sk);const struct tls_cipher_desc *cipher_desc; +union tls_crypto_context *crypto_ctx;int rc =0 ;int conf;
@@ -705,13 +706,15 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,return -EINVAL ;if (tx) { - crypto_info = &ctx->crypto_send.info; + crypto_ctx = &ctx->crypto_send; alt_crypto_info = &ctx->crypto_recv.info; }else { - crypto_info = &ctx->crypto_recv.info; + crypto_ctx = &ctx->crypto_recv; alt_crypto_info = &ctx->crypto_send.info; } + crypto_info = &crypto_ctx->info; +/* Currently we don't support set crypto info more than one time */ if (TLS_CRYPTO_INFO_READY (crypto_info))return -EBUSY ;
@@ -814,7 +817,7 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,return 0 ; err_crypto_info: -memzero_explicit (crypto_info,sizeof (union tls_crypto_context )); +memzero_explicit (crypto_ctx,sizeof (*crypto_ctx));return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2720/2857 tls: avoid field-spanning write when copying crypto info
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nandor Kracser <[email protected]>
[ Upstream commit c43c1c24f3cdc0d2d3f59e5686573ac3129637aa ]
do_tls_setsockopt_conf() copies the cipher-specific part of the crypto info to crypto_info + 1, where crypto_info points at the 4-byte info member of union tls_crypto_context. When optval is a kernel sockptr, copy_from_sockptr_offset() is a memcpy(), and FORTIFY_SOURCE bounds the destination by that member:
[ 6.948348] memcpy: detected field-spanning write (size 52) of single field "dst" at include/linux/sockptr.h:49 (size 0) [ 6.948480] WARNING: include/linux/sockptr.h:49 at tls_setsockopt+0x9b2/0xa30, CPU#1: init/1 [ 7.001355] Call Trace: [ 7.003146] do_sock_setsockopt+0xb0/0x190 [ 7.003975] __sys_setsockopt+0x76/0xc0 [ 7.005368] do_syscall_64+0xda/0x4b0
tls_setsockopt() gets a kernel sockptr whenever a cgroup setsockopt BPF program is attached, even one that leaves the option alone, because __cgroup_bpf_run_filter_setsockopt() passes optval on in a kernel buffer. With a no-op program on the root cgroup, a plain TLS_TX setsockopt() with AES-GCM-256 triggers the warning above on an x86_64 build with CONFIG_FORTIFY_SOURCE.
Copy into the union at offset sizeof(struct tls_crypto_info) instead. crypto_ctx already points at the right union for both the first set and the TLS 1.3 rekey (tmp) case, and the address is unchanged.
--- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tls/tls_main.c +2 -2
@@ -762,8 +762,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, goto err_crypto_info; } - rc =copy_from_sockptr_offset (crypto_info +1 , optval, -sizeof (*crypto_info), + rc =copy_from_sockptr_offset ((u8 *)crypto_ctx +sizeof (*crypto_info), + optval,sizeof (*crypto_info), optlen -sizeof (*crypto_info));if (rc) { rc = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2721/2857 net/sched: etf: initialise the sock_exterr_skb before filling it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 7076f684d5132e6a6145e1da2fa74771ecd052e5 ]
report_sock_error() clones the transmitted skb, overlays a struct sock_exterr_skb on its control block and fills in the seven struct sock_extended_err fields, but never clears addr_offset and port. skb_clone() copies cb[] verbatim, so the errqueue entry carries the TX skb's stale control block to the receive side, and the ipv4 error-queue reader trusts those bytes:
net/ipv4/ip_sockglue.c:556
sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset); sin->sin_port = serr->port;
The gate that is supposed to guard that read only asks whether an address was requested at all:
net/ipv4/ip_sockglue.c:484
return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP || serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
SO_EE_ORIGIN_TXTIME is neither ICMP nor LOCAL, so for sch_etf the gate is decided by serr->port alone -- by the stale byte pair. When it is non-zero the reader dereferences skb_network_header() + addr_offset with an arbitrary offset. On the TCP path cb[40..44) is not zero: the transmit path stored delivered_mstamp there (tcp_rate_skb_sent()), which is exactly where addr_offset/port sit in the arm64 struct layout.
Reached with an unmodified 7.3-rc4 (arm64, KASAN, in-tree modules): a TCP socket enables TX-timestamp error reporting (SO_TXTIME with SOF_TXTIME_REPORT_ERRORS), a sch_etf qdisc drops the packet, and a recvmsg() reaches ip_recv_error():
BUG: KASAN: slab-out-of-bounds in ip_recv_error+0x970/0xa0c Read of size 4 at addr ffff0000158ffdd5 by task A-227-A227-1_S2/113 ip_recv_error+0x970/0xa0c inet_recv_error+0x94/0xdc tcp_recvmsg+0x378/0x408 ... The buggy address is located 149 bytes to the right of allocated 704-byte region
Zero the whole overlay rather than the two fields individually: the errqueue entry is handed to the receive side as a self-contained record, which is what every other producer in the tree already does (sch_etf was the only error-queue producer that cleared neither field). This does not change what the in-tree selftest observes -- so_txtime.c reads only ee_origin/ee_errno/ee_code/ee_data/ee_info, never msg_name or sin_port.
--- net/sched/sch_etf.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_etf.c +1 -0
@@ -147,6 +147,7 @@ static void report_sock_error(struct sk_buff *skb, u32 err, u8 code)return ; serr =SKB_EXT_ERR (clone); +memset (serr,0 ,sizeof (*serr)); serr->ee.ee_errno = err; serr->ee.ee_origin =SO_EE_ORIGIN_TXTIME ; serr->ee.ee_type =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2722/2857 scsi: elx: libefc: Fix resource leak in efcport_init() error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit b4bd078b78c248d4263a1da7033cbe7a74ce0e12 ]
efcport_init() creates efc->node_pool and efc->node_dma_pool before allocating efc->els_io_pool. When the latter allocation fails it returns -ENOMEM without releasing the node dma pool or the node pool, leaking both. The caller efct_efclib_config() only logs the error and efct_device_attach() failure path never calls efcport_destroy(), so the resources are never freed.
Destroy node_dma_pool and node_pool before returning from the els_io_pool allocation failure path.
--- drivers/scsi/elx/libefc/efclib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/elx/libefc/efclib.c +2 -0
@@ -50,6 +50,8 @@ int efcport_init(struct efc *efc) sizeof(struct efc_els_io_req));if (!efc->els_io_pool) {efc_log_err (efc,"Can't allocate els io pool\n" ); +dma_pool_destroy (efc->node_dma_pool); +mempool_destroy (efc->node_pool);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2723/2857 bpf: Propagate btf_add_type() errors in btf_check_all_metas()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit fb2b27d214c3b88d926a303267dd83cfdb428b13 ]
btf_check_all_metas() ignores the return value of btf_add_type(), so a type that could not be registered is silently dropped while the loop keeps walking over the type section.
Both failure modes are reachable:
- -E2BIG. Once the types array reaches its capacity (BTF_MAX_TYPE), every following btf_add_type() fails the same way, so btf_check_all_metas() still returns 0 and the BTF object is created with btf->nr_types capped while hdr->type_len claims more records.
- -ENOMEM. btf->nr_types is not incremented and the array is not grown, so the next type is recorded at the slot of the dropped one and btf->types[] stays off by one with respect to the type ids for all remaining types. btf_type_by_id() then returns the wrong type for those ids for the whole lifetime of the object, and the last type is silently left unresolved.
Propagate the error so that the object is rejected instead.
--- kernel/bpf/btf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +5 -1
@@ -4643,6 +4643,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env)struct btf *btf = env->btf;struct btf_header *hdr;void *cur, *end; +int err; hdr = &btf->hdr; cur = btf->nohdr_data + hdr->type_off;
@@ -4657,7 +4658,10 @@ static int btf_check_all_metas(struct btf_verifier_env *env)if (meta_size <0 )return meta_size; -btf_add_type (env, t); + err =btf_add_type (env, t); +if (err) +return err; + cur += meta_size; env->log_type_id++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2724/2857 kernel/reboot: avoid potential deadlocks during suspension
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 66644b992f25f6a33775788c8b69a8bb3d41ad67 ]
Invoking reboot with LINUX_REBOOT_CMD_SW_SUSPEND causes kernel/reboot.c to acquire system_transition_mutex and invoke hibernate(). hibernate() calls lock_system_sleep(), which sets PF_NOFREEZE on current and attempts to acquire system_transition_mutex again, potentially hitting:
WARNING: possible recursive locking detected
--------------------------------------------
syz.3.5755/5950 is trying to acquire lock:ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: lock_system_sleep+0x49/0x70 kernel/power/main.c:71
but task is already holding lock:ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline] ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(system_transition_mutex);
lock(system_transition_mutex);
*** DEADLOCK ***
May be due to missing lock nesting notation
locks held by syz.3.5755/5950: 1, last CPU#0:
#0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline] #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738
Call Trace: lock_system_sleep+0x49/0x70 kernel/power/main.c:71 hibernate+0x162/0x680 kernel/power/hibernate.c:784 __do_sys_reboot kernel/reboot.c:816 [inline]
Move the suspension operation outside the scope protected by lock system_transition_mutex.
--- kernel/reboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/reboot.c +2 -2
@@ -775,8 +775,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,#ifdef CONFIG_HIBERNATION case LINUX_REBOOT_CMD_SW_SUSPEND : - ret =hibernate (); -break ; +mutex_unlock (&system_transition_mutex); +return hibernate ();#endif default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2725/2857 profiling: fix sampling step on 64-bit big-endian systems
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit b1d68946a08313895f352af5336623d29739c299 ]
read_profile() stores the sampling step in an unsigned long but copies only four bytes to userspace. On 64-bit big-endian systems (not common obviously), this copies the upper 32 bits and discards the rest, causing /proc/profile to report zero for normal shift values.
Cast to unsigned int so we get the correct 4 bytes, while keeping the shift calculation in unsigned long.
A small C reproducer under qemu-s390x reproduced this and proved the fix works for prof_shift=2.
--- kernel/profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/profile.c +1 -1
@@ -390,7 +390,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)unsigned long p = *ppos;ssize_t read;char *pnt; -unsigned long sample_step =1UL << prof_shift; +unsigned int sample_step = (unsigned int )(1UL << prof_shift);profile_flip_buffers ();if (p >= (prof_len+1 )*sizeof (unsigned int ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2726/2857 tools/cgroup: sum shrinker object counts across NUMA nodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ren Tamura <[email protected]>
[ Upstream commit ae2514c95518b39b36fa463d855c74f29c91d064 ]
Each row of a memcg-aware shrinker's debugfs count file contains the cgroup ID followed by one object count per NUMA node. memcg_shrinker.py uses only the first count when sorting and displaying entries.
This undercounts objects on NUMA systems. An entry with counts of 0 and 23 is treated as zero and omitted from the output, even though its total is 23.
Sum all count fields after the cgroup ID so that the displayed totals and sort order account for every node. Single-node input retains the same result.
--- tools/cgroup/memcg_shrinker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/cgroup/memcg_shrinker.py +1 -1
@@ -32,7 +32,7 @@ def scan_shrinkers(shrinker_debugfs): items = line.split(' ') ino = int(items[0]) # (count, shrinker, memcg ino) - shrinkers.append((int(items[1]), shrinker, ino)) + shrinkers.append((sum(map(int, items[1:])), shrinker, ino)) return shrinkers
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2727/2857 netlink: fix out-of-bounds bitmap access clearing stale mc groups
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 6430fb7f1cc4e329e386521b7b208df443de92f2 ]
netlink_realloc_groups() sizes nlk->groups to the number of groups that exist at bind/ADD_MEMBERSHIP time. When more multicast groups are registered later (e.g. a new genl family), existing sockets keep their smaller bitmap.
When clearing a multicast group of a departing family, __netlink_clear_multicast_users() runs netlink_update_socket_mc() on each socket on mc_list, which does test_bit()/__assign_bit() on group - 1 with no regard to nlk->ngroups. Skip sockets whose bitmap predates the group: such a socket can never have joined it.
The overflow windows differ per architecture, both needing privileged module (un)loading. On 32-bit kernels the ~54 dynamically allocated genl groups already exceed the initial 32-bit bitmap, so the table can grow there directly. On 64-bit kernels the same in-tree set fits the initial 64-bit bitmap only while allocation stays contiguous:genl_allocate_reserve_groups() takes the first free contiguous range and unregister does not compact, so an unload/reload sequence can fragment the ~59 free IDs until no fitting range remains, forcing the table past 64 bits and reaching the same stale-bitmap overflow on the next family teardown.
This issue was discovered by Tencent CodeBuddy Security.
--- net/netlink/af_netlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +5 -1
@@ -2117,8 +2117,12 @@ void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group)struct netlink_table *tbl = &nl_table[ksk->sk_protocol];struct hlist_node *tmp; -sk_for_each_bound_safe (sk, tmp, &tbl->mc_list) +sk_for_each_bound_safe (sk, tmp, &tbl->mc_list) { +/* bitmap predates the group, can't be a member */ +if (group -1 >=nlk_sk (sk)->ngroups) +continue ;netlink_update_socket_mc (nlk_sk (sk), group,0 ); + } } struct nlmsghdr *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2728/2857 ceph: remove unused field `i_cap_migration_resv`
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
[ Upstream commit a200e12135c96893f7c29bdf97f46868132f695d ]
This field was added 17 years ago by commit de57606c23afd ("ceph:
client types") but it was never used.
This reduces the size of struct ceph_inode_info by 8 bytes.
--- fs/ceph/super.h | 1 - 1 file changed, 1 deletion(-)
fs/ceph/super.h +0 -1
@@ -405,7 +405,6 @@ struct ceph_inode_info {wait_queue_head_t i_cap_wq;/* threads waiting on a capability */ unsigned long i_hold_caps_max;/* jiffies */ struct list_head i_cap_delay_list;/* for delayed cap release to mds */ -struct ceph_cap_reservation i_cap_migration_resv;struct list_head i_cap_snaps;/* snapped state pending flush to mds */ struct ceph_snap_context *i_head_snapc;/* set if wr_buffer_head > 0 or dirty|flushing caps */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2729/2857 ceph: mark the superblock active after mounting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit 32eacfae3b16f6a9c0c20f946115abf5a091c922 ]
ceph_get_tree() calls sget_fc() directly and so never goes through vfs_get_super(), which is what sets SB_ACTIVE after fill_super for filesystems that use it. Before commit 82995cc6c5ae ("libceph, rbd,
ceph: convert to use the new mount API") the flag used to be set by get_sb_nodev(), which did this for ceph, but the conversion dropped it.
SB_ACTIVE is required for iput_final() to retain an inode on the inode LRU instead of evicting it once its last reference goes away. This has gone unnoticed because ceph sets inode_just_drop() for ->drop_inode, which always asks for eviction, so the retain branch in iput_final() was never reachable. The next patch makes ->drop_inode() able to retain inodes, and that needs the flag to actually work.
Set it once the mount is up, like nfs_get_tree() does.
--- fs/ceph/super.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ceph/super.c +9 -0
@@ -1267,6 +1267,15 @@ static int ceph_get_tree(struct fs_context *fc)dout ("root %p inode %p ino %llx.%llx\n" , res,d_inode (res),ceph_vinop (d_inode (res))); fc->root = fsc->sb->s_root; + +/* +* The mount is up. sget_fc() leaves SB_ACTIVE unset, and, unlike +* filesystems that go through vfs_get_super(), nothing else sets +* it here, so iput_final() would always evict an inode whose +* ->drop_inode() asks to retain it. Set it like nfs_get_tree() +* does. +*/ + sb->s_flags |=SB_ACTIVE ;return 0 ; out_splat:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2730/2857 ceph: dont keep a mon_addr string that failed to parse
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 6c82bff8561f4c20dc0113f81cb2f6e6e2b4cf70 ]
ceph_parse_mon_addr() stores the string in fsopt->mon_addr before handing it to ceph_parse_mon_ips(), and then returns that function's error. So after a mon_addr= that does not parse, fsconfig() reports the failure but the mount context keeps the rejected string.
That matters because ceph_get_tree() uses fsopt->mon_addr as the "monitor addresses were supplied" test:
if (fsopt->new_dev_syntax && !fsopt->mon_addr) return invalfc(fc, "No monitor address");
Userspace is free to ignore the error from fsconfig(FSCONFIG_SET_STRING) and go straight to FSCONFIG_CMD_CREATE. The check then passes on a value that was rejected, and the mount continues with ceph_options::num_mon still 0 - which is how syzbot reached the BUG_ON() in pick_new_mon() fixed by the previous patch.
Parse first and commit only on success. A failed mon_addr= now leaves any previously accepted value in place instead of replacing it with one that does not parse.
--- fs/ceph/super.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/ceph/super.c +7 -2
@@ -391,13 +391,18 @@ static int ceph_parse_mon_addr(struct fs_parameter *param, {struct ceph_parse_opts_ctx *pctx = fc->fs_private;struct ceph_mount_options *fsopt = pctx->opts; +int ret; + + ret =ceph_parse_mon_ips (param->string,strlen (param->string), + pctx->copts, fc->log.log,'/' ); +if (ret) +return ret;kfree (fsopt->mon_addr); fsopt->mon_addr = param->string; param->string =NULL ; -return ceph_parse_mon_ips (fsopt->mon_addr,strlen (fsopt->mon_addr), - pctx->copts, fc->log.log,'/' ); +return 0 ; } static int ceph_parse_mount_param(struct fs_context *fc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2731/2857 libceph: reject bad connect_seq in msgr1 READY reply
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit 6dfc1b1a99da4909aee07a906352be5c3fc9baba ]
process_connect() WARN_ON()s when the peer's READY/SEQ reply carries a connect_seq other than ours + 1. That value comes off the wire, so a misbehaving or malicious server can trigger the warning at will (and panic machines running with panic_on_warn).
Check it before touching connection state and fail the connection with a protocol error instead, like the other bad-reply cases here.
--- net/ceph/messenger_v1.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/ceph/messenger_v1.c +6 -2
@@ -897,6 +897,12 @@ static int process_connect(struct ceph_connection *con)return -1 ; } +if (le32_to_cpu (con->v1.in_reply.connect_seq) != + con->v1.connect_seq +1 ) { + con->error_msg ="protocol error, bad connect_seq" ; +return -1 ; + } +WARN_ON (con->state !=CEPH_CON_S_V1_CONNECT_MSG ); con->state =CEPH_CON_S_OPEN ; con->v1.auth_retry =0 ;/* we authenticated; clear flag */
@@ -908,8 +914,6 @@ static int process_connect(struct ceph_connection *con) con->v1.peer_global_seq,le32_to_cpu (con->v1.in_reply.connect_seq), con->v1.connect_seq); -WARN_ON (con->v1.connect_seq != -le32_to_cpu (con->v1.in_reply.connect_seq));if (con->v1.in_reply.flags &CEPH_MSG_CONNECT_LOSSY )ceph_con_flag_set (con,CEPH_CON_F_LOSSYTX );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2732/2857 block: advance iterator after copy-in for SG_DXFER_TO_FROM_DEV
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: TJ Adams <[email protected]>
[ Upstream commit 82e72ea18d0af724914c31a1f274c1aef452aad0 ]
When a passthrough request uses transfer direction SG_DXFER_TO_FROM_DEV, bio_copy_user_iov() sets up a temporary iterator iter2 with data_source = ITER_SOURCE to copy user data into the bio pages before execution.
bio_copy_from_iter(bio, &iter2) copies the data and advances iter2, but the original iter is never advanced. Consequently, iov_iter_count(&i) remains non-zero in the caller loop in blk_rq_map_user_iov():
i = *iter;
do {
if (copy)
ret = bio_copy_user_iov(rq, map_data, &i, gfp_mask);
...
} while (iov_iter_count(&i));Because i is never advanced, blk_rq_map_user_iov() loops indefinitely, continually allocating bios and consuming map_data pages until it exhausts pages and fails with -EINVAL.
Fix this by calling iov_iter_advance(iter, bio->bi_iter.bi_size) in the map_data && map_data->from_user branch after bio_copy_from_iter().
--- block/blk-map.c | 1 + 1 file changed, 1 insertion(+)
block/blk-map.c +1 -0
@@ -216,6 +216,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data, ret =bio_copy_from_iter (bio, &iter2);if (ret) goto cleanup; +iov_iter_advance (iter, bio->bi_iter.bi_size); }else {if (bmd->is_our_pages)zero_fill_bio (bio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2733/2857 thermal: Fix CPU mask truncation in power limit trace event
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 82c9c94f54a444a686e926c872dae4b198d1036f ]
num_possible_cpus() counts CPUs, but CPU IDs need not be contiguous. Using it to size the thermal_power_cpu_limit bitmap can omit CPUs with higher IDs. For example, possible CPUs 0 and 64 produce an eight-byte bitmap on a 64-bit system, dropping CPU 64.
Use nr_cpumask_bits for both sizing and copying the bitmap.
--- include/trace/events/thermal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/trace/events/thermal.h +2 -2
@@ -117,7 +117,7 @@ TRACE_EVENT(thermal_power_cpu_limit,TP_ARGS (cpus, freq, cdev_state, power),TP_STRUCT__entry ( - __bitmask(cpumask, num_possible_cpus()) + __bitmask(cpumask, nr_cpumask_bits) __field(unsigned int, freq ) __field(unsigned long, cdev_state) __field(u32, power )
@@ -125,7 +125,7 @@ TRACE_EVENT(thermal_power_cpu_limit,TP_fast_assign (__assign_bitmask (cpumask,cpumask_bits (cpus), - num_possible_cpus()); + nr_cpumask_bits); __entry->freq = freq; __entry->cdev_state = cdev_state; __entry->power = power;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2734/2857 ASoC: codecs: wsa883x: disable runtime PM on unbind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
[ Upstream commit ea63182d71956dc33c6f08dc4171f1052f8409a9 ]
Probe enables runtime PM but nothing disables it on unbind, or when registering the component fails. A pending autosuspend can then run wsa883x_runtime_suspend() after the devm-managed regmap is freed, and dereference NULL, as seen on wsa884x.
Use devm_pm_runtime_enable() so runtime PM is disabled before the regmap is freed.
--- sound/soc/codecs/wsa883x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/wsa883x.c +3 -1
@@ -1449,7 +1449,9 @@ static int wsa883x_probe(struct sdw_slave *pdev,pm_runtime_use_autosuspend (dev);pm_runtime_mark_last_busy (dev);pm_runtime_set_active (dev); -pm_runtime_enable (dev); + ret =devm_pm_runtime_enable (dev); +if (ret) + goto err; ret = devm_snd_soc_register_component(&pdev->dev, &wsa883x_component_drv,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2735/2857 ASoC: codecs: es*: Modify the registers related to ALC RECOVERY
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit dd64271fe1b935252cf454a72a558cbdb7be57c5 ]
The register related to "ALC Capture Recovery Level" is ES8326_ALC_RECOVERY, not ES8326_ALC_LEVEL.
--- sound/soc/codecs/es8326.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/es8326.c +1 -1
@@ -91,7 +91,7 @@ static const struct snd_kcontrol_new es8326_snd_controls[] = {SOC_SINGLE_TLV ("ADC PGA Gain Volume" ,ES8326_PGAGAIN ,0 ,10 ,0 , adc_analog_pga_tlv),SOC_SINGLE_TLV ("ADC Ramp Rate" ,ES8326_ADC_RAMPRATE ,0 ,0x0f ,0 , softramp_rate),SOC_SINGLE ("ALC Capture Switch" ,ES8326_ALC_RECOVERY ,3 ,1 ,0 ), -SOC_SINGLE_TLV ("ALC Capture Recovery Level" ,ES8326_ALC_LEVEL , +SOC_SINGLE_TLV ("ALC Capture Recovery Level" ,ES8326_ALC_RECOVERY ,0 ,4 ,0 , drc_recovery_tlv),SOC_ENUM ("ALC Capture Winsize" , alc_winsize), SOC_SINGLE_TLV("ALC Capture Target Level", ES8326_ALC_LEVEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2736/2857 net/sched: gred: keep the qdisc lock while updating the table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 306f788134a21a3d60c1eb872d0ec0ce7c7e09bc ]
gred_change_table_def() publishes table->DPs/def/red_flags under sch_tree_lock(), drops the lock, and then keeps writing state the datapath reads without it:
- gred_enable_rio_mode()/gred_disable_rio_mode()/gred_disable_wred_mode()
set/clear table->flags;
- the red_flags_changed loop writes table->tab[i]->red_flags;
- the shadowed-VQ loop frees table->tab[i] and clears the slot.
gred_enqueue() and gred_dequeue() read those same fields (test_bit on table->flags, q->red_flags, t->tab[]/t->DPs) under the same root lock on another CPU, so the post-unlock writes race with the enqueue path:
BUG: KCSAN: data-race in gred_change_table_def [sch_gred] / gred_enqueue [sch_gred] read (marked) to 0xffff000007ad3b00 of 8 bytes by task 110 on cpu 0: gred_enqueue+0x88/0xc60 [sch_gred] dev_qdisc_enqueue+0x4c/0x19c __dev_queue_xmit+0x10a4/0x1ea4
The comment justifying the early unlock only covers the DP-vs-DPs check, which the shadowed-VQ free loop relies on; it does not cover the scalar mode bits and per-VQ red_flags written afterwards. Move the unlock below those updates so everything the datapath reads is published under the lock that protects it.
--- net/sched/sch_gred.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
net/sched/sch_gred.c +9 -7
@@ -442,13 +442,6 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps, red_flags_changed = table->red_flags != sopt->flags; table->red_flags = sopt->flags; -/* -* Every entry point to GRED is synchronized with the above code -* and the DP is checked against DPs, i.e. shadowed VQs can no -* longer be found so we can unlock right here. -*/ -sch_tree_unlock (sch); -if (sopt->grio) {gred_enable_rio_mode (table);gred_disable_wred_mode (table);
@@ -474,6 +467,15 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps, } } +/* +* Keep the lock until every field the datapath reads (the +* RIO/WRED mode bits, the per-VQ red_flags and the tab[] slots) +* has been updated: gred_enqueue()/gred_dequeue() read them under +* the same lock, so publishing them after the unlock races with +* the enqueue path. +*/ +sch_tree_unlock (sch); +gred_offload (sch,TC_GRED_REPLACE );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2737/2857 net/sched: act_api: inherit filter offload flags only on new actions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Cassen <[email protected]>
[ Upstream commit 9463e8d8c6922a5aa87f7e4fe6deb4f16925d498 ]
tcf_action_init() gives the skip_sw and skip_hw flags of a filter to the actions it binds. An action that another filter created gets them too, they then apply to every filter that uses this action. When a skip_sw filter reuses the action of a software filter, the software filter silently stops running it. This happens even when the filter add fails on a later action. A skip_hw filter likewise prevents a later filter without flags from reusing the action.
Give the flags only to the actions that the filter creates. The mismatch check still rejects a filter that reuses an action with a flag that the filter does not have.
Discovered by manual code inspection after the Sashiko AI review [1] of a tunnel_key patch questioned how actions get the filter flags. Reproduced on netdevsim without kernel changes. The egress filter below runs in software only, since netdevsim offloads only ingress filters. Once the skip_sw filter reuses its drop action, the last command shows skip_sw on this action and the egress filter stops dropping packets:
ethtool -K eth0 hw-tc-offload on
tc qdisc add dev eth0 clsact
tc filter add dev eth0 egress protocol ip flower dst_ip 192.0.2.1 \
action gact drop index 1
tc filter add dev eth0 ingress protocol ip flower skip_sw \
dst_ip 192.0.2.2 action gact drop index 1
tc actions get action gact index 1
Tested with the reproducer and the tc-testing action, matchall and flower tests.
--- net/sched/act_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/act_api.c +3 -0
@@ -1512,6 +1512,9 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, err = -EINVAL ; goto err; } +/* Other filters share an existing action */ +if (init_res[i -1 ] !=ACT_P_CREATED ) +continue ;if (skip_sw) act->tcfa_flags |=TCA_ACT_FLAGS_SKIP_SW ;if (skip_hw)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2738/2857 net/sched: taprio: unwind the netdevice notifier if register_qdisc() fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit c5234f89d7cb311880ef218cb7a969794a106678 ]
taprio_module_init() registers taprio_device_notifier and then returns register_qdisc()'s error directly. When register_qdisc() fails the notifier stays registered, but the loader's failure path frees the module image without ever calling the __exit function, so netdev_chain is left pointing at taprio_device_notifier.notifier_call -- a function pointer that lives in text that has just been freed.
register_qdisc() has two failure returns: -EEXIST (duplicate .id) and -EINVAL (malformed cl_ops). taprio_class_ops satisfies every checked implication, so -EINVAL is unreachable and -EEXIST is the only reachable failure; it needs a pre-existing "taprio" entry in qdisc_base. In-tree that is reachable only through bpf_qdisc_reg() (CONFIG_NET_SCH_BPF); a module calling the exported register_qdisc() reaches it as well.
Once the notifier is left dangling, the next netdevice event that walks netdev_chain calls through the stale pointer:
BUG: KASAN: vmalloc-out-of-bounds in notifier_call_chain+0x650/0xb5c Read of size 8 at addr ffff80001fc5ab08 by task ip/110 notifier_call_chain+0x650/0xb5c raw_notifier_call_chain+0x34/0x64 call_netdevice_notifiers_info+0xa8/0x198 __dev_close_many+0xe0/0x800 ... >ffff80001fc5ab00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
The shadow row is all f8 (KASAN_VMALLOC_INVALID): the read lands in vmalloc memory that was poisoned when the module image was freed, and the indirect call is unguarded because the only check, func_ptr_is_kernel_text(), is compiled out unless CONFIG_DEBUG_NOTIFIERS.
Mirror the sibling sch_cbs.c and act_mirred.c, which unwind the notifier on this failure path.
--- net/sched/sch_taprio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/sch_taprio.c +5 -1
@@ -2171,7 +2171,11 @@ static int __init taprio_module_init(void)if (err)return err; -return register_qdisc (&taprio_qdisc_ops); + err =register_qdisc (&taprio_qdisc_ops); +if (err) +unregister_netdevice_notifier (&taprio_device_notifier); + +return err; } static void __exit taprio_module_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2739/2857 net: stmmac: fix rx checksum offload with extended descriptors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: alex todadze <[email protected]>
[ Upstream commit 72ee27b97986f4d331fe1c26e4333f12738d982f ]
With extended descriptors, bit 0 of RDES0 is the Extended Status Available flag. enh_desc_get_rx_status() still reads it as the payload checksum error bit of the checksum offload table, so every IP frame that has extended status is reported as csum_none and its checksum is verified again in software.
When extended status is available, take the result from RDES4 instead. A TCP, UDP or ICMP payload with no IP header error, no payload error and no checksum bypass is a good frame. Everything else keeps the status from RDES0. Since RDES4 now decides the checksum status, read it after the own bit with dma_rmb(). While at it, fix the IP payload type mask, which covered bits 6:2 instead of 2:0 and had no users.
Tested on a Siflower SF19A2890 (GMAC 3.70) with the board as the iperf3 endpoint. TCP receive goes from 326 to 378 Mbit/s with one stream and from 259 to 329 Mbit/s with four, and CPU use while receiving 200 Mbit/s drops from 26.6% to 21.5%. In stmmac_rx(), frames with a bad TCP, UDP or ICMP checksum, over IPv4 and IPv6 and including fragmented UDP, are still passed up as CHECKSUM_NONE and dropped by the stack.
--- drivers/net/ethernet/stmicro/stmmac/descs.h | 6 ++++- .../net/ethernet/stmicro/stmmac/enh_desc.c | 25 +++++++++++++++++-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 ++--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++++---- 4 files changed, 45 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/descs.h +5 -1
@@ -123,7 +123,7 @@#define ETDES1_BUFFER2_SIZE_SHIFT 16/* Extended Receive descriptor definitions */ -#define ERDES4_IP_PAYLOAD_TYPE_MASK GENMASK(6, 2) +#define ERDES4_IP_PAYLOAD_TYPE_MASK GENMASK(2, 0)#define ERDES4_IP_HDR_ERR BIT(3)#define ERDES4_IP_PAYLOAD_ERR BIT(4)#define ERDES4_IP_CSUM_BYPASSED BIT(5)
@@ -154,6 +154,10 @@#define RDES_PTP_SIGNALING 0xa#define RDES_PTP_PKT_RESERVED_TYPE 0xf +#define RDES_EXT_PAYLOAD_UDP 0x1 +#define RDES_EXT_PAYLOAD_TCP 0x2 +#define RDES_EXT_PAYLOAD_ICMP 0x3 +/* Basic descriptor structure for normal and alternate descriptors */ struct dma_desc {__le32 des0;
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +23 -2
@@ -114,8 +114,25 @@ static int enh_desc_coe_rdes0(int ipc_err, int type, int payload_err)return ret; } -static void enh_desc_get_ext_status (struct stmmac_extra_stats *x, -struct dma_extended_desc *p) +static int enh_desc_ext_rx_csum (u32 rdes0,u32 rdes4,int status) +{ +u32 type =FIELD_GET (ERDES4_IP_PAYLOAD_TYPE_MASK , rdes4); + +if (status != csum_none || !(rdes0 &RDES0_FRAME_TYPE )) +return status; +if (!(rdes4 & (ERDES4_IPV4_PKT_RCVD |ERDES4_IPV6_PKT_RCVD )) || + (rdes4 & (ERDES4_IP_HDR_ERR |ERDES4_IP_PAYLOAD_ERR | +ERDES4_IP_CSUM_BYPASSED ))) +return status; +if (type !=RDES_EXT_PAYLOAD_UDP && type !=RDES_EXT_PAYLOAD_TCP && + type !=RDES_EXT_PAYLOAD_ICMP ) +return status; + +return good_frame; +} + +static int enh_desc_get_ext_status (struct stmmac_extra_stats *x, +struct dma_extended_desc *p,int status) {unsigned int rdes0 =le32_to_cpu (p->basic.des0);unsigned int rdes4 =le32_to_cpu (p->des4);
@@ -175,7 +192,11 @@ static void enh_desc_get_ext_status(struct stmmac_extra_stats *x, x->l4_filter_match++;if ((rdes4 &ERDES4_L3_L4_FILT_NO_MATCH_MASK ) >>26 ) x->l3_l4_filter_no_match++; + + status =enh_desc_ext_rx_csum (rdes0, rdes4, status); } + +return status; } static int enh_desc_get_rx_status(struct stmmac_extra_stats *x,
drivers/net/ethernet/stmicro/stmmac/hwif.h +3 -3
@@ -68,8 +68,8 @@ struct stmmac_desc_ops {/* Return the reception status looking at the RDES1 */ int (*rx_status)(struct stmmac_extra_stats *x,struct dma_desc *p); -void (*rx_extended_status)(struct stmmac_extra_stats *x, -struct dma_extended_desc *p); +int (*rx_extended_status)(struct stmmac_extra_stats *x, +struct dma_extended_desc *p,int status);/* Set tx timestamp enable bit */ void (*enable_tx_timestamp) (struct dma_desc *p);/* get tx timestamp status */
@@ -128,7 +128,7 @@ struct stmmac_desc_ops { #define stmmac_rx_status(__priv, __args...) \ stmmac_do_callback(__priv, desc, rx_status, __args) #define stmmac_rx_extended_status(__priv, __args...) \ - stmmac_do_void_callback(__priv, desc, rx_extended_status, __args) + stmmac_do_callback(__priv, desc, rx_extended_status, __args) #define stmmac_enable_tx_timestamp(__priv, __args...) \ stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args) #define stmmac_get_tx_timestamp_status(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +14 -5
@@ -5174,9 +5174,13 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)if (!buf->xdp)break ; -if (priv->extend_desc) -stmmac_rx_extended_status (priv, &priv->xstats, - rx_q->dma_erx + entry); +if (priv->extend_desc) { +/* Read the extended status after the own bit */ +dma_rmb (); + status =stmmac_rx_extended_status (priv, &priv->xstats, + &rx_q->dma_erx[entry], + status); + }if (unlikely (status == discard_frame)) {xsk_buff_free (buf->xdp); buf->xdp =NULL ;
@@ -5363,8 +5367,13 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)prefetch (np); -if (priv->extend_desc) -stmmac_rx_extended_status (priv, &priv->xstats, rx_q->dma_erx + entry); +if (priv->extend_desc) { +/* Read the extended status after the own bit */ +dma_rmb (); + status =stmmac_rx_extended_status (priv, &priv->xstats, + &rx_q->dma_erx[entry], + status); + }if (unlikely (status == discard_frame)) {page_pool_recycle_direct (rx_q->page_pool, buf->page); buf->page =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2740/2857 ipmr: clear skb->cb[] in reg_vif_xmit()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 389952e8776a4663044df2ae3e8987a9e81964cf ]
reg_vif_xmit() hands the skb to ipmr_cache_report() as an IGMPMSG_WHOLEPKT report. When the mroute socket has IP_PKTINFO enabled, ipmr_cache_report() calls ipv4_pktinfo_prepare() on the original skb, which reads skb->cb[] as IPCB.
By the time the pimreg device transmits the packet, skb->cb[] is not IPCB anymore: qdisc_pkt_len_init() overwrites IPCB(skb)->iif with qdisc_skb_cb(skb)->pkt_len, and any qdisc installed on the device or a tc BPF program writing skb->cb[] fills the area holding the IP options and IPCB(skb)->flags.
For locally generated packets routed out pimreg (they carry an rtable dst), the mroute socket can therefore receive a bogus ipi_ifindex (the packet length), and the l3mdev slave test in ipv4_pktinfo_prepare() is driven by stale qdisc data.
Clear IPCB before building the report, as done for IPv6 in commit 238164201431 ("ip6mr: clear skb->cb[] in reg_vif_xmit()"). The skb is freed right after, so nothing else depends on its control block.
--- net/ipv4/ipmr.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv4/ipmr.c +5 -0
@@ -529,6 +529,11 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)DEV_STATS_ADD (dev, tx_bytes, skb->len);DEV_STATS_INC (dev, tx_packets); +/* skb->cb[] holds qdisc/tc state at this point, not IPCB. +* ipmr_cache_report() reads it as IPCB to build IP_PKTINFO. +*/ +memset (IPCB (skb),0 ,sizeof (*IPCB (skb))); +/* Pairs with WRITE_ONCE() in vif_add() and vif_delete() */ ipmr_cache_report (mrt, skb,READ_ONCE (mrt->mroute_reg_vif_num),IGMPMSG_WHOLEPKT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2741/2857 clk: lmk04832: Handle reset GPIO lookup errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5c7c0cbf81bba69695efa12e451f0f2ecd4b92a5 ]
devm_gpiod_get_optional() may return -EPROBE_DEFER or other errors, but lmk04832_probe() currently ignores them.
Check the return value and propagate errors from the reset GPIO lookup.
--- drivers/clk/clk-lmk04832.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/clk-lmk04832.c +3 -0
@@ -1404,6 +1404,9 @@ static int lmk04832_probe(struct spi_device *spi) lmk->reset_gpio =devm_gpiod_get_optional (&spi->dev,"reset" ,GPIOD_OUT_LOW ); +if (IS_ERR (lmk->reset_gpio)) +return dev_err_probe (lmk->dev,PTR_ERR (lmk->reset_gpio), +"failed to get reset GPIO\n" ); lmk->dclk =devm_kcalloc (lmk->dev, info->num_channels >>1 ,sizeof (struct lmk_dclk ),GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2742/2857 clk: cdce925: Size the PLL child name buffer for any int
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit e9e6b4dc303dff637ef725aca4f4968d7600798b ]
The PLL child node name is built from "PLL%d" in a 6 byte stack buffer. The PLL index is bounded by the chip's num_plls, at most 4, but GCC cannot see that bound and, with W=1, warns that the formatted string may not fit.
Make the buffer large enough to hold any int and use snprintf() with sizeof() so the size stays tied to the declaration.
--- drivers/clk/clk-cdce925.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/clk-cdce925.c +7 -2
@@ -655,7 +655,12 @@ static int cdce925_probe(struct i2c_client *client)int i;int err;struct device_node *np_output; -char child_name[6 ]; +/* +* The PLL number isn't a compile time constant so GCC can't infer +* the number. Make the stack buffer large enough to hold any int +* so Wformat-truncation does not complain. +*/ +char child_name[15 ];struct regmap_config config = { .name ="configuration0" , .reg_bits =8 ,
@@ -727,7 +732,7 @@ static int cdce925_probe(struct i2c_client *client)dev_err (&client->dev,"Failed register PLL %d\n" , i); goto error; } -sprintf (child_name,"PLL%d" , i+1 ); +snprintf (child_name,sizeof (child_name),"PLL%d" , i +1 ); np_output =of_get_child_by_name (node, child_name);if (!np_output)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2743/2857 tipc: fix refcount panic in tipc_rcv() when receiving shared skb
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tung Nguyen <[email protected]>
[ Upstream commit 5308a2049b764aa55513c90c68933abf596c51d2 ]
TIPC assumes that the received skb is not shared with other users. However, syzbot reports a bug triggered by receiving a shared skb:
...
RIP: 0010:pskb_expand_head+0x135a/0x13a0 net/core/skbuff.c:2308 __pskb_pull_tail+0x111/0x1870 net/core/skbuff.c:2890 skb_cow_data+0x2ed/0xc50 net/core/skbuff.c:5398 tipc_aead_decrypt net/tipc/crypto.c:892 [inline] tipc_crypto_rcv+0x346/0x23d0 net/tipc/crypto.c:1843 tipc_rcv+0x4b7/0x1040 net/tipc/node.c:2119 tipc_l2_rcv_msg+0x2d9/0x470 net/tipc/bearer.c:669 deliver_ptype_list_skb net/core/dev.c:2533 [inline]
...
The root cause is that local delivery hooks in the kernel (e.g., deliver_skb()) may increment the skb's reference count (users) before TIPC processes it on ingress.
Fix this by calling skb_share_check() to ensure exclusive ownership before passing the skb to tipc_rcv(). As TIPC needs to modify the skb's data, the cloned skb needs to be uncloned when needed. This can be addressed in separate patch.
--- net/tipc/bearer.c | 4 ++++ 1 file changed, 4 insertions(+)
net/tipc/bearer.c +4 -0
@@ -661,6 +661,10 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev, {struct tipc_bearer *b; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) +return NET_RX_DROP ; +rcu_read_lock (); b =rcu_dereference (dev->tipc_ptr) ?:rcu_dereference (orig_dev->tipc_ptr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2744/2857 pppoe: drop discovery frames with no MAC header
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 406bf2dc8d6d3e93fdae0b66d2ae99b6b62e479c ]
Commit 8540827ebac6 ("pppoe: fix reception of frames with no mac header") drops PPPoE session frames with no MAC header to avoid reading uninitialized memory.
Apply the same to PPPoE discovery frames, as both functions read eth_hdr(skb)->h_source.
Found by LLM static analysis, and reproduced using the same TUN injection as described in the mentioned commit.
--- drivers/net/ppp/pppoe.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ppp/pppoe.c +3 -0
@@ -496,6 +496,9 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->pkt_type !=PACKET_HOST ) goto abort; +if (skb_mac_header_len (skb) <ETH_HLEN ) + goto abort; +if (!pskb_may_pull (skb,sizeof (struct pppoe_hdr ))) goto abort;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2745/2857 net: atlantic: Unregister before clearing RXNFC rules
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 13b364c765e69db1f8446399d8db0b331c23b50c ]
aq_pci_remove() clears the driver's RXNFC rule list before unregistering the netdevice. Until unregister_netdev() returns, ethtool operations can still call aq_get_rxnfc_rule(), aq_get_rxnfc_all_rules(), aq_add_rxnfc_rule(), or aq_del_rxnfc_rule(). Those paths traverse the same unlocked hlist that aq_clear_rxnfc_all_rules() is mutating and freeing.
The race is reachable by issuing RXNFC ethtool commands concurrently with PCI device removal or driver unbind. A reader can dereference a node that has just been freed, and two writers can corrupt the list or free the same rule more than once, causing KASAN reports, list corruption, or a kernel panic.
Reverse the removal order: unregister the netdevice first, then clear the RXNFC rules. After unregister_netdev() returns, ethtool can no longer enter the driver, while the PCI device is still available for the rule-clearing routine to issue hardware commands.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +1 -1
@@ -346,9 +346,9 @@ static void aq_pci_remove(struct pci_dev *pdev)struct aq_nic_s *self =pci_get_drvdata (pdev);if (self->ndev) { -aq_clear_rxnfc_all_rules (self);if (self->ndev->reg_state ==NETREG_REGISTERED )unregister_netdev (self->ndev); +aq_clear_rxnfc_all_rules (self);#if IS_ENABLED (CONFIG_MACSEC )aq_macsec_free (self);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2746/2857 net: usb: cdc_ncm: dont enable BHs in tx_fixup under netpoll
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 108ca34cf4b453f6375a70079e32b11866b02601 ]
netpoll holds the txq lock and calls ndo_start_xmit() with IRQs off but BHs on. The spin_unlock_bh() in cdc_ncm_tx_fixup() then runs pending softirqs. If one of them transmits, it spins on the txq lock that netpoll holds. With netconsole on a cdc_ncm device this ends in a soft or hard lockup.
Every caller of cdc_ncm_tx_fixup() holds the txq lock with BHs or IRQs off, so the softirq user of ctx->mtx cannot interrupt it. Use plain spin_lock().
--- drivers/net/usb/cdc_ncm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/usb/cdc_ncm.c +5 -2
@@ -1534,14 +1534,17 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)if (ctx ==NULL ) goto error; -spin_lock_bh (&ctx->mtx); +/* BHs or IRQs are always off here. netpoll only disables IRQs, and +* spin_unlock_bh() would then run softirqs with the txq lock held. +*/ +spin_lock (&ctx->mtx);if (ctx->is_ndp16) skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN ));else skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP32_NOCRC_SIGN )); -spin_unlock_bh (&ctx->mtx); +spin_unlock (&ctx->mtx);return skb_out; error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2747/2857 net: usb: cdc_mbim: dont enable BHs in tx_fixup under netpoll
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit bfd7ced012c7857b5ab5edf7e416c2789b652702 ]
cdc_mbim_tx_fixup() has the same spin_unlock_bh() as cdc_ncm_tx_fixup(). Under netpoll it runs pending softirqs while the txq lock is held, and a transmit from one of them spins on that lock.
Use plain spin_lock() as in cdc_ncm.
--- drivers/net/usb/cdc_mbim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/usb/cdc_mbim.c +3 -2
@@ -290,9 +290,10 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb } } -spin_lock_bh (&ctx->mtx); +/* BHs or IRQs are always off here, see cdc_ncm_tx_fixup() */ +spin_lock (&ctx->mtx); skb_out =cdc_ncm_fill_tx_frame (dev, skb, sign); -spin_unlock_bh (&ctx->mtx); +spin_unlock (&ctx->mtx);return skb_out; error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2748/2857 ALSA: usb-audio: Add correct datainterval in the quirks-table for Microbook II
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sally Marcher <[email protected]>
[ Upstream commit a09c2f3b267e47767b8937f65930567edbb88d44 ]
This patch fixes playback issues on the Microbook II. The correct value was in the older driver for this device
(https://github.com/manuel-rhdt/snd-microbookii/blob/dd304c097bb6a9d52276ac29c6969fa02bc7674a/audio.c#L914).
Datainterval needs to be set explicitly.
--- sound/usb/quirks-table.h | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks-table.h +2 -0
@@ -2743,6 +2743,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rates = SNDRV_PCM_RATE_96000, .ep_attr =USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, .rate_min = 96000, .rate_max = 96000, .nr_rates = 1,
@@ -2765,6 +2766,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .rates = SNDRV_PCM_RATE_96000, .ep_attr =USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, .rate_min = 96000, .rate_max = 96000, .nr_rates = 1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2749/2857 net: tun: hold napi_mutex when deleting NAPI in tun_detach_all()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Yongkang <[email protected]>
[ Upstream commit 6c799b4998c87bb44574bb090b8728bb3b3dbc47 ]
With IFF_NAPI_FRAGS, tun_get_user() takes tfile->napi_mutex, gets the skb from napi_get_frags() and copies the user data into it before it enters the RCU read-side section around napi_gro_frags().
tun_detach_all() waits with synchronize_net() and then calls tun_napi_del() without napi_mutex. netif_napi_del() frees napi->skb through napi_free_frags(). A writer that is still copying has not yet entered its RCU section, so synchronize_net() does not wait for it, and deleting the device frees the skb while the writer is using it:
BUG: KASAN: slab-use-after-free in skb_copy_datagram_from_iter+0x175/0x720 Read of size 8 at addr ffff888077def990 by task br029-poc/9406 Call Trace: skb_copy_datagram_from_iter+0x175/0x720 tun_get_user+0xb42/0x3d00 tun_chr_write_iter+0x113/0x200 ... Freed by task 9405: kmem_cache_free+0x184/0x670 __netif_napi_del_locked+0x2bb/0x3c0 tun_net_uninit+0x566/0xa70 unregister_netdevice_many_notify+0x1a26/0x2090 rtnl_dellink+0x514/0x710
__tun_detach() also calls tun_napi_del() without the mutex, but only from tun_chr_close(), when no write on that file can be in flight.
Take napi_mutex around tun_napi_del() in tun_detach_all() for both attached and disabled queues.
--- drivers/net/tun.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/tun.c +4 -0
@@ -736,14 +736,18 @@ static void tun_detach_all(struct net_device *dev)synchronize_net ();for (i =0 ; i < n; i++) { tfile =rtnl_dereference (tun->tfiles[i]); +mutex_lock (&tfile->napi_mutex);tun_napi_del (tfile); +mutex_unlock (&tfile->napi_mutex);/* Drop read queue */ tun_queue_purge (tfile);xdp_rxq_info_unreg (&tfile->xdp_rxq);sock_put (&tfile->sk); }list_for_each_entry_safe (tfile, tmp, &tun->disabled, next) { +mutex_lock (&tfile->napi_mutex);tun_napi_del (tfile); +mutex_unlock (&tfile->napi_mutex);tun_enable_queue (tfile);tun_queue_purge (tfile);xdp_rxq_info_unreg (&tfile->xdp_rxq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2750/2857 rds:Simplify the allocation of slab caches
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit 9f1f70dd850038b37e8b103ef0cc6f5eaeb6a8fc ]
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches.
Stable-dep-of: ffbbc315b8b8 ("net/rds: do not initialize transports after rds_init() failed")
--- net/rds/tcp.c | 4 +--- net/rds/tcp_recv.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
net/rds/tcp.c +1 -3
@@ -820,9 +820,7 @@ static int __init rds_tcp_init(void) {int ret; - rds_tcp_conn_slab =kmem_cache_create ("rds_tcp_connection" , -sizeof (struct rds_tcp_connection ), -0 ,0 ,NULL ); + rds_tcp_conn_slab =KMEM_CACHE (rds_tcp_connection,0 );if (!rds_tcp_conn_slab) { ret = -ENOMEM ; goto out;
net/rds/tcp_recv.c +1 -3
@@ -335,9 +335,7 @@ void rds_tcp_data_ready(struct sock *sk)int rds_tcp_recv_init (void ) { - rds_tcp_incoming_slab =kmem_cache_create ("rds_tcp_incoming" , -sizeof (struct rds_tcp_incoming ), -0 ,0 ,NULL ); + rds_tcp_incoming_slab =KMEM_CACHE (rds_tcp_incoming,0 );if (!rds_tcp_incoming_slab)return -ENOMEM ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2751/2857 net/rds: do not initialize transports after rds_init() failed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit ffbbc315b8b883a1c0e131fb3186b9428d2812aa ]
rds, rds_rdma and rds_tcp each have their own module_init(). When they are built in, those run in link order, so rds_init() goes first, but do_initcalls() does not stop when it fails. The transports then initialize against a core that has already been torn down: rds_wq has been destroyed, yet rds_ib_dev_put(), rds_ib_unregister_client() and rds_tcp_accept_work() still queue onto or flush it, and rds_trans_register() hands the transports to a core whose socket family may never have been registered.
This was seen with CONFIG_SYSCTL=n, where rds_sysctl_init() failed and rds_ib_init()'s error path then flushed the freed rds_wq [1], but any rds_init() failure after rds_threads_init() has the same effect.
Record whether rds_init() succeeded and have rds_rdma_init() and rds_tcp_init() bail out with -ENODEV otherwise. Modular builds are
unaffected: the transports need symbols exported by rds.ko, so they cannot be loaded unless rds_init() succeeded.
[1] https://lore.kernel.org/oe-lkp/[email protected]
--- net/rds/af_rds.c | 14 ++++++++++++++ net/rds/rdma_transport.c | 3 +++ net/rds/rds.h | 1 + net/rds/tcp.c | 3 +++ 4 files changed, 21 insertions(+)
net/rds/af_rds.c +14 -0
@@ -922,8 +922,11 @@ static void rds6_sock_info(struct socket *sock, unsigned int len, }#endif +static bool rds_initialized; +static void rds_exit (void ) { + rds_initialized = false;sock_unregister (rds_family_ops.family);proto_unregister (&rds_proto);rds_conn_exit ();
@@ -944,6 +947,16 @@ module_exit(rds_exit);u32 rds_gen_num; +/* When RDS is built in, a failed rds_init() does not stop the rds_rdma +* and rds_tcp initcalls from running against a core that has already +* been torn down (rds_wq in particular). Let them bail out early. +*/ +bool rds_is_initialized (void ) +{ +return rds_initialized; +} +EXPORT_SYMBOL_GPL (rds_is_initialized); +static int __init rds_init (void ) {int ret;
@@ -980,6 +993,7 @@ static int __init rds_init(void)rds_info_register_func (RDS6_INFO_SOCKETS , rds6_sock_info);rds_info_register_func (RDS6_INFO_RECV_MESSAGES , rds6_sock_inc_info);#endif + rds_initialized = true; goto out;
net/rds/rdma_transport.c +3 -0
@@ -325,6 +325,9 @@ static int __init rds_rdma_init(void) {int ret; +if (!rds_is_initialized ()) +return -ENODEV ; + ret =rds_ib_init ();if (ret) goto out;
net/rds/rds.h +1 -0
@@ -1009,6 +1009,7 @@ extern unsigned int rds_sysctl_trace_level;int rds_threads_init (void );void rds_threads_exit (void );extern struct workqueue_struct *rds_wq; +bool rds_is_initialized (void );void rds_queue_reconnect (struct rds_conn_path *cp);void rds_connect_worker (struct work_struct *);void rds_shutdown_worker (struct work_struct *);
net/rds/tcp.c +3 -0
@@ -820,6 +820,9 @@ static int __init rds_tcp_init(void) {int ret; +if (!rds_is_initialized ()) +return -ENODEV ; + rds_tcp_conn_slab =KMEM_CACHE (rds_tcp_connection,0 );if (!rds_tcp_conn_slab) { ret = -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2752/2857 net: xps: bound the cleanup loop by the old maps num_tc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 6d5a2cb0b7d6caf170d37ae7ac74738d592d2a05 ]
__netif_set_xps_queue() walks the OLD dev_maps to free its entries. The per-row trip count uses the NEW num_tc while the row stride uses the OLD dev_maps->num_tc, so when dev->num_tc was raised without rebuilding the XPS map the last row indexes attr_map[] past the allocation:
BUG: KASAN: slab-out-of-bounds in __netif_set_xps_queue+0x1458/0x1ee8 Read of size 8 at addr ffff000014f69458 by task insmod/112
The loop frees entries in dev_maps, so both the trip count and the stride must come from dev_maps->num_tc. The map is sized XPS_CPU_DEV_MAPS_SIZE(old num_tc)/XPS_RXQ_DEV_MAPS_SIZE(old num_tc, ...), so iterating the new (larger) num_tc reads past the end.
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -2737,7 +2737,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, goto out_no_old_maps;for (j =0 ; j < dev_maps->nr_ids; j++) { -for (i = num_tc, tci = j * dev_maps->num_tc; i--; tci++) { +for (i = dev_maps->num_tc, tci = j * dev_maps->num_tc; i--; tci++) { map =xmap_dereference (dev_maps->attr_map[tci]);if (!map)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2753/2857 net: lan966x: do not inject uninitialised bytes past skb->len
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit b4a7180558eb3cd8affa1e240b22171425bdfcb4 ]
lan966x_port_ifh_xmit() writes the frame to the injection FIFO one 32-bit word at a time, and pads frames shorter than 60 bytes with zero words.
Before this patch, the last word is loaded whole even when skb->len is not a multiple of four, so 1 to 3 bytes past the end of the frame are read. For a frame shorter than 60 bytes those bytes are also transmitted, as VLD_BYTES marks the whole last word valid and the padding starts at the next word.
Write the trailing bytes from a zeroed word. The number of words written and VLD_BYTES are unchanged.
Found by an AI code review agent. Reproduced on a lan9668 board with register injection, by sending a
57 byte frame and capturing it on the link partner: byte 57 of the padded frame was not zero. With the fix all padding bytes are zero.
--- .../ethernet/microchip/lan966x/lan966x_main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_main.c +16 -3
@@ -250,9 +250,8 @@ static int lan966x_port_ifh_xmit(struct sk_buff *skb,lan_wr ((__force u32 )ifh[i], lan966x,QS_INJ_WR (grp)); } -/* Write frame */ - count =DIV_ROUND_UP (skb->len,4 ); - last = skb->len %4 ; +/* Write the whole words of the frame */ + count = skb->len /4 ;for (i =0 ; i < count; ++i) {/* Wait until the fifo is ready */ err =lan966x_port_inj_ready (lan966x, grp);
@@ -262,6 +261,20 @@ static int lan966x_port_ifh_xmit(struct sk_buff *skb,lan_wr (((u32 *)skb->data)[i], lan966x,QS_INJ_WR (grp)); } +/* Write the last 1 to 3 bytes, zero padded to a whole word */ + last = skb->len %4 ; +if (last) { +/* Wait until the fifo is ready */ + err =lan966x_port_inj_ready (lan966x, grp); +if (err) + goto err; + + val =0 ; +memcpy (&val, skb->data + count *4 , last); +lan_wr (val, lan966x,QS_INJ_WR (grp)); + ++i; + } +/* Add padding */ while (i < (LAN966X_BUFFER_MIN_SZ /4 )) {/* Wait until the fifo is ready */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2754/2857 net: lan966x: do not warn on MAC entries that are not port destined
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 2cffcf1aeabb187e4f08fe4f5363128a3c45d786 ]
lan966x_mac_irq_handler() scans the rows of the MAC table that the analyzer reports as changed, reads back all four columns of each row and treats ANA_MACACCESS.DEST_IDX as a port number.
Before this patch, a destination index above num_phys_ports hits a WARN_ON(). The driver installs such entries itself:lan966x_mac_cpu_learn() uses PGID_CPU, and L2 multicast entries use a general-purpose PGID. A row holding one of them is read back whenever another entry in the same row is learned or aged out, so the scan warns in normal operation, repeatedly once the MAC table is busy.
Skipping such a column is already the right behaviour. Drop the WARN_ON() and keep the bounds check as a plain filter.
Found by an AI code review agent. Reproduced on a lan9668 board by bridging two ports with a 10 s ageing time and sending three rounds of 2048 new source MACs: the base kernel warned 42 times from lan966x_mac_irq_process(), the fixed kernel did not warn.
--- drivers/net/ethernet/microchip/lan966x/lan966x_mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +2 -2
@@ -447,7 +447,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,lan966x_mac_process_raw_entry (&raw_entries[column], mac, &vid, &dest_idx); -if (WARN_ON (dest_idx >= lan966x->num_phys_ports)) +if (dest_idx >= lan966x->num_phys_ports)continue ;/* If the entry in SW is found, then there is nothing
@@ -501,7 +501,7 @@ static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row,lan966x_mac_process_raw_entry (&raw_entries[column], mac, &vid, &dest_idx); -if (WARN_ON (dest_idx >= lan966x->num_phys_ports)) +if (dest_idx >= lan966x->num_phys_ports)continue ;spin_lock (&lan966x->mac_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2755/2857 x86_energy_perf_policy: Fix optarg keyword matching
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 0177067d195a4757149f6702af191987377c71c3 ]
Replace strncmp() with strcmp() for exact string matching in parse_optarg_string(). Exact keyword matching is safer and clearer. This prevents accidental matches with longer strings
like "performance-foo".
--- .../x86_energy_perf_policy/x86_energy_perf_policy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +6 -6
@@ -312,22 +312,22 @@ int parse_optarg_string(char *s)int i;char *endptr; -if (!strncmp (s,"default" ,7 )) +if (strcmp (s,"default" ) ==0 )return OPTARG_NORMAL ; -if (!strncmp (s,"normal" ,6 )) +if (strcmp (s,"normal" ) ==0 )return OPTARG_NORMAL ; -if (!strncmp (s,"power" ,9 )) +if (strcmp (s,"power" ) ==0 )return OPTARG_POWER ; -if (!strncmp (s,"balance-power" ,17 )) +if (strcmp (s,"balance-power" ) ==0 )return OPTARG_BALANCE_POWER ; -if (!strncmp (s,"balance-performance" ,19 )) +if (strcmp (s,"balance-performance" ) ==0 )return OPTARG_BALANCE_PERFORMANCE ; -if (!strncmp (s,"performance" ,11 )) +if (strcmp (s,"performance" ) ==0 )return OPTARG_PERFORMANCE ; i =strtol (s, &endptr,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2756/2857 x86_energy_perf_policy: Cleanup: Check fseek() in VM path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 2778dc35d40e7e84c134ca4cab1376fa58208f80 ]
Add return value validation for fseek() and ensure consistent resource cleanup on all error paths in err_on_hypervisor().
--- .../x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +5 -1
@@ -661,7 +661,11 @@ void err_on_hypervisor(void) flags =strstr (buffer,"flags" );rewind (cpuinfo); -fseek (cpuinfo, flags - buffer,SEEK_SET ); +if (fseek (cpuinfo, flags - buffer,SEEK_SET ) !=0 ) { +fclose (cpuinfo); +free (buffer); +err (1 ,"Failed to seek in /proc/cpuinfo" ); + }if (!fgets (buffer,4096 , cpuinfo)) {fclose (cpuinfo);free (buffer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2757/2857 perf mmap: Use the head selected by read_init
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit 022c64992af554cfd8c564bff86100fb5ed98678 ]
perf_mmap__push() reads the producer head before calling perf_mmap__read_init(), which reads it again to select the range to copy.
If the producer advances between those reads, push() copies through the newer head but stores the earlier head in prev. The next drain starts at that earlier position and can write the same records to perf.data again.
Use the head selected by read_init(): end for forward buffers and start for overwrite buffers. Save it before the copy loop advances start so prev matches the range that was copied.
--- tools/perf/util/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/mmap.c +2 -1
@@ -324,7 +324,7 @@ int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpuint perf_mmap__push (struct mmap *md,void *to,int push (struct mmap *map,void *to,void *buf,size_t size)) { -u64 head =perf_mmap__read_head (&md->core); +u64 head;unsigned char *data = md->core.base + page_size;unsigned long size;void *buf;
@@ -334,6 +334,7 @@ int perf_mmap__push(struct mmap *md, void *to,if (rc <0 )return (rc == -EAGAIN ) ?1 :-1 ; + head = md->core.overwrite ? md->core.start : md->core.end; size = md->core.end - md->core.start;if ((md->core.start & md->core.mask) + size != (md->core.end & md->core.mask)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2758/2857 perf mmap: Preserve the consumed cursor in forward mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit 1e826983ceef421d7047ed76581840b778294ad4 ]
perf_mmap__read_event() updates prev as it consumes forward-buffer records. perf_mmap__read_done() then overwrites prev with a fresh producer head, even when unread records remain.
perf_kvm__mmap_read_idx() stops after 25 records per mmap and calls read_done(). If more records are pending, prev advances past them. The next drain starts at that new position and skips the unread remainder.
An event arriving after the last empty read_event() and before read_done() can also be skipped. read_done() does not itself update the kernel's data_tail.
Only refresh prev for overwrite buffers, which need the current head as the end of the next backward read. Leave the forward cursor at the consumed position.
--- tools/lib/perf/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/mmap.c +1 -1
@@ -194,7 +194,7 @@ void perf_mmap__read_done(struct perf_mmap *map)/* * Check if event was unmapped due to a POLLHUP/POLLERR. */ -if (!refcount_read (&map->refcnt)) +if (!refcount_read (&map->refcnt) || !map->overwrite)return ; map->prev =perf_mmap__read_head (map);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2759/2857 net: lan966x: release the in-flight slot of a stale TX skb
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Machon <[email protected]>
[ Upstream commit 074caa30a62726c0ee959e8b8ccb64cda0b26ae5 ]
lan966x_ptp_txtstamp_request() counts every two step TX skb waiting for its timestamp in lan966x->ptp_skbs, and refuses new ones once LAN966X_MAX_PTP_ID are in flight. lan966x_ptp_txtstamp_old_release() frees the skbs that have waited longer than LAN966X_PTP_TIMEOUT.
Before this patch, old_release() does not decrement ptp_skbs, so every skb whose timestamp never arrives, for example because the switch discarded the frame, keeps its slot forever. Once LAN966X_MAX_PTP_ID slots are lost, two step frames fail to transmit on every port of the switch.
Return the number of released skbs from old_release() and subtract it from ptp_skbs in txtstamp_request(), under the ptp_ts_id_lock it already takes.
This fixes the accounting only. A port's stale skbs are still aged out only when that port sends a two step frame, so a port that stops sending them keeps its stale skbs, and their slots, until it sends one again. That behaviour is unchanged by this patch.
Found by an AI code review agent. Reproduced on a lan9668 board.
--- drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c +8 -2
@@ -140,9 +140,10 @@ static int lan966x_ptp_classify(struct lan966x_port *port, struct sk_buff *skb)return IFH_REW_OP_TWO_STEP_PTP ; } -static void lan966x_ptp_txtstamp_old_release (struct lan966x_port *port) +static unsigned int lan966x_ptp_txtstamp_old_release (struct lan966x_port *port) {struct sk_buff *skb, *skb_tmp; +unsigned int purged =0 ;unsigned long flags;spin_lock_irqsave (&port->tx_skbs.lock, flags);
@@ -153,14 +154,18 @@ static void lan966x_ptp_txtstamp_old_release(struct lan966x_port *port)__skb_unlink (skb, &port->tx_skbs);dev_kfree_skb_any (skb); + purged++; }spin_unlock_irqrestore (&port->tx_skbs.lock, flags); + +return purged; }int lan966x_ptp_txtstamp_request (struct lan966x_port *port,struct sk_buff *skb) {struct lan966x *lan966x = port->lan966x; +unsigned int purged;unsigned long flags;u8 rew_op;
@@ -170,9 +175,10 @@ int lan966x_ptp_txtstamp_request(struct lan966x_port *port,if (rew_op !=IFH_REW_OP_TWO_STEP_PTP )return 0 ; -lan966x_ptp_txtstamp_old_release (port); + purged =lan966x_ptp_txtstamp_old_release (port);spin_lock_irqsave (&lan966x->ptp_ts_id_lock, flags); + lan966x->ptp_skbs -= purged;if (lan966x->ptp_skbs ==LAN966X_MAX_PTP_ID ) {spin_unlock_irqrestore (&lan966x->ptp_ts_id_lock, flags);return -EBUSY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2760/2857 net: dsa: mv88e6xxx: fix 6351 family statistics snapshot
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 9663edfa71e8807890203578dab6db60c6b548c4 ]
The 88E6171, 88E6175, 88E6350 and 88E6351 take the port number in the low bits of the statistics operation register. The 6320 snapshot helper instead encodes the port as (port + 1) << 5. On an EA4500 with an 88E6171, this causes ethtool -S to return physical port 0's MIB counters for every user port. Traffic on other ports does not update their reported hardware counters.
Before the snapshot operation was moved into the chip operations, only the 6320 and 6352 families used the shifted encoding. The refactoring incorrectly assigned that encoding to all four 6351 family chips.
Use the unshifted snapshot helper for the entire 6351 family. This matches the Marvell DSDT statsCapture() implementation, which uses the raw port number for chips outside DEV_RMON_PORT_BITS, including these four chips.
The original 88E6171 change was tested on an EA4500: pings through different switch ports updated only the corresponding port's hardware counters. The other three chips have not been hardware tested.
--- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -4
@@ -4572,7 +4572,7 @@ static const struct mv88e6xxx_ops mv88e6171_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -4675,7 +4675,7 @@ static const struct mv88e6xxx_ops mv88e6175_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -5363,7 +5363,7 @@ static const struct mv88e6xxx_ops mv88e6350_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
@@ -5407,7 +5407,7 @@ static const struct mv88e6xxx_ops mv88e6351_ops = { .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, .port_get_cmode = mv88e6352_port_get_cmode, .port_setup_message_port = mv88e6xxx_setup_message_port, - .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_snapshot = mv88e6xxx_g1_stats_snapshot, .stats_set_histogram = mv88e6095_g1_stats_set_histogram, .stats_get_sset_count = mv88e6095_stats_get_sset_count, .stats_get_strings = mv88e6095_stats_get_strings,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2761/2857 usbnet: fix EVENT_RX_PAUSED race in usbnet_skb_return()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ömer Mete Kaya <[email protected]>
[ Upstream commit 67ae1b80cf73f592b35e4b5e5001a24d6d6c8637 ]
On SMP, usbnet_skb_return() can observe EVENT_RX_PAUSED as set on CPU0 while usbnet_resume_rx() clears the flag and drains rxq_pause on CPU1. The skb can then be queued after the drain has completed and remain stranded until the next MTU change or device stop.
Synchronize the EVENT_RX_PAUSED state transition and paused-queue dequeue operations with rxq_pause.lock. In usbnet_resume_rx() splice the paused queue into a local queue under the lock, then drain the local queue lock-free. In usbnet_skb_return() use a double-check pattern under rxq_pause.lock on the slow path, keeping the normal RX fast path lock-free. Use spin_lock_irqsave() to match the lockdep class shared with other sk_buff_head locks taken from hardirq context in defer_bh().
Discovered by Sashiko, not triggered, not tested on real hardware.
--- drivers/net/usb/usbnet.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/net/usb/usbnet.c +16 -4
@@ -332,9 +332,14 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)unsigned long flags;int status; -if (test_bit (EVENT_RX_PAUSED , &dev->flags)) { -skb_queue_tail (&dev->rxq_pause, skb); -return ; +if (unlikely (test_bit (EVENT_RX_PAUSED , &dev->flags))) { +spin_lock_irqsave (&dev->rxq_pause.lock, flags); +if (test_bit (EVENT_RX_PAUSED , &dev->flags)) { +__skb_queue_tail (&dev->rxq_pause, skb); +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); +return ; + } +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); }/* only update if unset to allow minidriver rx_fixup override */
@@ -703,13 +708,20 @@ EXPORT_SYMBOL_GPL(usbnet_pause_rx);void usbnet_resume_rx (struct usbnet *dev) { +struct sk_buff_head q;struct sk_buff *skb; +unsigned long flags;int num =0 ; +__skb_queue_head_init (&q); +local_bh_disable (); +spin_lock_irqsave (&dev->rxq_pause.lock, flags);clear_bit (EVENT_RX_PAUSED , &dev->flags); +skb_queue_splice_init (&dev->rxq_pause, &q); +spin_unlock_irqrestore (&dev->rxq_pause.lock, flags); -while ((skb =skb_dequeue (&dev->rxq_pause)) !=NULL ) { +while ((skb =__skb_dequeue (&q))) {usbnet_skb_return (dev, skb); num++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2762/2857 bpf: Fix out-of-bounds btf->types write for split BTF
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit 6c476d2b73056ed151c3f8b884c627c75999ed7c ]
btf_add_type() stores the types of a BTF in btf->types[], which can hold at most BTF_MAX_TYPE entries. The types of a split BTF get IDs start_id .. start_id + nr_types - 1, so only BTF_MAX_TYPE - start_id of them fit, but neither the limit check nor the size used to grow the array accounts forstart_id: the check is an equality test against BTF_MAX_TYPE ('start_id + btf->types_size == BTF_MAX_TYPE') and the new size is clamped to BTF_MAX_TYPE.
The check therefore only fires if the array happens to grow to exactly BTF_MAX_TYPE - start_id entries. Otherwise, if the module has more than BTF_MAX_TYPE types, the array is filled up to BTF_MAX_TYPE entries. The next type that needs to be added reallocates the array to the same size, after which btf->types_size no longer equals btf->nr_types and the growth path is not taken anymore, so every following type is written past the end of the array:
BUG: unable to handle page fault for address: ffffc90006200000 RIP: 0010:btf_add_type+0x74/0x270 Call Trace: btf_check_all_metas btf_parse_module
Bound both the array size and the limit check by BTF_MAX_TYPE - start_id. Base BTF (start_id == 0) is unaffected.
--- kernel/bpf/btf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/bpf/btf.c +4 -3
@@ -1549,15 +1549,16 @@ static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t)/* Expand 'types' array */ struct btf_type **new_types; -u32 expand_by, new_size; +u32 expand_by, new_size, max_size; -if (btf->start_id + btf->types_size ==BTF_MAX_TYPE ) { +if (btf->start_id + btf->types_size >=BTF_MAX_TYPE ) {btf_verifier_log (env,"Exceeded max num of types" );return -E2BIG ; } + max_size =BTF_MAX_TYPE - btf->start_id; expand_by =max_t (u32, btf->types_size >>2 ,16 ); - new_size =min_t (u32,BTF_MAX_TYPE , + new_size =min_t (u32, max_size, btf->types_size + expand_by); new_types = kvcalloc(new_size, sizeof(*new_types),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2763/2857 ASoC: xilinx: formatter_pcm: Fix read-modify-write of AUD_CTRL in hw_params
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 3b54e739273752b370e49b09976da152fa3b802c ]
xlnx_formatter_pcm_hw_params() does a read-modify-write on XLNX_AUD_CTRL but only ORs in the new data width and active channel values without clearing the old ones. If hw_params is called more than once on an open stream, these fields may retain bits from the previous configuration, resulting in an incorrect sample width or channel count.
Clear both fields before writing the new values, and use FIELD_PREP() so the values cannot spill into neighbouring bits.
--- sound/soc/xilinx/xlnx_formatter_pcm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/soc/xilinx/xlnx_formatter_pcm.c +10 -8
@@ -6,6 +6,7 @@// // Author: Maruthi Srinivas Bayyavarapu <[email protected]> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/module.h>
@@ -57,8 +58,8 @@#define CFG_S2MM_XFER_SHIFT 29#define CFG_S2MM_PKG_MASK BIT(28) -#define AUD_CTRL_DATA_WIDTH_SHIFT 16 -#define AUD_CTRL_ACTIVE_CH_SHIFT 19 +#define AUD_CTRL_DATA_WIDTH_MASK GENMASK(18, 16) +#define AUD_CTRL_ACTIVE_CH_MASK GENMASK(22, 19)#define PERIOD_CFG_PERIODS_SHIFT 16#define PERIODS_MIN 2
@@ -509,28 +510,29 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component,writel (high, stream_data->mmio +XLNX_AUD_BUFF_ADDR_MSB ); val =readl (stream_data->mmio +XLNX_AUD_CTRL ); + val &= ~(AUD_CTRL_DATA_WIDTH_MASK |AUD_CTRL_ACTIVE_CH_MASK ); bits_per_sample =params_width (params);switch (bits_per_sample) {case 8 : - val |= (BIT_DEPTH_8 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_8 );break ;case 16 : - val |= (BIT_DEPTH_16 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_16 );break ;case 20 : - val |= (BIT_DEPTH_20 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_20 );break ;case 24 : - val |= (BIT_DEPTH_24 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_24 );break ;case 32 : - val |= (BIT_DEPTH_32 <<AUD_CTRL_DATA_WIDTH_SHIFT ); + val |=FIELD_PREP (AUD_CTRL_DATA_WIDTH_MASK ,BIT_DEPTH_32 );break ;default :return -EINVAL ; } - val |= active_ch <<AUD_CTRL_ACTIVE_CH_SHIFT ; + val |=FIELD_PREP (AUD_CTRL_ACTIVE_CH_MASK , active_ch);writel (val, stream_data->mmio +XLNX_AUD_CTRL ); val = (params_periods (params) <<PERIOD_CFG_PERIODS_SHIFT )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2764/2857 nvmet: zns: reject a NUMD whose byte count wraps
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit 12740bec646dafe009a7d9a4d22d3495ef1ea5cd ]
Zone Management Receive computes its buffer size as (numd + 1) << 2 in u32, in nvmet_bdev_validate_zone_mgmt_recv(), nvmet_bdev_zone_zmgmt_recv_work() and nvmet_bdev_execute_zone_mgmt_recv(). NUMD is a 32-bit dword count, so any NUMD from 0x3fffffff up wraps.
The data length check in nvmet_bdev_execute_zone_mgmt_recv() sees the same wrapped value, so such a command can pass it. A data length that does not match the wrapped size is already rejected by that check, with Data SGL Length Invalid.
Every site agrees on the wrapped size, so the target zeroes and fills only that many bytes and nothing leaks, but it answers a command whose NUMD asks for 4 GiB or more.
Reject a NUMD from U32_MAX / 4 up with Invalid Field at the start of nvmet_bdev_execute_zone_mgmt_recv(), before this handler or its work item computes the byte count. A size_t computation would still wrap on 32-bit kernels, where nvmet_check_transfer_len() and req->transfer_len are 32 bits wide.
nvmet_io_cmd_transfer_len() in core.c, which the pci-epf transport uses to size its buffer, computes the same expression before this handler runs. Return 0 there for such a NUMD, so pci-epf allocates no buffer and the handler then rejects the command.
Tested over the loop, tcp, rdma and fc transports with a zoned null_blk namespace: a wrapping NUMD, sent with a data length that matches the wrapped size, was accepted before this patch and now fails with Invalid Field, while ordinary NUMD values still succeed. The core.c change only affects pci-epf and is build-tested only.
--- drivers/nvme/target/core.c | 3 +++ drivers/nvme/target/zns.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/nvme/target/core.c +3 -0
@@ -905,6 +905,9 @@ static u32 nvmet_io_cmd_transfer_len(struct nvmet_req *req)case nvme_cmd_dsm:return nvmet_dsm_len (req);case nvme_cmd_zone_mgmt_recv: +/* The handler rejects a NUMD whose byte count would wrap. */ +if (le32_to_cpu (req->cmd->zmr.numd) >=U32_MAX /4 ) +return 0 ;return (le32_to_cpu (req->cmd->zmr.numd) +1 ) <<2 ;default :return 0 ;
drivers/nvme/target/zns.c +10 -2
@@ -324,9 +324,17 @@ static void nvmet_bdev_zone_zmgmt_recv_work(struct work_struct *w)void nvmet_bdev_execute_zone_mgmt_recv (struct nvmet_req *req) { -u32 out_bufsize = (le32_to_cpu (req->cmd->zmr.numd) +1 ) <<2 ; +u32 numd =le32_to_cpu (req->cmd->zmr.numd); + +/* From U32_MAX / 4 up, (numd + 1) << 2 wraps here and in the work. */ +if (numd >=U32_MAX /4 ) { + req->error_loc = offsetof(struct nvme_zone_mgmt_recv_cmd , numd); +nvmet_req_complete (req, +NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ); +return ; + } -if (!nvmet_check_transfer_len (req, out_bufsize)) +if (!nvmet_check_transfer_len (req, (numd +1 ) <<2 ))return ;INIT_WORK (&req->z.zmgmt_work, nvmet_bdev_zone_zmgmt_recv_work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2765/2857 nvmet: prevent double-free after metadata SGL allocation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 2f61b9d1d54edf75a352c43eebe3804144b5d44e ]
If metadata SGL allocation fails, nvmet_req_alloc_sgls() frees req->sg without clearing it. The RDMA error completion path later frees the same scatterlist again.
Use nvmet_req_free_sgls() instead so that the scatterlist pointers and counts are cleared before response cleanup.
--- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
@@ -1129,7 +1129,7 @@ int nvmet_req_alloc_sgls(struct nvmet_req *req)return 0 ; out_free: -sgl_free (req->sg); +nvmet_req_free_sgls (req); out:return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2766/2857 nvmet: protect nvmet_ports_list with nvmet_config_sem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Zhang <[email protected]>
[ Upstream commit cead6beb89256ae7145b65fbe8e8a5fedba4a47c ]
Readers of nvmet_ports_list (e.g. nvmet_subsys_disc_changed()) hold nvmet_config_sem and assert it via lockdep. The writers -- nvmet_ports_make() and nvmet_port_release() -- do not take the lock; they rely on the parent directory's VFS inode lock for serialization, which is an implementation detail of configfs and not a guaranteed contract. Align the writers with the lock the readers already require.
Also move list_add() in nvmet_ports_make() to after the port is fully
initialized: the old position published the port on the global list before INIT_LIST_HEAD(&port->subsystems), so a concurrent reader could traverse uninitialized list heads.
flush_workqueue() in nvmet_port_release() stays outside the semaphore to avoid a lock dependency on nvmet_wq.
--- drivers/nvme/target/configfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/target/configfs.c +6 -2
@@ -1644,7 +1644,9 @@ static void nvmet_port_release(struct config_item *item)/* Let inflight controllers teardown complete */ flush_workqueue (nvmet_wq); +down_write (&nvmet_config_sem);list_del (&port->global_entry); +up_write (&nvmet_config_sem);kfree (port->ana_state);kfree (port);
@@ -1701,8 +1703,6 @@ static struct config_group *nvmet_ports_make(struct config_group *group, port->ana_state[i] =NVME_ANA_INACCESSIBLE ; } -list_add (&port->global_entry, &nvmet_ports_list); -INIT_LIST_HEAD (&port->entry);INIT_LIST_HEAD (&port->subsystems);INIT_LIST_HEAD (&port->referrals);
@@ -1733,6 +1733,10 @@ static struct config_group *nvmet_ports_make(struct config_group *group,configfs_add_default_group (&port->ana_default_group.group, &port->ana_groups_group); +down_write (&nvmet_config_sem); +list_add (&port->global_entry, &nvmet_ports_list); +up_write (&nvmet_config_sem); +return &port->group; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2767/2857 nvme: add TCP TSAS definitions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 646f45b23218c7a97a84259d8eeb22dad5711fc8 ]
Stable-dep-of: 60385038754e ("nvmet: use the enabled transport when disabling a port")
--- include/linux/nvme.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/nvme.h +10 -0
@@ -111,6 +111,13 @@ enum { NVMF_RDMA_CMS_RDMA_CM = 1, /* Sockets based endpoint addressing */ }; +/* TSAS SECTYPE for TCP transport */ +enum { +NVMF_TCP_SECTYPE_NONE =0 ,/* No Security */ +NVMF_TCP_SECTYPE_TLS12 =1 ,/* TLSv1.2, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */ +NVMF_TCP_SECTYPE_TLS13 =2 ,/* TLSv1.3, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */ +}; +#define NVME_AQ_DEPTH 32#define NVME_NR_AEN_COMMANDS 1#define NVME_AQ_BLK_MQ_DEPTH (NVME_AQ_DEPTH - NVME_NR_AEN_COMMANDS)
@@ -1453,6 +1460,9 @@ struct nvmf_disc_rsp_page_entry {__u16 pkey;__u8 resv10[246 ]; } rdma; +struct tcp { +__u8 sectype; + } tcp; } tsas; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2768/2857 nvmet: make TCP sectype settable via configfs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 3f123494db725d899fdf990d894648bcc33cf7a3 ]
Add a new configfs attribute 'addr_tsas' to make the TCP sectype settable via configfs.
Stable-dep-of: 60385038754e ("nvmet: use the enabled transport when disabling a port")
--- drivers/nvme/target/configfs.c | 75 +++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-)
drivers/nvme/target/configfs.c +74 -1
@@ -159,6 +159,11 @@ static const struct nvmet_type_name_map nvmet_addr_treq[] = { { NVMF_TREQ_NOT_REQUIRED, "not required" }, }; +static inline u8 nvmet_port_disc_addr_treq_mask (struct nvmet_port *port) +{ +return (port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK ); +} +static ssize_t nvmet_addr_treq_show (struct config_item *item,char *page) { u8 treq = to_nvmet_port(item)->disc_addr.treq &
@@ -178,7 +183,7 @@ static ssize_t nvmet_addr_treq_store(struct config_item *item, const char *page, size_t count) {struct nvmet_port *port =to_nvmet_port (item); -u8 treq = port->disc_addr.treq & ~NVME_TREQ_SECURE_CHANNEL_MASK ; +u8 treq =nvmet_port_disc_addr_treq_mask (port);int i;if (nvmet_is_port_enabled (port, __func__))
@@ -303,6 +308,11 @@ static void nvmet_port_init_tsas_rdma(struct nvmet_port *port) port->disc_addr.tsas.rdma.cms =NVMF_RDMA_CMS_RDMA_CM ; } +static void nvmet_port_init_tsas_tcp (struct nvmet_port *port,int sectype) +{ + port->disc_addr.tsas.tcp.sectype = sectype; +} +static ssize_t nvmet_addr_trtype_store (struct config_item *item,const char *page,size_t count) {
@@ -325,11 +335,73 @@ static ssize_t nvmet_addr_trtype_store(struct config_item *item, port->disc_addr.trtype = nvmet_transport[i].type;if (port->disc_addr.trtype ==NVMF_TRTYPE_RDMA )nvmet_port_init_tsas_rdma (port); +else if (port->disc_addr.trtype ==NVMF_TRTYPE_TCP ) +nvmet_port_init_tsas_tcp (port,NVMF_TCP_SECTYPE_NONE );return count; }CONFIGFS_ATTR (nvmet_, addr_trtype); +static const struct nvmet_type_name_map nvmet_addr_tsas_tcp[] = { + {NVMF_TCP_SECTYPE_NONE ,"none" }, + {NVMF_TCP_SECTYPE_TLS13 ,"tls1.3" }, +}; + +static const struct nvmet_type_name_map nvmet_addr_tsas_rdma[] = { + {NVMF_RDMA_QPTYPE_CONNECTED ,"connected" }, + {NVMF_RDMA_QPTYPE_DATAGRAM ,"datagram" }, +}; + +static ssize_t nvmet_addr_tsas_show (struct config_item *item, +char *page) +{ +struct nvmet_port *port =to_nvmet_port (item); +int i; + +if (port->disc_addr.trtype ==NVMF_TRTYPE_TCP ) { +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_tcp); i++) { +if (port->disc_addr.tsas.tcp.sectype == nvmet_addr_tsas_tcp[i].type) +return sprintf (page,"%s\n" , nvmet_addr_tsas_tcp[i].name); + } + }else if (port->disc_addr.trtype ==NVMF_TRTYPE_RDMA ) { +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_rdma); i++) { +if (port->disc_addr.tsas.rdma.qptype == nvmet_addr_tsas_rdma[i].type) +return sprintf (page,"%s\n" , nvmet_addr_tsas_rdma[i].name); + } + } +return sprintf (page,"reserved\n" ); +} + +static ssize_t nvmet_addr_tsas_store (struct config_item *item, +const char *page,size_t count) +{ +struct nvmet_port *port =to_nvmet_port (item); +u8 sectype; +int i; + +if (nvmet_is_port_enabled (port, __func__)) +return -EACCES ; + +if (port->disc_addr.trtype !=NVMF_TRTYPE_TCP ) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (nvmet_addr_tsas_tcp); i++) { +if (sysfs_streq (page, nvmet_addr_tsas_tcp[i].name)) { + sectype = nvmet_addr_tsas_tcp[i].type; + goto found; + } + } + +pr_err ("Invalid value '%s' for tsas\n" , page); +return -EINVAL ; + +found: +nvmet_port_init_tsas_tcp (port, sectype); +return count; +} + +CONFIGFS_ATTR (nvmet_, addr_tsas); +/* * Namespace structures & file operation functions below */
@@ -1658,6 +1730,7 @@ static struct configfs_attribute *nvmet_port_attrs[] = { &nvmet_attr_addr_traddr, &nvmet_attr_addr_trsvcid, &nvmet_attr_addr_trtype, + &nvmet_attr_addr_tsas, &nvmet_attr_param_inline_data_size, #ifdef CONFIG_BLK_DEV_INTEGRITY &nvmet_attr_param_pi_enable,
Signature · 1 line
2.53.0