5.15.209-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 575/776 netfilter: xtables: restrict several matches to inet family
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b6fe26f86a1649f84e057f3f15605b08eda15497 ]
This is a partial revert of:
commit ab4f21e6fb1c ("netfilter: xtables: use NFPROTO_UNSPEC in more extensions")
to allow ipv4 and ipv6 only.
- xt_mac
- xt_owner
- xt_physdev
These extensions are not used by ebtables in userspace.
Moreover, xt_realm is only for ipv4, since dst->tclassid is ipv4 specific.
--- net/netfilter/xt_mac.c | 34 +++++++++++++++++++++++----------- net/netfilter/xt_owner.c | 37 +++++++++++++++++++++++++------------ net/netfilter/xt_physdev.c | 29 +++++++++++++++++++---------- net/netfilter/xt_realm.c | 2 +- 4 files changed, 68 insertions(+), 34 deletions(-)
net/netfilter/xt_mac.c +23 -11
@@ -38,25 +38,37 @@ static bool mac_mt(const struct sk_buff *skb, struct xt_action_param *par)return ret; } -static struct xt_match mac_mt_reg__read_mostly = { - .name ="mac" , - .revision =0 , - .family =NFPROTO_UNSPEC , - .match = mac_mt, - .matchsize =sizeof (struct xt_mac_info ), - .hooks = (1 <<NF_INET_PRE_ROUTING ) | (1 <<NF_INET_LOCAL_IN ) | - (1 <<NF_INET_FORWARD ), - .me =THIS_MODULE , +static struct xt_match mac_mt_reg[]__read_mostly = { + { + .name ="mac" , + .family =NFPROTO_IPV4 , + .match = mac_mt, + .matchsize =sizeof (struct xt_mac_info ), + .hooks = (1 <<NF_INET_PRE_ROUTING ) | + (1 <<NF_INET_LOCAL_IN ) | + (1 <<NF_INET_FORWARD ), + .me =THIS_MODULE , + }, + { + .name ="mac" , + .family =NFPROTO_IPV6 , + .match = mac_mt, + .matchsize =sizeof (struct xt_mac_info ), + .hooks = (1 <<NF_INET_PRE_ROUTING ) | + (1 <<NF_INET_LOCAL_IN ) | + (1 <<NF_INET_FORWARD ), + .me =THIS_MODULE , + }, };static int __init mac_mt_init (void ) { -return xt_register_match (&mac_mt_reg); +return xt_register_matches (mac_mt_reg,ARRAY_SIZE (mac_mt_reg)); } static void __exit mac_mt_exit(void) { -xt_unregister_match (&mac_mt_reg); +xt_unregister_matches (mac_mt_reg,ARRAY_SIZE (mac_mt_reg)); }module_init (mac_mt_init);
net/netfilter/xt_owner.c +25 -12
@@ -127,26 +127,39 @@ owner_mt(const struct sk_buff *skb, struct xt_action_param *par)return true; } -static struct xt_match owner_mt_reg__read_mostly = { - .name ="owner" , - .revision =1 , - .family =NFPROTO_UNSPEC , - .checkentry = owner_check, - .match = owner_mt, - .matchsize =sizeof (struct xt_owner_match_info ), - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_POST_ROUTING ), - .me =THIS_MODULE , +static struct xt_match owner_mt_reg[]__read_mostly = { + { + .name ="owner" , + .revision =1 , + .family =NFPROTO_IPV4 , + .checkentry = owner_check, + .match = owner_mt, + .matchsize =sizeof (struct xt_owner_match_info ), + .hooks = (1 <<NF_INET_LOCAL_OUT ) | + (1 <<NF_INET_POST_ROUTING ), + .me =THIS_MODULE , + }, + { + .name ="owner" , + .revision =1 , + .family =NFPROTO_IPV6 , + .checkentry = owner_check, + .match = owner_mt, + .matchsize =sizeof (struct xt_owner_match_info ), + .hooks = (1 <<NF_INET_LOCAL_OUT ) | + (1 <<NF_INET_POST_ROUTING ), + .me =THIS_MODULE , + } };static int __init owner_mt_init (void ) { -return xt_register_match (&owner_mt_reg); +return xt_register_matches (owner_mt_reg,ARRAY_SIZE (owner_mt_reg)); } static void __exit owner_mt_exit(void) { -xt_unregister_match (&owner_mt_reg); +xt_unregister_matches (owner_mt_reg,ARRAY_SIZE (owner_mt_reg)); }module_init (owner_mt_init);
net/netfilter/xt_physdev.c +19 -10
@@ -115,24 +115,33 @@ static int physdev_mt_check(const struct xt_mtchk_param *par)return 0 ; } -static struct xt_match physdev_mt_reg__read_mostly = { - .name ="physdev" , - .revision =0 , - .family =NFPROTO_UNSPEC , - .checkentry = physdev_mt_check, - .match = physdev_mt, - .matchsize =sizeof (struct xt_physdev_info ), - .me =THIS_MODULE , +static struct xt_match physdev_mt_reg[]__read_mostly = { + { + .name ="physdev" , + .family =NFPROTO_IPV4 , + .checkentry = physdev_mt_check, + .match = physdev_mt, + .matchsize =sizeof (struct xt_physdev_info ), + .me =THIS_MODULE , + }, + { + .name ="physdev" , + .family =NFPROTO_IPV6 , + .checkentry = physdev_mt_check, + .match = physdev_mt, + .matchsize =sizeof (struct xt_physdev_info ), + .me =THIS_MODULE , + }, };static int __init physdev_mt_init (void ) { -return xt_register_match (&physdev_mt_reg); +return xt_register_matches (physdev_mt_reg,ARRAY_SIZE (physdev_mt_reg)); } static void __exit physdev_mt_exit(void) { -xt_unregister_match (&physdev_mt_reg); +xt_unregister_matches (physdev_mt_reg,ARRAY_SIZE (physdev_mt_reg)); }module_init (physdev_mt_init);
net/netfilter/xt_realm.c +1 -1
@@ -33,7 +33,7 @@ static struct xt_match realm_mt_reg __read_mostly = { .matchsize = sizeof(struct xt_realm_info), .hooks = (1 <<NF_INET_POST_ROUTING ) | (1 <<NF_INET_FORWARD ) | (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN), - .family = NFPROTO_UNSPEC, + .family = NFPROTO_IPV4, .me =THIS_MODULE };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 576/776 ipvs: fix MTU check for GSO packets in tunnel mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingnan Zhang <[email protected]>
[ Upstream commit 67bf42cae41d847fd6e5749eb68278ca5d748b25 ]
Currently, IPVS skips MTU checks for GSO packets by excluding them with the !skb_is_gso(skb) condition. This creates problems when IPVS tunnel mode encapsulates GSO packets with IPIP headers.
The issue manifests in two ways:
1. MTU violation after encapsulation:
When a GSO packet passes through IPVS tunnel mode, the original MTU check is bypassed. After adding the IPIP tunnel header, the packet size may exceed the outgoing interface MTU, leading to unexpected fragmentation at the IP layer.
2. Fragmentation with problematic IP IDs:
When net.ipv4.vs.pmtu_disc=1 and a GSO packet with multiple segments is fragmented after encapsulation, each segment gets a sequentially incremented IP ID (0, 1, 2, ...). This happens because:
a) The GSO packet bypasses MTU check and gets encapsulated
b) At __ip_finish_output, the oversized GSO packet is split into separate SKBs (one per segment), with IP IDs incrementing
c) Each SKB is then fragmented again based on the actual MTU
This sequential IP ID allocation differs from the expected behavior and can cause issues with fragment reassembly and packet tracking.
Fix this by properly validating GSO packets using skb_gso_validate_network_len(). This function correctly validates whether the GSO segments will fit within the MTU after segmentation. If validation fails, send an ICMP Fragmentation Needed message to enable proper PMTU discovery.
--- net/netfilter/ipvs/ip_vs_xmit.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_xmit.c +15 -4
@@ -103,6 +103,18 @@ __ip_vs_dst_check(struct ip_vs_dest *dest)return dest_dst; } +/* Based on ip_exceeds_mtu(). */ +static bool ip_vs_exceeds_mtu (const struct sk_buff *skb,unsigned int mtu) +{ +if (skb->len <= mtu) +return false; + +if (skb_is_gso (skb) &&skb_gso_validate_network_len (skb, mtu)) +return false; + +return true; +} +static inline bool __mtu_check_toobig_v6 (const struct sk_buff *skb,u32 mtu) {
@@ -112,10 +124,9 @@ __mtu_check_toobig_v6(const struct sk_buff *skb, u32 mtu)*/ if (IP6CB (skb)->frag_max_size > mtu)return true;/* largest fragment violate MTU */ - } -else if (skb->len > mtu && !skb_is_gso (skb)) { + }else if (ip_vs_exceeds_mtu (skb, mtu))return true;/* Packet size violate MTU size */ - } +return false; }
@@ -240,7 +251,7 @@ static inline bool ensure_mtu_is_adequate(struct netns_ipvs *ipvs, int skb_af,return true;if (unlikely (ip_hdr (skb)->frag_off &htons (IP_DF ) && - skb->len > mtu && !skb_is_gso (skb) && +ip_vs_exceeds_mtu (skb, mtu) && !ip_vs_iph_icmp (ipvsh))) {icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_FRAG_NEEDED ,htonl (mtu));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 577/776 netfilter: nfnetlink_osf: fix out-of-bounds read on option matching
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit f5ca450087c3baf3651055e7a6de92600f827af3 ]
In nf_osf_match(), the nf_osf_hdr_ctx structure is initialized once and passed by reference to nf_osf_match_one() for each fingerprint checked. During TCP option parsing, nf_osf_match_one() advances the shared ctx->optp pointer.
If a fingerprint perfectly matches, the function returns early without restoring ctx->optp to its initial state. If the user has configured NF_OSF_LOGLEVEL_ALL, the loop continues to the next fingerprint. However, because ctx->optp was not restored, the next call to nf_osf_match_one() starts parsing from the end of the options buffer. This causes subsequent matches to read garbage data and fail immediately, making it impossible to log more than one match or logging incorrect matches.
Instead of using a shared ctx->optp pointer, pass the context as a constant pointer and use a local pointer (optp) for TCP option traversal. This makes nf_osf_match_one() strictly stateless from the caller's perspective, ensuring every fingerprint check starts at the correct option offset.
--- net/netfilter/nfnetlink_osf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
net/netfilter/nfnetlink_osf.c +8 -11
@@ -64,9 +64,9 @@ struct nf_osf_hdr_ctx {static bool nf_osf_match_one (const struct sk_buff *skb,const struct nf_osf_user_finger *f,int ttl_check, -struct nf_osf_hdr_ctx *ctx) +const struct nf_osf_hdr_ctx *ctx) { -const __u8 *optpinit = ctx->optp; +const __u8 *optp = ctx->optp;unsigned int check_WSS =0 ;int fmatch =FMATCH_WRONG ;int foptsize, optnum;
@@ -95,17 +95,17 @@ static bool nf_osf_match_one(const struct sk_buff *skb, check_WSS = f->wss.wc;for (optnum =0 ; optnum < f->opt_num; ++optnum) { -if (f->opt[optnum].kind == *ctx->optp) { +if (f->opt[optnum].kind == *optp) {__u32 len = f->opt[optnum].length; -const __u8 *optend = ctx->optp + len; +const __u8 *optend = optp + len; fmatch =FMATCH_OK ; -switch (*ctx->optp) { +switch (*optp) {case OSFOPT_MSS : - mss = ctx->optp[3 ]; + mss = optp[3 ]; mss <<=8 ; - mss |= ctx->optp[2 ]; + mss |= optp[2 ]; mss =ntohs ((__force __be16 )mss);break ;
@@ -113,7 +113,7 @@ static bool nf_osf_match_one(const struct sk_buff *skb,break ; } - ctx->optp = optend; + optp = optend; }else fmatch =FMATCH_OPT_WRONG ;
@@ -156,9 +156,6 @@ static bool nf_osf_match_one(const struct sk_buff *skb, } } -if (fmatch !=FMATCH_OK ) - ctx->optp = optpinit; -return fmatch ==FMATCH_OK ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 578/776 netfilter: nfnetlink_osf: fix potential NULL dereference in ttl check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 711987ba281fd806322a7cd244e98e2a81903114 ]
The nf_osf_ttl() function accessed skb->dev to perform a local interface address lookup without verifying that the device pointer was valid.
Additionally, the implementation utilized an in_dev_for_each_ifa_rcu loop to match the packet source address against local interface addresses. It assumed that packets from the same subnet should not see a decrement on the initial TTL. A packet might appear it is from the same subnet but it actually isn't especially in modern environments with containers and virtual switching.
Remove the device dereference and interface loop. Replace the logic with a switch statement that evaluates the TTL according to the ttl_check.
--- net/netfilter/nfnetlink_osf.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
net/netfilter/nfnetlink_osf.c +7 -15
@@ -31,26 +31,18 @@ EXPORT_SYMBOL_GPL(nf_osf_fingers);static inline int nf_osf_ttl (const struct sk_buff *skb,int ttl_check,unsigned char f_ttl) { -struct in_device *in_dev =__in_dev_get_rcu (skb->dev);const struct iphdr *ip =ip_hdr (skb); -const struct in_ifaddr *ifa; -int ret =0 ; -if (ttl_check ==NF_OSF_TTL_TRUE ) +switch (ttl_check) { +case NF_OSF_TTL_TRUE :return ip->ttl == f_ttl; -if (ttl_check ==NF_OSF_TTL_NOCHECK ) -return 1 ; -else if (ip->ttl <= f_ttl) +break ; +case NF_OSF_TTL_NOCHECK :return 1 ; - -in_dev_for_each_ifa_rcu (ifa, in_dev) { -if (inet_ifa_match (ip->saddr, ifa)) { - ret = (ip->ttl == f_ttl); -break ; - } +case NF_OSF_TTL_LESS : +default : +return ip->ttl <= f_ttl; } - -return ret; }struct nf_osf_hdr_ctx {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 579/776 slip: reject VJ receive packets on instances with no rstate array
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit e76607442d5b73e1ba6768f501ef815bb58c2c0e ]
slhc_init() accepts rslots == 0 as a valid configuration, with the documented meaning of 'no receive compression'. In that case the allocation loop in slhc_init() is skipped, so comp->rstate stays NULL and comp->rslot_limit stays 0 (from the kzalloc of struct slcompress).
The receive helpers do not defend against that configuration. slhc_uncompress() dereferences comp->rstate[x] when the VJ header carries an explicit connection ID, and slhc_remember() later assigns cs = &comp->rstate[...] after only comparing the packet's slot number to comp->rslot_limit. Because rslot_limit is 0, slot 0 passes the range check, and the code dereferences a NULL rstate.
The configuration is reachable in-tree through PPP. PPPIOCSMAXCID stores its argument in a signed int, and (val >> 16) uses arithmetic shift. Passing 0xffff0000 therefore sign-extends to -1, so val2 + 1 is 0 and ppp_generic.c ends up calling slhc_init(0, 1). Because /dev/ppp open is gated by ns_capable(CAP_NET_ADMIN), the whole path is reachable from an unprivileged user namespace. Once the malformed VJ state is installed, any inbound VJ-compressed or VJ-uncompressed frame that selects slot 0 crashes the kernel in softirq context:
Oops: general protection fault, probably for non-canonical
address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
RIP: 0010:slhc_uncompress (drivers/net/slip/slhc.c:519)
Call Trace:
<TASK>
ppp_receive_nonmp_frame (drivers/net/ppp/ppp_generic.c:2466)
ppp_input (drivers/net/ppp/ppp_generic.c:2359)
ppp_async_process (drivers/net/ppp/ppp_async.c:492)
tasklet_action_common (kernel/softirq.c:926)
handle_softirqs (kernel/softirq.c:623)
run_ksoftirqd (kernel/softirq.c:1055)
smpboot_thread_fn (kernel/smpboot.c:160)
kthread (kernel/kthread.c:436)
ret_from_fork (arch/x86/kernel/process.c:164)
</TASK>Reject the receive side on such instances instead of touching rstate. slhc_uncompress() falls through to its existing 'bad' label, which bumps sls_i_error and enters the toss state. slhc_remember() mirrors that with an explicit sls_i_error increment followed by slhc_toss(); the sls_i_runt counter is not used here because a missing rstate is an internal configuration state, not a runt packet.
The transmit path is unaffected: the only in-tree caller that picks rslots from userspace (ppp_generic.c) still supplies tslots >= 1, and slip.c always calls slhc_init(16, 16), so comp->tstate remains valid and slhc_compress() continues to work.
--- drivers/net/slip/slhc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/slip/slhc.c +6 -0
@@ -506,6 +506,8 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize) comp->sls_i_error++;return 0 ; } +if (!comp->rstate) + goto bad; changes = *cp++;if (changes &NEW_C ){/* Make sure the state index is in range, then grab the state.
@@ -649,6 +651,10 @@ slhc_remember(struct slcompress *comp, unsigned char *icp, int isize)struct cstate *cs;unsigned int ihl; +if (!comp->rstate) { + comp->sls_i_error++; +return slhc_toss (comp); + }/* The packet is shorter than a legal IP header. * Also make sure isize is positive. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 580/776 slip: bound decode() reads against the compressed packet length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 4c1367a2d7aad643a6f87c6931b13cc1a25e8ca7 ]
slhc_uncompress() parses a VJ-compressed TCP header by advancing a pointer through the packet via decode() and pull16(). Neither helper bounds-checks against isize, and decode() masks its return with & 0xffff so it can never return the -1 that callers test for -- those error paths are dead code.
A short compressed frame whose change byte requests optional fields lets decode() read past the end of the packet. The over-read bytes are folded into the cached cstate and reflected into subsequent reconstructed packets.
Make decode() and pull16() take the packet end pointer and return -1 when exhausted. Add a bounds check before the TCP-checksum read. The existing == -1 tests now do what they were always meant to.
--- drivers/net/slip/slhc.c | 43 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-)
drivers/net/slip/slhc.c +25 -18
@@ -80,9 +80,9 @@#include <asm/unaligned.h> static unsigned char *encode (unsigned char *cp,unsigned short n); -static long decode (unsigned char **cpp); +static long decode (unsigned char **cpp,const unsigned char *end);static unsigned char *put16 (unsigned char *cp,unsigned short x); -static unsigned short pull16 (unsigned char **cpp); +static long pull16 (unsigned char **cpp,const unsigned char *end);/* Allocate compression data structure * slots must be in range 0 to 255 (zero meaning no compression)
@@ -190,30 +190,34 @@ encode(unsigned char *cp, unsigned short n)return cp; } -/* Pull a 16-bit integer in host order from buffer in network byte order */ -static unsigned short -pull16 (unsigned char **cpp) +/* Pull a 16-bit integer in host order from buffer in network byte order. +* Returns -1 if the buffer is exhausted, otherwise the 16-bit value. +*/ +static long +pull16 (unsigned char **cpp,const unsigned char *end) { -short rval; +long rval; +if (*cpp +2 > end) +return -1 ; rval = *(*cpp)++; rval <<=8 ; rval |= *(*cpp)++;return rval; } -/* Decode a number */ +/* Decode a number. Returns -1 if the buffer is exhausted. */ static long -decode (unsigned char **cpp) +decode (unsigned char **cpp,const unsigned char *end) {int x; +if (*cpp >= end) +return -1 ; x = *(*cpp)++; -if (x ==0 ){ -return pull16 (cpp) &0xffff ;/* pull16 returns -1 on error */ - }else { -return x &0xff ;/* -1 if PULLCHAR returned error */ - } +if (x ==0 ) +return pull16 (cpp, end); +return x &0xff ; }/*
@@ -499,6 +503,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)struct cstate *cs;int len, hdrlen;unsigned char *cp = icp; +const unsigned char *end = icp + isize;/* We've got a compressed packet; read the change byte */ comp->sls_i_compressed++;
@@ -536,6 +541,8 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize) thp = &cs->cs_tcp; ip = &cs->cs_ip; +if (cp +2 > end) + goto bad; thp->check = *(__sum16 *)cp; cp +=2 ;
@@ -566,26 +573,26 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)default :if (changes &NEW_U ){ thp->urg =1 ; -if ((x =decode (&cp)) ==-1 ) { +if ((x =decode (&cp, end)) ==-1 ) { goto bad; } thp->urg_ptr =htons (x); }else thp->urg =0 ;if (changes &NEW_W ){ -if ((x =decode (&cp)) ==-1 ) { +if ((x =decode (&cp, end)) ==-1 ) { goto bad; } thp->window =htons (ntohs (thp->window) + x); }if (changes &NEW_A ){ -if ((x =decode (&cp)) ==-1 ) { +if ((x =decode (&cp, end)) ==-1 ) { goto bad; } thp->ack_seq =htonl (ntohl (thp->ack_seq) + x); }if (changes &NEW_S ){ -if ((x =decode (&cp)) ==-1 ) { +if ((x =decode (&cp, end)) ==-1 ) { goto bad; } thp->seq =htonl (ntohl (thp->seq) + x);
@@ -593,7 +600,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)break ; }if (changes &NEW_I ){ -if ((x =decode (&cp)) ==-1 ) { +if ((x =decode (&cp, end)) ==-1 ) { goto bad; } ip->id =htons (ntohs (ip->id) + x);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 581/776 arm64: dts: meson-gxl-p230: fix ethernet PHY interrupt number
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yan <[email protected]>
[ Upstream commit 174a0ef3b33434f475c87e66f37980e39b73805a ]
Correct the interrupt number assigned to the Realtek PHY in the p230
following the same logic as commit 3106507e1004 ("ARM64: dts: meson-gxm:
fix q200 interrupt number"),as reported in [PATCH 0/2] Ethernet PHY interrupt improvements [1].
[1] https://lore.kernel.org/all/[email protected]/
--- arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts +2 -1
@@ -86,7 +86,8 @@ external_phy: ethernet-phy@0 { reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>; interrupt-parent = <&gpio_intc>; - interrupts = <29 IRQ_TYPE_LEVEL_LOW>; + /* MAC_INTR on GPIOZ_15 */ + interrupts = <25 IRQ_TYPE_LEVEL_LOW>; eee-broken-1000t; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 582/776 ksmbd: destroy tree_conn_ida in ksmbd_session_destroy()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: DaeMyung Kang <[email protected]>
[ Upstream commit c049ee14eb4343b69b6f7755563f961f5e153423 ]
When per-session tree_conn_ida was converted from a dynamically allocated ksmbd_ida to an embedded struct ida, ksmbd_ida_free() was removed from ksmbd_session_destroy() but no matching ida_destroy() was added. The session is therefore freed with the IDA's backing xarray still intact.
The kernel IDA API expects ida_init() and ida_destroy() to be paired over an object's lifetime, so add the missing cleanup before the enclosing session is freed.
Also move ida_init() to right after the session is allocated so that it is always paired with the destroy call even on the early error paths of __session_create() (ksmbd_init_file_table() or __init_smb2_session() failures), both of which jump to the error label and invoke ksmbd_session_destroy() on a partially initialised session.
No leak has been observed in testing; this is a pairing fix to match the IDA lifetime rules, not a response to a reproduced regression.
--- fs/ksmbd/mgmt/user_session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ksmbd/mgmt/user_session.c +3 -2
@@ -153,6 +153,7 @@ void ksmbd_session_destroy(struct ksmbd_session *sess)free_channel_list (sess);kfree (sess->Preauth_HashValue);ksmbd_release_id (&session_ida, sess->id); +ida_destroy (&sess->tree_conn_ida);kfree (sess); }
@@ -382,6 +383,8 @@ static struct ksmbd_session *__session_create(int protocol)if (!sess)return NULL ; +ida_init (&sess->tree_conn_ida); +if (ksmbd_init_file_table (&sess->file_table)) goto error;
@@ -399,8 +402,6 @@ static struct ksmbd_session *__session_create(int protocol)if (ret) goto error; -ida_init (&sess->tree_conn_ida); -down_write (&sessions_table_lock);hash_add (sessions_table, &sess->hlist, sess->id);up_write (&sessions_table_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 583/776 ksmbd: scope conn->binding slowpath to bound sessions only
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit b0da97c034b6107d14e537e212d4ce8b22109a58 ]
When the binding SESSION_SETUP sets conn->binding = true, the flag stays set after the call so that the global session lookup in ksmbd_session_lookup_all() can find the session, which was not added to conn->sessions. Because the flag is connection-wide, the global lookup path will also resolve any other session by id if asked.
Tighten the global lookup so that the returned session must have this connection registered in its channel xarray (sess->ksmbd_chann_list). The channel entry is installed by the existing binding_session path in ntlm_authenticate()/krb5_authenticate() when a SESSION_SETUP completes successfully, so this condition is a strict equivalent of "this connection has been accepted as a channel of this session". Connections that have not bound to a given session cannot reach it via the global table.
The existing conn->binding gate for entering the slowpath is preserved so that non-binding connections keep the fast-path-only behavior, and the session->state check is unchanged.
--- fs/ksmbd/mgmt/user_session.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ksmbd/mgmt/user_session.c +6 -1
@@ -301,8 +301,13 @@ struct ksmbd_session *ksmbd_session_lookup_all(struct ksmbd_conn *conn,struct ksmbd_session *sess; sess =ksmbd_session_lookup (conn, id); -if (!sess && conn->binding) +if (!sess && conn->binding) { sess =ksmbd_session_lookup_slowpath (id); +if (sess && !xa_load (&sess->ksmbd_chann_list, (long )conn)) { +ksmbd_user_session_put (sess); + sess =NULL ; + } + }if (sess && sess->state !=SMB2_SESSION_VALID ) {ksmbd_user_session_put (sess); sess =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/776 net/rds: zero per-item info buffer before handing it to visitors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit c88eb7e8d8397a8c1db59c425332c5a30b2a1682 ]
rds_for_each_conn_info() and rds_walk_conn_path_info() both hand a caller-allocated on-stack u64 buffer to a per-connection visitor and then copy the full item_len bytes back to user space via rds_info_copy() regardless of how much of the buffer the visitor actually wrote.
rds_ib_conn_info_visitor() and rds6_ib_conn_info_visitor() only write a subset of their output struct when the underlying rds_connection is not in state RDS_CONN_UP (src/dst addr, tos, sl and the two GIDs via explicit memsets). Several u32 fields (max_send_wr, max_recv_wr, max_send_sge, rdma_mr_max, rdma_mr_size, cache_allocs) and the 2-byte alignment hole between sl and cache_allocs remain as whatever stack contents preceded the visitor call and are then memcpy_to_user()'d out to user space.
struct rds_info_rdma_connection and struct rds6_info_rdma_connection are the only rds_info_* structs in include/uapi/linux/rds.h that are not marked __attribute__((packed)), so they have a real alignment hole. The other info visitors (rds_conn_info_visitor, rds6_conn_info_visitor, rds_tcp_tc_info, ...) write all fields of their packed output struct today and are not known to be vulnerable, but a future visitor that adds a conditional write-path would have the same bug.
Reproduction on a kernel built without CONFIG_INIT_STACK_ALL_ZERO=y:
a local unprivileged user opens AF_RDS, sets SO_RDS_TRANSPORT=IB, binds to a local address on an RDMA-capable netdev (rxe soft-RoCE on any netdev is sufficient), sendto()'s any peer on the same subnet (fails cleanly but installs an rds_connection in the global hash in RDS_CONN_CONNECTING), then calls getsockopt(SOL_RDS, RDS_INFO_IB_CONNECTIONS). The returned 68-byte item contains 26 bytes of stack garbage including kernel text/data pointers:
0..7 0a 63 00 01 0a 63 00 02 src=10.99.0.1 dst=10.99.0.2
8..39 00 ... gids (memset-zeroed)
40..47 e0 92 a3 81 ff ff ff ff kernel pointer (max_send_wr)
48..55 7f 37 b5 81 ff ff ff ff kernel pointer (rdma_mr_max)
56..59 01 00 08 00 rdma_mr_size (garbage)
60..61 00 00 tos, sl
62..63 00 00 alignment padding
64..67 18 00 00 00 cache_allocs (garbage)Fix by zeroing the per-item buffer in both rds_for_each_conn_info() and rds_walk_conn_path_info() before invoking the visitor. This covers the IPv4/IPv6 IB visitors and hardens all current and future visitors against the same class of bug.
No functional change for visitors that fully populate their output.
Changes in v2:
- retarget at the net tree (subject prefix "[PATCH net v2]", net/rds: prefix in the title)
- pick up Reviewed-by tags from Sharath Srinivasan and Allison Henderson
--- net/rds/connection.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
net/rds/connection.c +14 -0
@@ -673,6 +673,13 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len, i++, head++) {hlist_for_each_entry_rcu (conn, head, c_hash_node) { +/* Zero the per-item buffer before handing it to the +* visitor so any field the visitor does not write - +* including implicit alignment padding - cannot leak +* stack contents to user space via rds_info_copy(). +*/ +memset (buffer,0 , item_len); +/* XXX no c_lock usage.. */ if (!visitor (conn, buffer))continue ;
@@ -722,6 +729,13 @@ static void rds_walk_conn_path_info(struct socket *sock, unsigned int len,*/ cp = conn->c_path; +/* Zero the per-item buffer for the same reason as +* rds_for_each_conn_info(): any byte the visitor +* does not write (including alignment padding) must +* not leak stack contents via rds_info_copy(). +*/ +memset (buffer,0 , item_len); +/* XXX no cp_lock usage.. */ if (!visitor (cp, buffer))continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/776 net_sched: sch_hhf: annotate data-races in hhf_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit a6edf2cd4156b71e07258876b7626692e158f7e8 ]
hhf_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path.
Add READ_ONCE()/WRITE_ONCE() annotations.
--- net/sched/sch_hhf.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
net/sched/sch_hhf.c +10 -9
@@ -198,7 +198,8 @@ static struct hh_flow_state *seek_list(const u32 hash,return NULL ;list_del (&flow->flowchain);kfree (flow); - q->hh_flows_current_cnt--; +WRITE_ONCE (q->hh_flows_current_cnt, + q->hh_flows_current_cnt -1 ); }else if (flow->hash_id == hash) {return flow; }
@@ -226,7 +227,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head, }if (q->hh_flows_current_cnt >= q->hh_flows_limit) { - q->hh_flows_overlimit++; +WRITE_ONCE (q->hh_flows_overlimit, q->hh_flows_overlimit +1 );return NULL ; }/* Create new entry. */
@@ -234,7 +235,7 @@ static struct hh_flow_state *alloc_new_hh(struct list_head *head,if (!flow)return NULL ; - q->hh_flows_current_cnt++; +WRITE_ONCE (q->hh_flows_current_cnt, q->hh_flows_current_cnt +1 );INIT_LIST_HEAD (&flow->flowchain);list_add_tail (&flow->flowchain, head);
@@ -309,7 +310,7 @@ static enum wdrr_bucket_idx hhf_classify(struct sk_buff *skb, struct Qdisc *sch)return WDRR_BUCKET_FOR_NON_HH ; flow->hash_id = hash; flow->hit_timestamp = now; - q->hh_flows_total_cnt++; +WRITE_ONCE (q->hh_flows_total_cnt, q->hh_flows_total_cnt +1 );/* By returning without updating counters in q->hhf_arrays, * we implicitly implement "shielding" (see Optimization O1).
@@ -403,7 +404,7 @@ static int hhf_enqueue(struct sk_buff *skb, struct Qdisc *sch,return NET_XMIT_SUCCESS ; prev_backlog = sch->qstats.backlog; - q->drop_overlimit++; +WRITE_ONCE (q->drop_overlimit, q->drop_overlimit +1 );/* Return Congestion Notification only if we dropped a packet from this * bucket. */
@@ -681,10 +682,10 @@ static int hhf_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct hhf_sched_data *q =qdisc_priv (sch);struct tc_hhf_xstats st = { - .drop_overlimit = q->drop_overlimit, - .hh_overlimit = q->hh_flows_overlimit, - .hh_tot_count = q->hh_flows_total_cnt, - .hh_cur_count = q->hh_flows_current_cnt, + .drop_overlimit =READ_ONCE (q->drop_overlimit), + .hh_overlimit =READ_ONCE (q->hh_flows_overlimit), + .hh_tot_count =READ_ONCE (q->hh_flows_total_cnt), + .hh_cur_count =READ_ONCE (q->hh_flows_current_cnt), };return gnet_stats_copy_app (d, &st,sizeof (st));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/776 net/sched: sch_pie: annotate data-races in pie_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5154561d9b119f781249f8e845fecf059b38b483 ]
pie_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path.
Add READ_ONCE()/WRITE_ONCE() annotations.
Alternative would be to acquire the qdisc spinlock, but our long-term goal is to make qdisc dump operations lockless as much as we can.
tc_pie_xstats fields don't need to be latched atomically, otherwise this bug would have been caught earlier.
--- include/net/pie.h | 2 +- net/sched/sch_pie.c | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-)
include/net/pie.h +1 -1
@@ -104,7 +104,7 @@ static inline void pie_vars_init(struct pie_vars *vars) vars->dq_tstamp =DTIME_INVALID ; vars->accu_prob =0 ; vars->dq_count =DQCOUNT_INVALID ; - vars->avg_dq_rate =0 ; +WRITE_ONCE (vars->avg_dq_rate,0 ); }static inline struct pie_skb_cb *get_pie_cb (const struct sk_buff *skb)
net/sched/sch_pie.c +19 -19
@@ -89,7 +89,7 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,bool enqueue = false;if (unlikely (qdisc_qlen (sch) >= sch->limit)) { - q->stats.overlimit++; +WRITE_ONCE (q->stats.overlimit, q->stats.overlimit +1 ); goto out; }
@@ -101,7 +101,7 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,/* If packet is ecn capable, mark it if drop probability * is lower than 10%, else drop it. */ - q->stats.ecn_mark++; +WRITE_ONCE (q->stats.ecn_mark, q->stats.ecn_mark +1 ); enqueue = true; }
@@ -111,15 +111,15 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (!q->params.dq_rate_estimator)pie_set_enqueue_time (skb); - q->stats.packets_in++; +WRITE_ONCE (q->stats.packets_in, q->stats.packets_in +1 );if (qdisc_qlen (sch) > q->stats.maxq) - q->stats.maxq =qdisc_qlen (sch); +WRITE_ONCE (q->stats.maxq,qdisc_qlen (sch));return qdisc_enqueue_tail (skb, sch); } out: - q->stats.dropped++; +WRITE_ONCE (q->stats.dropped, q->stats.dropped +1 ); q->vars.accu_prob =0 ;return qdisc_drop (skb, sch, to_free); }
@@ -263,11 +263,11 @@ void pie_process_dequeue(struct sk_buff *skb, struct pie_params *params, count = count / dtime;if (vars->avg_dq_rate ==0 ) - vars->avg_dq_rate = count; +WRITE_ONCE (vars->avg_dq_rate, count);else - vars->avg_dq_rate = +WRITE_ONCE (vars->avg_dq_rate, (vars->avg_dq_rate - - (vars->avg_dq_rate >>3 )) + (count >>3 ); + (vars->avg_dq_rate >>3 )) + (count >>3 ));/* If the queue has receded below the threshold, we hold * on to the last drain rate calculated, else we reset
@@ -377,7 +377,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,if (delta >0 ) {/* prevent overflow */ if (vars->prob < oldprob) { - vars->prob =MAX_PROB ; +WRITE_ONCE (vars->prob,MAX_PROB );/* Prevent normalization error. If probability is at * maximum value already, we normalize it here, and * skip the check to do a non-linear drop in the next
@@ -388,7 +388,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars, }else {/* prevent underflow */ if (vars->prob > oldprob) - vars->prob =0 ; +WRITE_ONCE (vars->prob,0 ); }/* Non-linear drop in probability: Reduce drop probability quickly if
@@ -399,7 +399,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,/* Reduce drop probability to 98.4% */ vars->prob -= vars->prob /64 ; - vars->qdelay = qdelay; +WRITE_ONCE (vars->qdelay, qdelay); vars->backlog_old = backlog;/* We restart the measurement cycle if the following conditions are met
@@ -494,21 +494,21 @@ static int pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d)struct pie_sched_data *q =qdisc_priv (sch);struct tc_pie_xstats st = { .prob = q->vars.prob <<BITS_PER_BYTE , - .delay = ((u32 )PSCHED_TICKS2NS (q->vars.qdelay)) / + .delay = ((u32 )PSCHED_TICKS2NS (READ_ONCE (q->vars.qdelay))) /NSEC_PER_USEC , - .packets_in = q->stats.packets_in, - .overlimit = q->stats.overlimit, - .maxq = q->stats.maxq, - .dropped = q->stats.dropped, - .ecn_mark = q->stats.ecn_mark, + .packets_in =READ_ONCE (q->stats.packets_in), + .overlimit =READ_ONCE (q->stats.overlimit), + .maxq =READ_ONCE (q->stats.maxq), + .dropped =READ_ONCE (q->stats.dropped), + .ecn_mark =READ_ONCE (q->stats.ecn_mark), };/* avg_dq_rate is only valid if dq_rate_estimator is enabled */ st.dq_rate_estimating = q->params.dq_rate_estimator;/* unscale and return dq_rate in bytes per sec */ -if (q->params.dq_rate_estimator) - st.avg_dq_rate = q->vars.avg_dq_rate * +if (st.dq_rate_estimating) + st.avg_dq_rate =READ_ONCE (q->vars.avg_dq_rate) * (PSCHED_TICKS_PER_SEC ) >>PIE_SCALE ;return gnet_stats_copy_app (d, &st,sizeof (st));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/776 net/sched: sch_fq_codel: remove data-races from fq_codel_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit bbfaa73ea6871db03dc05d7f05f00557a8981f25 ]
fq_codel_dump_stats() acquires the qdisc spinlock a bit too late.
Move this acquisition before we fill st.qdisc_stats with live data.
--- net/sched/sch_fq_codel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sched/sch_fq_codel.c +2 -1
@@ -559,6 +559,8 @@ static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) };struct list_head *pos; +sch_tree_lock (sch); + st.qdisc_stats.maxpacket = q->cstats.maxpacket; st.qdisc_stats.drop_overlimit = q->drop_overlimit; st.qdisc_stats.ecn_mark = q->cstats.ecn_mark;
@@ -567,7 +569,6 @@ static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) st.qdisc_stats.memory_usage = q->memory_usage; st.qdisc_stats.drop_overmemory = q->drop_overmemory; -sch_tree_lock (sch);list_for_each (pos, &q->new_flows) st.qdisc_stats.new_flows_len++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/776 net: sched: gred/red: remove unused variables in struct red_stats
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchao Shao <[email protected]>
[ Upstream commit 4516c873e3b55856012ddd6db9d4366ce3c60c5d ]
The variable "other" in the struct red_stats is not used. Remove it.
Stable-dep-of: a8f5192809ca ("net/sched: sch_red: annotate data-races in red_dump_stats()")
--- include/net/red.h | 1 - net/sched/sch_gred.c | 3 --- net/sched/sch_red.c | 1 - 3 files changed, 5 deletions(-)
include/net/red.h +0 -1
@@ -122,7 +122,6 @@ struct red_stats {u32 forced_drop;/* Forced drops, qavg > max_thresh */ u32 forced_mark;/* Forced marks, qavg > max_thresh */ u32 pdrop;/* Drops due to queue limits */ -u32 other;/* Drops due to drop() calls */ };struct red_parms {
net/sched/sch_gred.c +0 -3
@@ -817,7 +817,6 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb) opt.Wlog = q->parms.Wlog; opt.Plog = q->parms.Plog; opt.Scell_log = q->parms.Scell_log; - opt.other = q->stats.other; opt.early = q->stats.prob_drop; opt.forced = q->stats.forced_drop; opt.pdrop = q->stats.pdrop;
@@ -883,8 +882,6 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb) goto nla_put_failure;if (nla_put_u32 (skb,TCA_GRED_VQ_STAT_PDROP , q->stats.pdrop)) goto nla_put_failure; -if (nla_put_u32 (skb,TCA_GRED_VQ_STAT_OTHER , q->stats.other)) - goto nla_put_failure;nla_nest_end (skb, vq); }
net/sched/sch_red.c +0 -1
@@ -463,7 +463,6 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d) } st.early = q->stats.prob_drop + q->stats.forced_drop; st.pdrop = q->stats.pdrop; - st.other = q->stats.other; st.marked = q->stats.prob_mark + q->stats.forced_mark;return gnet_stats_copy_app (d, &st,sizeof (st));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/776 net/sched: sch_red: annotate data-races in red_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit a8f5192809caf636d05ba47c144f282cfd0e3839 ]
red_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path.
Add READ_ONCE()/WRITE_ONCE() annotations.
Alternative would be to acquire the qdisc spinlock, but our long-term goal is to make qdisc dump operations lockless as much as we can.
tc_red_xstats fields don't need to be latched atomically, otherwise this bug would have been caught earlier.
--- net/sched/sch_red.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
net/sched/sch_red.c +21 -10
@@ -89,17 +89,20 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,case RED_PROB_MARK :qdisc_qstats_overlimit (sch);if (!red_use_ecn (q)) { - q->stats.prob_drop++; +WRITE_ONCE (q->stats.prob_drop, + q->stats.prob_drop +1 ); goto congestion_drop; }if (INET_ECN_set_ce (skb)) { - q->stats.prob_mark++; +WRITE_ONCE (q->stats.prob_mark, + q->stats.prob_mark +1 ); skb =tcf_qevent_handle (&q->qe_mark, sch, skb, to_free, &ret);if (!skb)return NET_XMIT_CN | ret; }else if (!red_use_nodrop (q)) { - q->stats.prob_drop++; +WRITE_ONCE (q->stats.prob_drop, + q->stats.prob_drop +1 ); goto congestion_drop; }
@@ -109,17 +112,20 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,case RED_HARD_MARK :qdisc_qstats_overlimit (sch);if (red_use_harddrop (q) || !red_use_ecn (q)) { - q->stats.forced_drop++; +WRITE_ONCE (q->stats.forced_drop, + q->stats.forced_drop +1 ); goto congestion_drop; }if (INET_ECN_set_ce (skb)) { - q->stats.forced_mark++; +WRITE_ONCE (q->stats.forced_mark, + q->stats.forced_mark +1 ); skb =tcf_qevent_handle (&q->qe_mark, sch, skb, to_free, &ret);if (!skb)return NET_XMIT_CN | ret; }else if (!red_use_nodrop (q)) { - q->stats.forced_drop++; +WRITE_ONCE (q->stats.forced_drop, + q->stats.forced_drop +1 ); goto congestion_drop; }
@@ -133,7 +139,8 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch, sch->qstats.backlog += len; sch->q.qlen++; }else if (net_xmit_drop_count (ret)) { - q->stats.pdrop++; +WRITE_ONCE (q->stats.pdrop, + q->stats.pdrop +1 );qdisc_qstats_drop (sch); }return ret;
@@ -461,9 +468,13 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d) dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_QDISC_RED , &hw_stats_request); } - st.early = q->stats.prob_drop + q->stats.forced_drop; - st.pdrop = q->stats.pdrop; - st.marked = q->stats.prob_mark + q->stats.forced_mark; + st.early =READ_ONCE (q->stats.prob_drop) + +READ_ONCE (q->stats.forced_drop); + + st.pdrop =READ_ONCE (q->stats.pdrop); + + st.marked =READ_ONCE (q->stats.prob_mark) + +READ_ONCE (q->stats.forced_mark);return gnet_stats_copy_app (d, &st,sizeof (st)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/776 net/sched: sch_sfb: annotate data-races in sfb_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 1ada03fdef82d3d7d2edb9dcd3acc91917675e48 ]
sfb_dump_stats() only runs with RTNL held, reading fields that can be changed in qdisc fast path.
Add READ_ONCE()/WRITE_ONCE() annotations.
Alternative would be to acquire the qdisc spinlock, but our long-term goal is to make qdisc dump operations lockless as much as we can.
tc_sfb_xstats fields don't need to be latched atomically, otherwise this bug would have been caught earlier.
--- net/sched/sch_sfb.c | 54 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-)
net/sched/sch_sfb.c +32 -22
@@ -130,7 +130,7 @@ static void increment_one_qlen(u32 sfbhash, u32 slot, struct sfb_sched_data *q) sfbhash >>=SFB_BUCKET_SHIFT ;if (b[hash].qlen <0xFFFF ) - b[hash].qlen++; +WRITE_ONCE (b[hash].qlen, b[hash].qlen +1 ); b +=SFB_NUMBUCKETS ;/* next level */ } }
@@ -159,7 +159,7 @@ static void decrement_one_qlen(u32 sfbhash, u32 slot, sfbhash >>=SFB_BUCKET_SHIFT ;if (b[hash].qlen >0 ) - b[hash].qlen--; +WRITE_ONCE (b[hash].qlen, b[hash].qlen -1 ); b +=SFB_NUMBUCKETS ;/* next level */ } }
@@ -179,12 +179,12 @@ static void decrement_qlen(const struct sk_buff *skb, struct sfb_sched_data *q)static void decrement_prob (struct sfb_bucket *b,struct sfb_sched_data *q) { - b->p_mark =prob_minus (b->p_mark, q->decrement); +WRITE_ONCE (b->p_mark,prob_minus (b->p_mark, q->decrement)); }static void increment_prob (struct sfb_bucket *b,struct sfb_sched_data *q) { - b->p_mark =prob_plus (b->p_mark, q->increment); +WRITE_ONCE (b->p_mark,prob_plus (b->p_mark, q->increment)); }static void sfb_zero_all_buckets (struct sfb_sched_data *q)
@@ -202,11 +202,14 @@ static u32 sfb_compute_qlen(u32 *prob_r, u32 *avgpm_r, const struct sfb_sched_daconst struct sfb_bucket *b = &q->bins[q->slot].bins[0 ][0 ];for (i =0 ; i <SFB_LEVELS *SFB_NUMBUCKETS ; i++) { -if (qlen < b->qlen) - qlen = b->qlen; - totalpm += b->p_mark; -if (prob < b->p_mark) - prob = b->p_mark; +u32 b_qlen =READ_ONCE (b->qlen); +u32 b_mark =READ_ONCE (b->p_mark); + +if (qlen < b_qlen) + qlen = b_qlen; + totalpm += b_mark; +if (prob < b_mark) + prob = b_mark; b++; } *prob_r = prob;
@@ -294,7 +297,8 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (unlikely (sch->q.qlen >= q->limit)) {qdisc_qstats_overlimit (sch); - q->stats.queuedrop++; +WRITE_ONCE (q->stats.queuedrop, + q->stats.queuedrop +1 ); goto drop; }
@@ -347,7 +351,8 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,if (unlikely (minqlen >= q->max)) {qdisc_qstats_overlimit (sch); - q->stats.bucketdrop++; +WRITE_ONCE (q->stats.bucketdrop, + q->stats.bucketdrop +1 ); goto drop; }
@@ -373,7 +378,8 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, }if (sfb_rate_limit (skb, q)) {qdisc_qstats_overlimit (sch); - q->stats.penaltydrop++; +WRITE_ONCE (q->stats.penaltydrop, + q->stats.penaltydrop +1 ); goto drop; } goto enqueue;
@@ -388,14 +394,17 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,* In either case, we want to start dropping packets. */ if (r < (p_min -SFB_MAX_PROB /2 ) *2 ) { - q->stats.earlydrop++; +WRITE_ONCE (q->stats.earlydrop, + q->stats.earlydrop +1 ); goto drop; } }if (INET_ECN_set_ce (skb)) { - q->stats.marked++; +WRITE_ONCE (q->stats.marked, + q->stats.marked +1 ); }else { - q->stats.earlydrop++; +WRITE_ONCE (q->stats.earlydrop, + q->stats.earlydrop +1 ); goto drop; } }
@@ -408,7 +417,8 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, sch->q.qlen++;increment_qlen (&cb, q); }else if (net_xmit_drop_count (ret)) { - q->stats.childdrop++; +WRITE_ONCE (q->stats.childdrop, + q->stats.childdrop +1 );qdisc_qstats_drop (sch); }return ret;
@@ -597,12 +607,12 @@ static int sfb_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct sfb_sched_data *q =qdisc_priv (sch);struct tc_sfb_xstats st = { - .earlydrop = q->stats.earlydrop, - .penaltydrop = q->stats.penaltydrop, - .bucketdrop = q->stats.bucketdrop, - .queuedrop = q->stats.queuedrop, - .childdrop = q->stats.childdrop, - .marked = q->stats.marked, + .earlydrop =READ_ONCE (q->stats.earlydrop), + .penaltydrop =READ_ONCE (q->stats.penaltydrop), + .bucketdrop =READ_ONCE (q->stats.bucketdrop), + .queuedrop =READ_ONCE (q->stats.queuedrop), + .childdrop =READ_ONCE (q->stats.childdrop), + .marked =READ_ONCE (q->stats.marked), }; st.maxqlen =sfb_compute_qlen (&st.maxprob, &st.avgprob, q);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/776 nfp: fix swapped arguments in nfp_encode_basic_qdr() calls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kodanev <[email protected]>
[ Upstream commit 4078c5611d7585548b249377ebd60c272e410490 ]
There is a mismatch between the passed arguments and the actual nfp_encode_basic_qdr() function parameter names:
static int nfp_encode_basic_qdr(u64 addr, int dest_island, int cpp_tgt,
int mode, bool addr40, int isld1, int isld0)
{
...But "dest_island" and "cpp_tgt" are swapped at every call-site. For example:
return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
mode, addr40, isld1, isld0);
As a result, nfp_encode_basic_qdr() receives "dest_island" as CPP target type, which is always NFP_CPP_TARGET_QDR(2) for these calls, and "cpp_tgt" as the destination island ID, which can accidentally match or be outside the valid NFP_CPP_TARGET_* types (e.g. '-1' for any destination).
Since code already worked for years, also add extra pr_warn() to error paths in nfp_encode_basic_qdr() to help identify any potential address verification failures.
Detected using the static analysis tool - Svace.
--- .../ethernet/netronome/nfp/nfpcore/nfp_target.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_target.c +11 -6
@@ -435,12 +435,17 @@ static int nfp_encode_basic_qdr(u64 addr, int dest_island, int cpp_tgt,/* Full Island ID and channel bits overlap? */ ret =nfp_decode_basic (addr, &v, cpp_tgt, mode, addr40, isld1, isld0); -if (ret) +if (ret) { +pr_warn ("%s: decode dest_island failed: %d\n" , __func__, ret);return ret; + }/* The current address won't go where expected? */ -if (dest_island !=-1 && dest_island != v) +if (dest_island !=-1 && dest_island != v) { +pr_warn ("%s: dest_island mismatch: current (%d) != decoded (%d)\n" , + __func__, dest_island, v);return -EINVAL ; + }/* If dest_island was -1, we don't care where it goes. */ return 0 ;
@@ -493,7 +498,7 @@ static int nfp_encode_basic(u64 *addr, int dest_island, int cpp_tgt,* the address but we can verify if the existing * contents will point to a valid island. */ -return nfp_encode_basic_qdr (*addr, cpp_tgt, dest_island, +return nfp_encode_basic_qdr (*addr, dest_island, cpp_tgt, mode, addr40, isld1, isld0); iid_lsb = addr40 ?34 :26 ;
@@ -504,7 +509,7 @@ static int nfp_encode_basic(u64 *addr, int dest_island, int cpp_tgt,return 0 ;case 1 :if (cpp_tgt ==NFP_CPP_TARGET_QDR && !addr40) -return nfp_encode_basic_qdr (*addr, cpp_tgt, dest_island, +return nfp_encode_basic_qdr (*addr, dest_island, cpp_tgt, mode, addr40, isld1, isld0); idx_lsb = addr40 ?39 :31 ;
@@ -530,7 +535,7 @@ static int nfp_encode_basic(u64 *addr, int dest_island, int cpp_tgt,* be set before hand and with them select an island. * So we need to confirm that it's at least plausible. */ -return nfp_encode_basic_qdr (*addr, cpp_tgt, dest_island, +return nfp_encode_basic_qdr (*addr, dest_island, cpp_tgt, mode, addr40, isld1, isld0);/* Make sure we compare against isldN values
@@ -551,7 +556,7 @@ static int nfp_encode_basic(u64 *addr, int dest_island, int cpp_tgt,* iid<1> = addr<30> = channel<0> * channel<1> = addr<31> = Index */ -return nfp_encode_basic_qdr (*addr, cpp_tgt, dest_island, +return nfp_encode_basic_qdr (*addr, dest_island, cpp_tgt, mode, addr40, isld1, isld0); isld[0 ] &= ~3 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/776 tipc: fix double-free in tipc_buf_append()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit d293ca716e7d5dffdaecaf6b9b2f857a33dc3d3a ]
tipc_msg_validate() can potentially reallocate the skb it is validating, freeing the old one. In tipc_buf_append(), it was being called with a pointer to a local variable which was a copy of the caller's skb pointer.
If the skb was reallocated and validation subsequently failed, the error handling path would free the original skb pointer, which had already been freed, leading to double-free.
Fix this by checking if head now points to a newly allocated reassembled skb. If it does, reassign *headbuf for later freeing operations.
--- net/tipc/msg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
net/tipc/msg.c +13 -1
@@ -177,8 +177,20 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)if (fragid ==LAST_FRAGMENT ) {TIPC_SKB_CB (head)->validated =0 ; -if (unlikely (!tipc_msg_validate (&head))) + +/* If the reassembled skb has been freed in +* tipc_msg_validate() because of an invalid truesize, +* then head will point to a newly allocated reassembled +* skb, while *headbuf points to freed reassembled skb. +* In such cases, correct *headbuf for freeing the newly +* allocated reassembled skb later. +*/ +if (unlikely (!tipc_msg_validate (&head))) { +if (head != *headbuf) + *headbuf = head; goto err; + } + *buf = head;TIPC_SKB_CB (head)->tail =NULL ; *headbuf =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/776 vhost_net: fix sleeping with preempt-disabled in vhost_net_busy_poll()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit e08a9fac5cf8c3fecf4755e7e3ac059f78b8f83d ]
syzbot reported "sleeping function called from invalid context" in vhost_net_busy_poll().
Commit 030881372460 ("vhost_net: basic polling support") introduced a busy-poll loop and preempt_{disable,enable}() around it, where each iteration calls a sleepable function inside the loop.
The purpose of disabling preemption was to keep local_clock()-based timeout accounting on a single CPU, rather than as a requirement of busy-poll itself:
https://lore.kernel.org/[email protected]
Quoted 1 line
From this perspective,
migrate_disable()is sufficient here, so replace
preempt_disable() with migrate_disable(), avoiding sleepable accesses from a preempt-disabled context.
--- drivers/vhost/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vhost/net.c +2 -2
@@ -545,7 +545,7 @@ static void vhost_net_busy_poll(struct vhost_net *net, busyloop_timeout = poll_rx ? rvq->busyloop_timeout: tvq->busyloop_timeout; -preempt_disable (); +migrate_disable (); endtime =busy_clock () + busyloop_timeout;while (vhost_can_busy_poll (endtime)) {
@@ -562,7 +562,7 @@ static void vhost_net_busy_poll(struct vhost_net *net,cpu_relax (); } -preempt_enable (); +migrate_enable ();if (poll_rx ||sock_has_rx_data (sock))vhost_net_busy_poll_try_queue (net, vq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/776 fs/adfs: validate nzones in adfs_validate_bblk()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bae Yeonju <[email protected]>
[ Upstream commit dd9d3e16c2d5fa166e13dce07413be51f42c8f5d ]
Reject ADFS disc records with a zero zone count during boot block validation, before the disc record is used.
When nzones is 0, adfs_read_map() passes it to kmalloc_array(0, ...) which returns ZERO_SIZE_PTR, and adfs_map_layout() then writes to dm[-1], causing an out-of-bounds write before the allocated buffer.
adfs_validate_dr0() already rejects nzones != 1 for old-format images. Add the equivalent check to adfs_validate_bblk() for new-format images so that a crafted image with nzones == 0 is rejected at probe time.
Found by syzkaller.
--- fs/adfs/super.c | 3 +++ 1 file changed, 3 insertions(+)
fs/adfs/super.c +3 -0
@@ -343,6 +343,9 @@ static int adfs_validate_bblk(struct super_block *sb, struct buffer_head *bh,if (adfs_checkdiscrecord (dr))return -EILSEQ ; +if ((dr->nzones | dr->nzones_high <<8 ) ==0 ) +return -EILSEQ ; + *drp = dr;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/776 rtc: abx80x: Disable alarm feature if no interrupt attached
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anthony Pighin (Nokia) <[email protected]>
[ Upstream commit 0fedce7244e4b85c049ce579c87e298a1b0b811d ]
Commit 795cda8338ea ("rtc: interface: Fix long-standing race when setting alarm") exposed an issue where the rtc-abx80x driver does not clear the alarm feature bit, but instead relies on the set_alarm operation to return invalid.
For example, when a RTC_UIE_ON ioctl is handled, it should abort at the feature validation. Instead, it proceeds to the rtc_timer_enqueue(), which used to return an error from the set_alarm call. However, following the race condition handling, which likely should not be discarding predecing errors, a success condition is returned to the ioctl() caller. This results in (for example):
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
Notwithstanding the validity of the race condition handling, if an interrupt wasn't specified, or could not be attached, the driver should clear the alarm feature bit.
--- drivers/rtc/rtc-abx80x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rtc/rtc-abx80x.c +2 -0
@@ -836,6 +836,8 @@ static int abx80x_probe(struct i2c_client *client, client->irq =0 ; } } +if (client->irq <=0 ) +clear_bit (RTC_FEATURE_ALARM , priv->rtc->features); err =rtc_add_group (priv->rtc, &rtc_calib_attr_group);if (err) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/776 fbdev: offb: fix PCI device reference leak on probe failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 869b93ba04088713596e68453c1146f52f713290 ]
offb_init_nodriver() gets a referenced PCI device with pci_get_device(). If pci_enable_device() fails, the function returns without dropping that reference.
Release the PCI device reference before returning from the pci_enable_device() failure path.
--- drivers/video/fbdev/offb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/video/fbdev/offb.c +6 -1
@@ -643,8 +643,13 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) vid =be32_to_cpup (vidp); did =be32_to_cpup (didp); pdev =pci_get_device (vid, did,NULL ); -if (!pdev ||pci_enable_device (pdev)) +if (!pdev)return ; + +if (pci_enable_device (pdev)) { +pci_dev_put (pdev); +return ; + } }#endif /* kludge for valkyrie */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/776 mailbox: mailbox-test: free channels on probe error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit c02053a9055d5fdfd32432287cca8958db1d5bc5 ]
On probe error, free the previously obtained channels. This not only prevents a leak, but also UAF scenarios because the client structure will be removed nonetheless because it was allocated with devm.
--- drivers/mailbox/mailbox-test.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/mailbox/mailbox-test.c +12 -3
@@ -405,18 +405,27 @@ static int mbox_test_probe(struct platform_device *pdev)if (tdev->rx_channel) { tdev->rx_buffer =devm_kzalloc (&pdev->dev,MBOX_MAX_MSG_LEN ,GFP_KERNEL ); -if (!tdev->rx_buffer) -return -ENOMEM ; +if (!tdev->rx_buffer) { + ret = -ENOMEM ; + goto err_free_chans; + } } ret =mbox_test_add_debugfs (pdev, tdev);if (ret) -return ret; + goto err_free_chans;init_waitqueue_head (&tdev->waitq);dev_info (&pdev->dev,"Successfully registered\n" );return 0 ; + +err_free_chans: +if (tdev->tx_channel) +mbox_free_channel (tdev->tx_channel); +if (tdev->rx_channel) +mbox_free_channel (tdev->rx_channel); +return ret; }static int mbox_test_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/776 cgroup/rdma: fix integer overflow in rdmacg_try_charge()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: cuitao <[email protected]>
[ Upstream commit c802f460dd485c1332b5a35e7adcfb2bc22536a2 ]
The expression rpool->resources[index].usage + 1 is computed in int arithmetic before being assigned to s64 variable new. When usage equals INT_MAX (the default "max" value), the addition overflows to INT_MIN. This negative value then passes the new > max check incorrectly, allowing a charge that should be rejected and corrupting usage to negative.
Fix by casting usage to s64 before the addition so the arithmetic is done in 64-bit.
--- kernel/cgroup/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/rdma.c +1 -1
@@ -281,7 +281,7 @@ int rdmacg_try_charge(struct rdma_cgroup **rdmacg, ret =PTR_ERR (rpool); goto err; }else { - new = rpool->resources[index].usage +1 ; + new = (s64 )rpool->resources[index].usage +1 ;if (new > rpool->resources[index].max) { ret = -EAGAIN ; goto err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/776 mailbox: add sanity check for channel array
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit c1aad75595fb67edc7fda8af249d3b886efa1be9 ]
Fail gracefully if there is no channel array attached to the mailbox controller. Otherwise the later dereference will cause an OOPS which might not be seen because mailbox controllers might instantiate very early. Remove the comment explaining the obvious while here.
--- drivers/mailbox/mailbox.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mailbox/mailbox.c +1 -2
@@ -484,8 +484,7 @@ int mbox_controller_register(struct mbox_controller *mbox) {int i, txdone; -/* Sanity check */ -if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans) +if (!mbox || !mbox->dev || !mbox->ops || !mbox->chans || !mbox->num_chans)return -EINVAL ;if (mbox->txdone_irq)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/776 mailbox: mailbox-test: dont free the reused channel
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 88ebadbf0deefdaccdab868b44ff70a0a257f473 ]
The RX channel can be aliased to the TX channel if it has a different MMIO. This special case needs to be handled when freeing the channels otherwise a double-free occurs.
--- drivers/mailbox/mailbox-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/mailbox-test.c +2 -2
@@ -423,7 +423,7 @@ static int mbox_test_probe(struct platform_device *pdev) err_free_chans:if (tdev->tx_channel)mbox_free_channel (tdev->tx_channel); -if (tdev->rx_channel) +if (tdev->rx_channel && tdev->rx_channel != tdev->tx_channel)mbox_free_channel (tdev->rx_channel);return ret; }
@@ -436,7 +436,7 @@ static int mbox_test_remove(struct platform_device *pdev)if (tdev->tx_channel)mbox_free_channel (tdev->tx_channel); -if (tdev->rx_channel) +if (tdev->rx_channel && tdev->rx_channel != tdev->tx_channel)mbox_free_channel (tdev->rx_channel);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/776 mailbox: mailbox-test: initialize struct earlier
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit bbcf9af68bfedb3d9cc3c7eae62f5c844d8b78b9 ]
The waitqueue must be initialized before the debugfs files are created because from that time, requests from userspace can already be made. Similarily, drvdata and spinlock needs to be initialized before we request the channel, otherwise dangling irqs might run into problems like a NULL pointer exception.
--- drivers/mailbox/mailbox-test.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/mailbox/mailbox-test.c +6 -7
@@ -365,6 +365,12 @@ static int mbox_test_probe(struct platform_device *pdev)if (!tdev)return -ENOMEM ; + tdev->dev = &pdev->dev; +spin_lock_init (&tdev->lock); +mutex_init (&tdev->mutex); +init_waitqueue_head (&tdev->waitq); +platform_set_drvdata (pdev, tdev); +/* It's okay for MMIO to be NULL */ res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); tdev->tx_mmio =devm_ioremap_resource (&pdev->dev, res);
@@ -396,12 +402,6 @@ static int mbox_test_probe(struct platform_device *pdev)if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) tdev->rx_channel = tdev->tx_channel; - tdev->dev = &pdev->dev; -platform_set_drvdata (pdev, tdev); - -spin_lock_init (&tdev->lock); -mutex_init (&tdev->mutex); -if (tdev->rx_channel) { tdev->rx_buffer =devm_kzalloc (&pdev->dev,MBOX_MAX_MSG_LEN ,GFP_KERNEL );
@@ -415,7 +415,6 @@ static int mbox_test_probe(struct platform_device *pdev)if (ret) goto err_free_chans; -init_waitqueue_head (&tdev->waitq);dev_info (&pdev->dev,"Successfully registered\n" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/776 mailbox: mailbox-test: make data_ready a per-instance variable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 6e937f4e769e60947909e3525965f0137b9039e8 ]
While not the default case, multiple tests can be run simultaneously. Then, data_ready being a global variable will be overwritten and the per-instance lock will not help. Turn the global variable into a per-instance one to avoid this problem.
--- drivers/mailbox/mailbox-test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mailbox/mailbox-test.c +4 -5
@@ -27,8 +27,6 @@#define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \ (MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE)) -static bool mbox_data_ready; -struct mbox_test_device {struct device *dev;void __iomem *tx_mmio;
@@ -41,6 +39,7 @@ struct mbox_test_device {spinlock_t lock;struct mutex mutex;wait_queue_head_t waitq; +bool data_ready;struct fasync_struct *async_queue;struct dentry *root_debugfs_dir; };
@@ -161,7 +160,7 @@ static bool mbox_test_message_data_ready(struct mbox_test_device *tdev)unsigned long flags;spin_lock_irqsave (&tdev->lock, flags); - data_ready = mbox_data_ready; + data_ready = tdev->data_ready;spin_unlock_irqrestore (&tdev->lock, flags);return data_ready;
@@ -226,7 +225,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf, *(touser + l) ='\0' ;memset (tdev->rx_buffer,0 ,MBOX_MAX_MSG_LEN ); - mbox_data_ready = false; + tdev->data_ready = false;spin_unlock_irqrestore (&tdev->lock, flags);
@@ -296,7 +295,7 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) message, MBOX_MAX_MSG_LEN);memcpy (tdev->rx_buffer, message,MBOX_MAX_MSG_LEN ); } - mbox_data_ready = true; + tdev->data_ready = true;spin_unlock_irqrestore (&tdev->lock, flags);wake_up_interruptible (&tdev->waitq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/776 btrfs: fix double-decrement of bytes_may_use in submit_one_async_extent()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Harmstone <[email protected]>
[ Upstream commit 82323b1a7088b7a5c3e528a5d634bff447fa286f ]
submit_one_async_extent() calls btrfs_reserve_extent(), which decrements bytes_may_use. If the call btrfs_create_io_em() fails, we jump to out_free_reserve, which calls extent_clear_unlock_delalloc().
Because we're specifying EXTENT_DO_ACCOUNTING, i.e. EXTENT_CLEAR_META_RESV | EXTENT_CLEAR_DATA_RESV, this decreases bytes_may_use again. This can lead to problems later on, as an initial write can fail only for the writeback to silently ENOSPC.
Fix this by replacing EXTENT_DO_ACCOUNTING with EXTENT_CLEAR_META_RESV. This parallels a4fe134fc1d8eb ("btrfs: fix a double release on reserved extents in cow_one_range()"), which is the same fix in cow_one_range().
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -1001,7 +1001,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) async_extent->ram_size -1 ,NULL ,EXTENT_LOCKED |EXTENT_DELALLOC |EXTENT_DELALLOC_NEW | -EXTENT_DEFRAG |EXTENT_DO_ACCOUNTING , +EXTENT_DEFRAG |EXTENT_CLEAR_META_RESV ,PAGE_UNLOCK |PAGE_START_WRITEBACK | PAGE_END_WRITEBACK | PAGE_SET_ERROR);free_async_extent_pages (async_extent);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/776 tracing: branch: Fix inverted check on stat tracer registration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 3b75dd76e64a04771861bb5647951c264919e563 ]
init_annotated_branch_stats() and all_annotated_branch_stats() check the return value of register_stat_tracer() with "if (!ret)", but register_stat_tracer() returns 0 on success and a negative errno on failure. The inverted check causes the warning to be printed on every successful registration, e.g.:
Warning: could not register annotated branches stats
while leaving real failures silent. The initcall also returned a hard-coded 1 instead of the actual error.
Invert the check and propagate ret so that the warning fires on real errors and the initcall reports the correct status.
--- kernel/trace/trace_branch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/trace_branch.c +4 -4
@@ -379,10 +379,10 @@ __init static int init_annotated_branch_stats(void)int ret; ret =register_stat_tracer (&annotated_branch_stats); -if (!ret) { +if (ret) {printk (KERN_WARNING "Warning: could not register " "annotated branches stats\n" ); -return 1 ; +return ret; }return 0 ; }
@@ -444,10 +444,10 @@ __init static int all_annotated_branch_stats(void)int ret; ret =register_stat_tracer (&all_branch_stats); -if (!ret) { +if (ret) {printk (KERN_WARNING "Warning: could not register " "all branches stats\n" ); -return 1 ; +return ret; }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/776 netfilter: arp_tables: fix IEEE1394 ARP payload parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 1e8e3f449b1e73b73a843257635b9c50f0cc0f0a ]
Weiming Shi says:
"arp_packet_match() unconditionally parses the ARP payload assuming two hardware addresses are present (source and target). However, IPv4-over-IEEE1394 ARP (RFC 2734) omits the target hardware address field, and arp_hdr_len() already accounts for this by returning a shorter length for ARPHRD_IEEE1394 devices.
As a result, on IEEE1394 interfaces arp_packet_match() advances past a nonexistent target hardware address and reads the wrong bytes for both the target device address comparison and the target IP address. This causes arptables rules to match against garbage data, leading to incorrect filtering decisions: packets that should be accepted may be dropped and vice versa.
The ARP stack in net/ipv4/arp.c (arp_create and arp_process) already handles this correctly by skipping the target hardware address for ARPHRD_IEEE1394. Apply the same pattern to arp_packet_match()."
Mangle the original patch to always return 0 (no match) in case user matches on the target hardware address which is never present in IEEE1394.
Note that this returns 0 (no match) for either normal and inverse match because matching in the target hardware address in ARPHRD_IEEE1394 has never been supported by arptables. This is intentional, matching on the target hardware address should never evaluate true for ARPHRD_IEEE1394.
Moreover, adjust arpt_mangle to drop the packet too as AI suggests:
In arpt_mangle, the logic assumes a standard ARP layout. Because IEEE1394 (FireWire) omits the target hardware address, the linear pointer arithmetic miscalculates the offset for the target IP address. This causes mangling operations to write to the wrong location, leading to packet corruption. To ensure safety, this patch drops packets (NF_DROP) when mangling is requested for these fields on IEEE1394 devices, as the current implementation cannot correctly map the FireWire ARP payload.
This omits both mangling target hardware and IP address. Even if IP address mangling should be possible in IEEE1394, this would require to adjust arpt_mangle offset calculation, which has never been supported.
Based on patch from Weiming Shi <[email protected]>.
--- net/ipv4/netfilter/arp_tables.c | 18 +++++++++++++++--- net/ipv4/netfilter/arpt_mangle.c | 8 ++++++++ 2 files changed, 23 insertions(+), 3 deletions(-)
net/ipv4/netfilter/arp_tables.c +15 -3
@@ -110,13 +110,25 @@ static inline int arp_packet_match(const struct arphdr *arphdr, arpptr += dev->addr_len;memcpy (&src_ipaddr, arpptr,sizeof (u32)); arpptr +=sizeof (u32); - tgt_devaddr = arpptr; - arpptr += dev->addr_len; + +if (IS_ENABLED (CONFIG_FIREWIRE_NET ) && dev->type ==ARPHRD_IEEE1394 ) { +if (unlikely (memchr_inv (arpinfo->tgt_devaddr.mask,0 , +sizeof (arpinfo->tgt_devaddr.mask)))) +return 0 ; + + tgt_devaddr =NULL ; + }else { + tgt_devaddr = arpptr; + arpptr += dev->addr_len; + }memcpy (&tgt_ipaddr, arpptr,sizeof (u32));if (NF_INVF (arpinfo,ARPT_INV_SRCDEVADDR ,arp_devaddr_compare (&arpinfo->src_devaddr, src_devaddr, - dev->addr_len)) || + dev->addr_len))) +return 0 ; + +if (tgt_devaddr &&NF_INVF (arpinfo,ARPT_INV_TGTDEVADDR ,arp_devaddr_compare (&arpinfo->tgt_devaddr, tgt_devaddr, dev->addr_len)))
net/ipv4/netfilter/arpt_mangle.c +8 -0
@@ -40,6 +40,10 @@ target(struct sk_buff *skb, const struct xt_action_param *par) } arpptr += pln;if (mangle->flags &ARPT_MANGLE_TDEV ) { +if (unlikely (IS_ENABLED (CONFIG_FIREWIRE_NET ) && + skb->dev->type ==ARPHRD_IEEE1394 )) +return NF_DROP ; +if (ARPT_DEV_ADDR_LEN_MAX < hln || (arpptr + hln >skb_tail_pointer (skb)))return NF_DROP ;
@@ -47,6 +51,10 @@ target(struct sk_buff *skb, const struct xt_action_param *par) } arpptr += hln;if (mangle->flags &ARPT_MANGLE_TIP ) { +if (unlikely (IS_ENABLED (CONFIG_FIREWIRE_NET ) && + skb->dev->type ==ARPHRD_IEEE1394 )) +return NF_DROP ; +if (ARPT_MANGLE_ADDR_LEN_MAX < pln || (arpptr + pln >skb_tail_pointer (skb)))return NF_DROP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/776 drm/amdgpu: fix spelling typos
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Demers <[email protected]>
[ Upstream commit ce43abd7ec9464cf954f90e1c69e11768b02fa0a ]
Found some typos while exploring amdgpu code.
Stable-dep-of: 13e4cf116dbf ("drm/amdgpu/uvd3.1: Don't validate the firmware when already validated")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | 3 ++- drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +1 -1
@@ -259,7 +259,7 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc* @adev: amdgpu device structure holding all necessary information * @mc: memory controller structure holding memory information * -* Function will place try to place GART before or after VRAM. +* Function will try to place GART before or after VRAM. * If GART size is bigger than space left then we ajust GART size. * Thus function will never fails. */
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +3 -3
@@ -98,7 +98,7 @@ static void uvd_v3_1_ring_emit_ib(struct amdgpu_ring *ring, }/** -* uvd_v3_1_ring_emit_fence - emit an fence & trap command +* uvd_v3_1_ring_emit_fence - emit a fence & trap command * * @ring: amdgpu_ring pointer * @addr: address
@@ -242,7 +242,7 @@ static void uvd_v3_1_mc_resume(struct amdgpu_device *adev)uint64_t addr;uint32_t size; -/* programm the VCPU memory controller bits 0-27 */ +/* program the VCPU memory controller bits 0-27 */ addr = (adev->uvd.inst->gpu_addr +AMDGPU_UVD_FIRMWARE_OFFSET ) >>3 ; size =AMDGPU_UVD_FIRMWARE_SIZE (adev) >>3 ;WREG32 (mmUVD_VCPU_CACHE_OFFSET0, addr);
@@ -416,7 +416,7 @@ static int uvd_v3_1_start(struct amdgpu_device *adev)/* Set the write pointer delay */ WREG32 (mmUVD_RBC_RB_WPTR_CNTL,0 ); -/* programm the 4GB memory segment for rptr and ring buffer */ +/* Program the 4GB memory segment for rptr and ring buffer */ WREG32 (mmUVD_LMI_EXT40_ADDR,upper_32_bits (ring->gpu_addr) | (0x7 <<16 ) | (0x1 <<31 ));
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +2 -1
@@ -298,7 +298,7 @@ static int uvd_v4_2_start(struct amdgpu_device *adev)/* enable VCPU clock */ WREG32 (mmUVD_VCPU_CNTL,1 <<9 ); -/* disable interupt */ +/* disable interrupt */ WREG32_P (mmUVD_MASTINT_EN,0 , ~(1 <<1 ));#ifdef __BIG_ENDIAN
@@ -308,6 +308,7 @@ static int uvd_v4_2_start(struct amdgpu_device *adev)#endif WREG32 (mmUVD_LMI_SWAP_CNTL, lmi_swap_cntl);WREG32 (mmUVD_MP_SWAP_CNTL, mp_swap_cntl); +/* initialize UVD memory controller */ WREG32 (mmUVD_LMI_CTRL,0x203108 );
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +1 -1
@@ -278,7 +278,7 @@ static int vce_v2_0_stop(struct amdgpu_device *adev)int status;if (vce_v2_0_lmi_clean (adev)) { -DRM_INFO ("vce is not idle \n" ); +DRM_INFO ("VCE is not idle \n" );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/776 drm/amdgpu/uvd3.1: Dont validate the firmware when already validated
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 13e4cf116dbf7a1fb8123a59bea2c098f30d3736 ]
UVD 3.1 firmware validation seems to always fail after attempting it when it had already been validated. (This works similarly with the VCE 1.0 as well.)
Don't attempt repeating the validation when it's already done.
This caused issues in situations when the system isn't able to suspend the GPU properly and so the GPU isn't actually powered down. Then amdgpu would fail when calling the IP block resume function.
--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +10 -0
@@ -242,6 +242,10 @@ static void uvd_v3_1_mc_resume(struct amdgpu_device *adev)uint64_t addr;uint32_t size; +/* When the keyselect is already set, don't perturb it. */ +if (RREG32 (mmUVD_FW_START)) +return ; +/* program the VCPU memory controller bits 0-27 */ addr = (adev->uvd.inst->gpu_addr +AMDGPU_UVD_FIRMWARE_OFFSET ) >>3 ; size =AMDGPU_UVD_FIRMWARE_SIZE (adev) >>3 ;
@@ -284,6 +288,12 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev)int i;uint32_t keysel = adev->uvd.keyselect; +if (RREG32 (mmUVD_FW_START) &UVD_FW_STATUS__PASS_MASK ) { +dev_dbg (adev->dev,"UVD keyselect already set: 0x%x (on CPU: 0x%x)\n" , +RREG32 (mmUVD_FW_START), adev->uvd.keyselect); +return 0 ; + } +WREG32 (mmUVD_FW_START, keysel);for (i =0 ; i <10 ; ++i) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/776 drm/amdgpu/gfx6: Support harvested SI chips with disabled TCCs (v2)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit fe2b84f9228e2a0903221a4d0d8c350b018e9c0c ]
This commit fixes amdgpu to work on the Radeon HD 7870 XT which has never worked with the Linux open source drivers before.
Some boards have "harvested" chips, meaning that some parts of the chip are disabled and fused, and it's sold for cheaper and under a different marketing name.
On a harvested chip, any of the following can be disabled:
- CUs (Compute Units)
- RBs (Render Backend, aka. ROP)
- Memory channels (ie. the chip has a lower bandwidth)
- TCCs (ie. less L2 cache)
Handle chips with harvested TCCs by patching the registers that configure how TCCs are mapped.
If some TCCs are disabled, we need to make sure that the disabled TCCs are not used, and the remaining TCCs are used optimally.
TCP_CHAN_STEER_LO/HI control which TCC is used by TCP channels. TCP_ADDR_CONFIG.NUM_TCC_BANKS controls how many channels are used.
Note that the TCC configuration is highly relevant to performance. Suboptimal configuration (eg. CHAN_STEER=0) can significantly reduce gaming performance.
For optimal performance:
- Rely on the CHAN_STEER from the golden registers table, only skip disabled TCCs but keep the mapping order.
- Limit NUM_TCC_BANKS to number of active TCCs to avoid thrashing, which performs better than using the same TCC twice.
v2:
- Also consider CGTS_USER_TCC_DISABLE for disabled TCCs.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +66 -0
@@ -1568,6 +1568,71 @@ static void gfx_v6_0_setup_spi(struct amdgpu_device *adev)mutex_unlock (&adev->grbm_idx_mutex); } +/** +* gfx_v6_0_setup_tcc() - setup which TCCs are used +* +* @adev: amdgpu_device pointer +* +* Verify whether the current GPU has any TCCs disabled, +* which can happen when the GPU is harvested and some +* memory channels are disabled, reducing the memory bus width. +* For example, on the Radeon HD 7870 XT (Tahiti LE). +* +* If some TCCs are disabled, we need to make sure that +* the disabled TCCs are not used, and the remaining TCCs +* are used optimally. +* +* TCP_CHAN_STEER_LO/HI control which TCC is used by TCP channels. +* TCP_ADDR_CONFIG.NUM_TCC_BANKS controls how many channels are used. +* +* For optimal performance: +* - Rely on the CHAN_STEER from the golden registers table, +* only skip disabled TCCs but keep the mapping order. +* - Limit NUM_TCC_BANKS to number of active TCCs to avoid thrashing, +* which performs better than using the same TCC twice. +*/ +static void gfx_v6_0_setup_tcc (struct amdgpu_device *adev) +{ +u32 i, tcc, tcp_addr_config, num_active_tcc =0 ; +u64 chan_steer, patched_chan_steer =0 ; +const u32 num_max_tcc = adev->gfx.config.max_texture_channel_caches; +const u32 dis_tcc_mask = +amdgpu_gfx_create_bitmask (num_max_tcc) & + (REG_GET_FIELD (RREG32 (mmCGTS_TCC_DISABLE), +CGTS_TCC_DISABLE ,TCC_DISABLE ) | +REG_GET_FIELD (RREG32 (mmCGTS_USER_TCC_DISABLE), +CGTS_USER_TCC_DISABLE ,TCC_DISABLE )); + +/* When no TCC is disabled, the golden registers table already has optimal TCC setup */ +if (!dis_tcc_mask) +return ; + +/* Each 4-bit nibble contains the index of a TCC used by all TCPs */ + chan_steer =RREG32 (mmTCP_CHAN_STEER_LO) | ((u64 )RREG32 (mmTCP_CHAN_STEER_HI) <<32ull ); + +/* Patch the TCP to TCC mapping to skip disabled TCCs */ +for (i =0 ; i < num_max_tcc; ++i) { + tcc = (chan_steer >> (u64)(4 * i)) &0xf ; + +if (!((1 << tcc) & dis_tcc_mask)) { +/* Copy enabled TCC indices to the patched register value. */ + patched_chan_steer |= (u64 )tcc << (u64)(4 * num_active_tcc); + ++num_active_tcc; + } + } + +WARN_ON (num_active_tcc != num_max_tcc -hweight32 (dis_tcc_mask)); + +/* Patch number of TCCs used by TCPs */ + tcp_addr_config =REG_SET_FIELD (RREG32 (mmTCP_ADDR_CONFIG), +TCP_ADDR_CONFIG ,NUM_TCC_BANKS , + num_active_tcc -1 ); + +WREG32 (mmTCP_ADDR_CONFIG, tcp_addr_config); +WREG32 (mmTCP_CHAN_STEER_HI,upper_32_bits (patched_chan_steer)); +WREG32 (mmTCP_CHAN_STEER_LO,lower_32_bits (patched_chan_steer)); +} +static void gfx_v6_0_config_init (struct amdgpu_device *adev) { adev->gfx.config.double_offchip_lds_buf =0 ;
@@ -1726,6 +1791,7 @@ static void gfx_v6_0_constants_init(struct amdgpu_device *adev)gfx_v6_0_tiling_mode_table_init (adev);gfx_v6_0_setup_rb (adev); +gfx_v6_0_setup_tcc (adev);gfx_v6_0_setup_spi (adev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/776 netfilter: xt_policy: fix strict mode inbound policy matching
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiexun Wang <[email protected]>
[ Upstream commit 4b2b4d7d4e203c92db8966b163edfacb1f0e1e29 ]
match_policy_in() walks sec_path entries from the last transform to the first one, but strict policy matching needs to consume info->pol[] in the same forward order as the rule layout.
Derive the strict-match policy position from the number of transforms already consumed so that multi-element inbound rules are matched consistently.
--- net/netfilter/xt_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_policy.c +1 -1
@@ -63,7 +63,7 @@ match_policy_in(const struct sk_buff *skb, const struct xt_policy_info *info,return 0 ;for (i = sp->len -1 ; i >=0 ; i--) { - pos = strict ? i - sp->len +1 :0 ; + pos = strict ? sp->len - i -1 :0 ;if (pos >= info->len)return 0 ; e = &info->pol[pos];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/776 netfilter: nf_conntrack_sip: dont use simple_strtoul
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 8cf6809cddcbe301aedfc6b51bcd4944d45795f6 ]
Replace unsafe port parsing in epaddr_len(), ct_sip_parse_header_uri(), and ct_sip_parse_request() with a new sip_parse_port() helper that validates each digit against the buffer limit, eliminating the use of simple_strtoul() which assumes NUL-terminated strings.
The previous code dereferenced pointers without bounds checks after sip_parse_addr() and relied on simple_strtoul() on non-NUL-terminated skb data. A port that reaches the buffer limit without a trailing character is also rejected as malformed.
Also get rid of all simple_strtoul() usage in conntrack, prefer a stricter version instead. There are intentional changes:
- Bail out if number is > UINT_MAX and indicate a failure, same for too long sequences.
While we do accept 05535 as port 5535, we will not accept e.g. 'sip:10.0.0.1:005060'. While its syntactically valid under RFC 3261, we should restrict this to not waste cycles when presented with malformed packets with 64k '0' characters.
- Force base 10 in ct_sip_parse_numerical_param(). This is used to fetch 'expire=' and 'rports='; both are expected to use base-10.
- In nf_nat_sip.c, only accept the parsed value if its within the 1k-64k range.
- epaddr_len now returns 0 if the port is invalid, as it already does for invalid ip addresses. This is intentional. nf_conntrack_sip performs lots of guesswork to find the right parts of the message to parse. Being stricter could break existing setups. Connection tracking helpers are designed to allow traffic to pass, not to block it.
Based on an earlier patch from Jenny Guanni Qu <[email protected]>.
--- net/netfilter/nf_conntrack_sip.c | 152 ++++++++++++++++++++++++------- net/netfilter/nf_nat_sip.c | 1 + 2 files changed, 119 insertions(+), 34 deletions(-)
net/netfilter/nf_conntrack_sip.c +118 -34
@@ -181,6 +181,57 @@ static int sip_parse_addr(const struct nf_conn *ct, const char *cp,return 1 ; } +/* Parse optional port number after IP address. +* Returns false on malformed input, true otherwise. +* If port is non-NULL, stores parsed port in network byte order. +* If no port is present, sets *port to default SIP port. +*/ +static bool sip_parse_port (const char *dptr,const char **endp, +const char *limit,__be16 *port) +{ +unsigned int p =0 ; +int len =0 ; + +if (dptr >= limit) +return false; + +if (*dptr !=':' ) { +if (port) + *port =htons (SIP_PORT ); +if (endp) + *endp = dptr; +return true; + } + + dptr++;/* skip ':' */ + +while (dptr < limit &&isdigit (*dptr)) { + p = p *10 + (*dptr -'0' ); + dptr++; + len++; +if (len >5 )/* max "65535" */ +return false; + } + +if (len ==0 ) +return false; + +/* reached limit while parsing port */ +if (dptr >= limit) +return false; + +if (p <1024 || p >65535 ) +return false; + +if (port) + *port =htons (p); + +if (endp) + *endp = dptr; + +return true; +} +/* skip ip address. returns its length. */ static int epaddr_len (const struct nf_conn *ct,const char *dptr,const char *limit,int *shift)
@@ -193,11 +244,8 @@ static int epaddr_len(const struct nf_conn *ct, const char *dptr,return 0 ; } -/* Port number */ -if (*dptr ==':' ) { - dptr++; - dptr +=digits_len (ct, dptr, limit, shift); - } +if (!sip_parse_port (dptr, &dptr, limit,NULL )) +return 0 ;return dptr - aux; }
@@ -228,6 +276,51 @@ static int skp_epaddr_len(const struct nf_conn *ct, const char *dptr,return epaddr_len (ct, dptr, limit, shift); } +/* simple_strtoul stops after first non-number character. +* But as we're not dealing with c-strings, we can't rely on +* hitting \r,\n,\0 etc. before moving past end of buffer. +* +* This is a variant of simple_strtoul, but doesn't require +* a c-string. +* +* If value exceeds UINT_MAX, 0 is returned. +*/ +static unsigned int sip_strtouint (const char *cp,unsigned int len,char **endp) +{ +const unsigned int max =sizeof ("4294967295" ); +unsigned int olen = len; +const char *s = cp; +u64 result =0 ; + +if (len > max) + len = max; + +while (olen >0 &&isdigit (*s)) { +unsigned int value; + +if (len ==0 ) + goto err; + + value = *s -'0' ; + result = result *10 + value; + +if (result >UINT_MAX ) + goto err; + s++; + len--; + olen--; + } + +if (endp) + *endp = (char *)s; + +return result; +err: +if (endp) + *endp = (char *)cp; +return 0 ; +} +/* Parse a SIP request line of the form: * * Request-Line = Method SP Request-URI SP SIP-Version CRLF
@@ -241,7 +334,6 @@ int ct_sip_parse_request(const struct nf_conn *ct, {const char *start = dptr, *limit = dptr + datalen, *end;unsigned int mlen; -unsigned int p;int shift =0 ;/* Skip method and following whitespace */
@@ -267,14 +359,8 @@ int ct_sip_parse_request(const struct nf_conn *ct,if (!sip_parse_addr (ct, dptr, &end, addr, limit, true))return -1 ; -if (end < limit && *end ==':' ) { - end++; - p =simple_strtoul (end, (char **)&end,10 ); -if (p <1024 || p >65535 ) -return -1 ; - *port =htons (p); - }else - *port =htons (SIP_PORT ); +if (!sip_parse_port (end, &end, limit, port)) +return -1 ;if (end == dptr)return 0 ;
@@ -509,7 +595,6 @@ int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr, union nf_inet_addr *addr, __be16 *port) { const char *c, *limit = dptr + datalen; -unsigned int p;int ret; ret = ct_sip_walk_headers(ct, dptr, dataoff ? *dataoff : 0, datalen,
@@ -520,14 +605,8 @@ int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr,if (!sip_parse_addr (ct, dptr + *matchoff, &c, addr, limit, true))return -1 ; -if (*c ==':' ) { - c++; - p =simple_strtoul (c, (char **)&c,10 ); -if (p <1024 || p >65535 ) -return -1 ; - *port =htons (p); - }else - *port =htons (SIP_PORT ); +if (!sip_parse_port (c, &c, limit, port)) +return -1 ;if (dataoff) *dataoff = c - dptr;
@@ -609,7 +688,7 @@ int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr,return 0 ; start +=strlen (name); - *val =simple_strtoul (start, &end,0 ); + *val =sip_strtouint (start, limit - start, (char **)&end);if (start == end)return -1 ;if (matchoff && matchlen) {
@@ -1065,6 +1144,8 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, mediaoff = sdpoff;for (i =0 ; i <ARRAY_SIZE (sdp_media_types); ) { +char *end; +if (ct_sip_get_sdp_header (ct, *dptr, mediaoff, *datalen,SDP_HDR_MEDIA ,SDP_HDR_UNSPEC , &mediaoff, &medialen) <=0 )
@@ -1080,8 +1161,8 @@ static int process_sdp(struct sk_buff *skb, unsigned int protoff, mediaoff += t->len; medialen -= t->len; - port =simple_strtoul (*dptr + mediaoff,NULL ,10 ); -if (port ==0 ) + port =sip_strtouint (*dptr + mediaoff, *datalen - mediaoff, (char **)&end); +if (port ==0 || *dptr + mediaoff == end)continue ;if (port <1024 || port >65535 ) {nf_ct_helper_log (skb, ct,"wrong port %u" , port);
@@ -1254,7 +1335,7 @@ static int process_register_request(struct sk_buff *skb, unsigned int protoff,*/ if (ct_sip_get_header (ct, *dptr,0 , *datalen,SIP_HDR_EXPIRES , &matchoff, &matchlen) >0 ) - expires =simple_strtoul (*dptr + matchoff,NULL ,10 ); + expires =sip_strtouint (*dptr + matchoff, *datalen - matchoff,NULL ); ret = ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen, SIP_HDR_CONTACT, NULL,
@@ -1354,7 +1435,7 @@ static int process_register_response(struct sk_buff *skb, unsigned int protoff,if (ct_sip_get_header (ct, *dptr,0 , *datalen,SIP_HDR_EXPIRES , &matchoff, &matchlen) >0 ) - expires =simple_strtoul (*dptr + matchoff,NULL ,10 ); + expires =sip_strtouint (*dptr + matchoff, *datalen - matchoff,NULL );while (1 ) {unsigned int c_expires = expires;
@@ -1414,10 +1495,12 @@ static int process_sip_response(struct sk_buff *skb, unsigned int protoff,struct nf_conn *ct =nf_ct_get (skb, &ctinfo);unsigned int matchoff, matchlen, matchend;unsigned int code, cseq, i; +char *end;if (*datalen <strlen ("SIP/2.0 200" ))return NF_ACCEPT ; - code =simple_strtoul (*dptr +strlen ("SIP/2.0 " ),NULL ,10 ); + code =sip_strtouint (*dptr +strlen ("SIP/2.0 " ), + *datalen -strlen ("SIP/2.0 " ),NULL );if (!code) {nf_ct_helper_log (skb, ct,"cannot get code" );return NF_DROP ;
@@ -1428,8 +1511,8 @@ static int process_sip_response(struct sk_buff *skb, unsigned int protoff,nf_ct_helper_log (skb, ct,"cannot parse cseq" );return NF_DROP ; } - cseq =simple_strtoul (*dptr + matchoff,NULL ,10 ); -if (!cseq && *(*dptr + matchoff) !='0' ) { + cseq =sip_strtouint (*dptr + matchoff, *datalen - matchoff, (char **)&end); +if (*dptr + matchoff == end) {nf_ct_helper_log (skb, ct,"cannot get cseq" );return NF_DROP ; }
@@ -1478,6 +1561,7 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff,for (i =0 ; i <ARRAY_SIZE (sip_handlers); i++) {const struct sip_handler *handler; +char *end; handler = &sip_handlers[i];if (handler->request ==NULL )
@@ -1494,8 +1578,8 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff,nf_ct_helper_log (skb, ct,"cannot parse cseq" );return NF_DROP ; } - cseq =simple_strtoul (*dptr + matchoff,NULL ,10 ); -if (!cseq && *(*dptr + matchoff) !='0' ) { + cseq =sip_strtouint (*dptr + matchoff, *datalen - matchoff, (char **)&end); +if (*dptr + matchoff == end) {nf_ct_helper_log (skb, ct,"cannot get cseq" );return NF_DROP ; }
@@ -1571,7 +1655,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff, &matchoff, &matchlen) <= 0)break ; - clen =simple_strtoul (dptr + matchoff, (char **)&end,10 ); + clen =sip_strtouint (dptr + matchoff, datalen - matchoff, (char **)&end);if (dptr + matchoff == end)break ;
net/netfilter/nf_nat_sip.c +1 -0
@@ -246,6 +246,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff,if (ct_sip_parse_numerical_param (ct, *dptr, matchend, *datalen,"rport=" , &poff, &plen, &n) >0 && + n >=1024 && n <=65535 &&htons (n) == ct->tuplehash[dir].tuple.dst.u.udp.port &&htons (n) != ct->tuplehash[!dir].tuple.src.u.udp.port) {__be16 p = ct->tuplehash[!dir].tuple.src.u.udp.port;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/776 scsi: sr: Add memory allocation failure handling for get_capabilities()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enze Li <[email protected]>
[ Upstream commit ebc95c790653508ad7e031cfb9de5d0fa39135e2 ]
The function get_capabilities() has the possibility of failing to allocate the transfer buffer but it does not currently handle this. This may lead to exceptions when accessing the buffer.
Add error handling when memory allocation fails.
Stable-dep-of: 0898a817621a ("cdrom, scsi: sr: propagate read-only status to block layer via set_disk_ro()")
--- drivers/scsi/sr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/scsi/sr.c +8 -6
@@ -118,7 +118,7 @@ static int sr_open(struct cdrom_device_info *, int);static void sr_release (struct cdrom_device_info *);static void get_sectorsize (struct scsi_cd *); -static void get_capabilities (struct scsi_cd *); +static int get_capabilities (struct scsi_cd *);static unsigned int sr_check_events (struct cdrom_device_info *cdi,unsigned int clearing,int slot);
@@ -710,8 +710,9 @@ static int sr_probe(struct device *dev) sdev->sector_size =2048 ;/* A guess, just in case */ -/* FIXME: need to handle a get_capabilities failure properly ?? */ -get_capabilities (cd); + error = -ENOMEM ; +if (get_capabilities (cd)) + goto fail_minor;sr_vendor_init (cd);set_capacity (disk, cd->capacity);
@@ -831,7 +832,7 @@ static void get_sectorsize(struct scsi_cd *cd)return ; } -static void get_capabilities (struct scsi_cd *cd) +static int get_capabilities (struct scsi_cd *cd) {unsigned char *buffer;struct scsi_mode_data data;
@@ -856,7 +857,7 @@ static void get_capabilities(struct scsi_cd *cd) buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer) {sr_printk (KERN_ERR , cd,"out of memory.\n" ); -return ; +return -ENOMEM ; }/* eat unit attentions */
@@ -876,7 +877,7 @@ static void get_capabilities(struct scsi_cd *cd) CDC_MRW | CDC_MRW_W | CDC_RAM);kfree (buffer);sr_printk (KERN_INFO , cd,"scsi-1 drive" ); -return ; +return 0 ; } n = data.header_length + data.block_descriptor_length;
@@ -935,6 +936,7 @@ static void get_capabilities(struct scsi_cd *cd) }kfree (buffer); +return 0 ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/776 cdrom, scsi: sr: propagate read-only status to block layer via set_disk_ro()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daan De Meyer <[email protected]>
[ Upstream commit 0898a817621a2f0cddca8122d9b974003fe5036d ]
The cdrom core never calls set_disk_ro() for a registered device, so BLKROGET on a CD-ROM device always returns 0 (writable), even when the drive has no write capabilities and writes will inevitably fail. This causes problems for userspace that relies on BLKROGET to determine whether a block device is read-only. For example, systemd's loop device setup uses BLKROGET to decide whether to create a loop device with LO_FLAGS_READ_ONLY. Without the read-only flag, writes pass through the loop device to the CD-ROM and fail with I/O errors. systemd-fsck similarly checks BLKROGET to decide whether to run fsck in no-repair mode (-n).
The write-capability bits in cdi->mask come from two different sources:CDC_DVD_RAM and CDC_CD_RW are populated by the driver from the MODE SENSE capabilities page (page 0x2A) before register_cdrom() is called, while CDC_MRW_W and CDC_RAM require the MMC GET CONFIGURATION command and were only probed by cdrom_open_write() at device open time. This meant that any attempt to compute the writable state from the full mask at probe time was incorrect, because the GET CONFIGURATION bits were still unset (and cdi->mask is initialized such that capabilities are assumed present).
Fix this by factoring the GET CONFIGURATION probing out of cdrom_open_write() into a new exported helper, cdrom_probe_write_features(), and having sr call it from sr_probe() right after get_capabilities() has populated the MODE SENSE bits. register_cdrom() then calls set_disk_ro() based on the full write-capability mask (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW) so the block layer reflects the drive's actual write support. The feature queries used (CDF_MRW and CDF_RWRT via GET CONFIGURATION with RT=00) report drive-level capabilities that are persistent across media, so a single probe before register_cdrom() is sufficient and the redundant probe at open time is dropped.
With set_disk_ro() now accurate, the long-vestigial cd->writeable flag in sr can go: get_capabilities() used to set cd->writeable based on the same four mask bits, but because CDC_MRW_W and CDC_RAM default to "capability present" in cdi->mask and aren't touched by MODE SENSE, the condition that gated cd->writeable was always true, making it unconditionally 1. Replace the corresponding gate in sr_init_command() with get_disk_ro(cd->disk), which turns a previously no-op check into a real one and also catches kernel-internal bio writers that bypass blkdev_write_iter()'s bdev_read_only() check.
The sd driver (SCSI disks) does not have this problem because it checks the MODE SENSE Write Protect bit and calls set_disk_ro() accordingly. The sr driver cannot use the same approach because the MMC specification does not define the WP bit in the MODE SENSE device-specific parameter byte for CD-ROM devices.
--- drivers/cdrom/cdrom.c | 73 ++++++++++++++++++++++++++++--------------- drivers/scsi/sr.c | 11 ++----- drivers/scsi/sr.h | 1 - include/linux/cdrom.h | 1 + 4 files changed, 51 insertions(+), 35 deletions(-)
drivers/cdrom/cdrom.c +48 -25
@@ -636,6 +636,16 @@ int register_cdrom(struct gendisk *disk, struct cdrom_device_info *cdi)WARN_ON (!cdo->generic_packet); +/* +* Propagate the drive's write support to the block layer so BLKROGET +* reflects actual write capability. Drivers that use GET CONFIGURATION +* features (CDC_MRW_W, CDC_RAM) must have called +* cdrom_probe_write_features() before register_cdrom() so the mask is +* complete here. +*/ +set_disk_ro (disk, !CDROM_CAN (CDC_DVD_RAM |CDC_MRW_W |CDC_RAM | +CDC_CD_RW )); +cd_dbg (CD_REG_UNREG ,"drive \"/dev/%s\" registered\n" , cdi->name);mutex_lock (&cdrom_mutex);list_add (&cdi->list, &cdrom_list);
@@ -747,6 +757,44 @@ static int cdrom_is_random_writable(struct cdrom_device_info *cdi, int *write)return 0 ; } +/* +* Probe write-related MMC features via GET CONFIGURATION and update +* cdi->mask accordingly. Drivers that populate cdi->mask from the MODE SENSE +* capabilities page (e.g. sr) should call this after those MODE SENSE bits +* have been set but before register_cdrom(), so that the full set of +* write-capability bits is known by the time register_cdrom() decides on the +* initial read-only state of the disk. +*/ +void cdrom_probe_write_features (struct cdrom_device_info *cdi) +{ +int mrw, mrw_write, ram_write; + + mrw =0 ; +if (!cdrom_is_mrw (cdi, &mrw_write)) + mrw =1 ; + +if (CDROM_CAN (CDC_MO_DRIVE )) + ram_write =1 ; +else + (void )cdrom_is_random_writable (cdi, &ram_write); + +if (mrw) + cdi->mask &= ~CDC_MRW ; +else + cdi->mask |=CDC_MRW ; + +if (mrw_write) + cdi->mask &= ~CDC_MRW_W ; +else + cdi->mask |=CDC_MRW_W ; + +if (ram_write) + cdi->mask &= ~CDC_RAM ; +else + cdi->mask |=CDC_RAM ; +} +EXPORT_SYMBOL (cdrom_probe_write_features); +static int cdrom_media_erasable (struct cdrom_device_info *cdi) {disc_information di;
@@ -899,33 +947,8 @@ static int cdrom_is_dvd_rw(struct cdrom_device_info *cdi)*/ static int cdrom_open_write (struct cdrom_device_info *cdi) { -int mrw, mrw_write, ram_write;int ret =1 ; - mrw =0 ; -if (!cdrom_is_mrw (cdi, &mrw_write)) - mrw =1 ; - -if (CDROM_CAN (CDC_MO_DRIVE )) - ram_write =1 ; -else - (void )cdrom_is_random_writable (cdi, &ram_write); - -if (mrw) - cdi->mask &= ~CDC_MRW ; -else - cdi->mask |=CDC_MRW ; - -if (mrw_write) - cdi->mask &= ~CDC_MRW_W ; -else - cdi->mask |=CDC_MRW_W ; - -if (ram_write) - cdi->mask &= ~CDC_RAM ; -else - cdi->mask |=CDC_RAM ; -if (CDROM_CAN (CDC_MRW_W )) ret =cdrom_mrw_open_write (cdi);else if (CDROM_CAN (CDC_DVD_RAM ))
drivers/scsi/sr.c +2 -9
@@ -431,7 +431,7 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)switch (req_op (rq)) {case REQ_OP_WRITE : -if (!cd->writeable) +if (get_disk_ro (cd->disk)) goto out; SCpnt->cmnd[0 ] =WRITE_10 ; cd->cdi.media_written =1 ;
@@ -713,6 +713,7 @@ static int sr_probe(struct device *dev) error = -ENOMEM ;if (get_capabilities (cd)) goto fail_minor; +cdrom_probe_write_features (&cd->cdi);sr_vendor_init (cd);set_capacity (disk, cd->capacity);
@@ -927,14 +928,6 @@ static int get_capabilities(struct scsi_cd *cd)/*else I don't think it can close its tray cd->cdi.mask |= CDC_CLOSE_TRAY; */ -/* -* if DVD-RAM, MRW-W or CD-RW, we are randomly writable -*/ -if ((cd->cdi.mask & (CDC_DVD_RAM |CDC_MRW_W |CDC_RAM |CDC_CD_RW )) != - (CDC_DVD_RAM |CDC_MRW_W |CDC_RAM |CDC_CD_RW )) { - cd->writeable =1 ; - } -kfree (buffer);return 0 ; }
drivers/scsi/sr.h +0 -1
@@ -38,7 +38,6 @@ typedef struct scsi_cd {struct scsi_device *device;unsigned int vendor;/* vendor code, see sr_vendor.c */ unsigned long ms_offset;/* for reading multisession-CD's */ - unsigned writeable : 1; unsigned use:1; /* is this device still supportable */ unsigned xa_flag:1; /* CD has XA sectors ? */ unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
include/linux/cdrom.h +1 -0
@@ -109,6 +109,7 @@ extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,extern unsigned int cdrom_check_events (struct cdrom_device_info *cdi,unsigned int clearing); +extern void cdrom_probe_write_features (struct cdrom_device_info *cdi);extern int register_cdrom (struct gendisk *disk,struct cdrom_device_info *cdi);extern void unregister_cdrom (struct cdrom_device_info *cdi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/776 netdevsim: zero initialize struct iphdr in dummy sk_buff
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Z. Ivanov <[email protected]>
[ Upstream commit 35eaa6d8d6c2ee65e96f507add856e0eacf24591 ]
Syzbot reports a KMSAN uninit-value originating from nsim_dev_trap_skb_build, with the allocation also being performed in the same function.
Fix this by calling skb_put_zero instead of skb_put to guarantee zero initialization of the whole IP header.
--- drivers/net/netdevsim/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netdevsim/dev.c +1 -1
@@ -674,7 +674,7 @@ static struct sk_buff *nsim_dev_trap_skb_build(void) skb->protocol =htons (ETH_P_IP );skb_set_network_header (skb, skb->len); - iph =skb_put (skb,sizeof (struct iphdr )); + iph =skb_put_zero (skb,sizeof (struct iphdr )); iph->protocol =IPPROTO_UDP ; iph->saddr =in_aton ("192.0.2.1" ); iph->daddr =in_aton ("198.51.100.1" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/776 net: sched: sch_netem: Refactor code in 4-state loss generator
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshit Mogalapalli <[email protected]>
[ Upstream commit cb3ef7b00042479277cda7871d899378ad91f081 ]
Fixed comments to match description with variable names and refactored code to match the convention as per [1].
To match the convention mapping is done as follows:
State 3 - LOST_IN_BURST_PERIOD
State 4 - LOST_IN_GAP_PERIOD
[1] S. Salsano, F. Ludovici, A. Ordine, "Definition of a general and intuitive loss model for packet networks and its implementation in the Netem module in the Linux kernel"
Stable-dep-of: 732b463449fd ("net/sched: netem: fix probability gaps in 4-state loss model")
--- net/sched/sch_netem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
net/sched/sch_netem.c +9 -9
@@ -210,17 +210,17 @@ static bool loss_4state(struct netem_sched_data *q)* next state and if the next packet has to be transmitted or lost. * The four states correspond to: * TX_IN_GAP_PERIOD => successfully transmitted packets within a gap period -* LOST_IN_BURST_PERIOD => isolated losses within a gap period -* LOST_IN_GAP_PERIOD => lost packets within a burst period -* TX_IN_GAP_PERIOD => successfully transmitted packets within a burst period +* LOST_IN_GAP_PERIOD => isolated losses within a gap period +* LOST_IN_BURST_PERIOD => lost packets within a burst period +* TX_IN_BURST_PERIOD => successfully transmitted packets within a burst period */ switch (clg->state) {case TX_IN_GAP_PERIOD :if (rnd < clg->a4) { - clg->state =LOST_IN_BURST_PERIOD ; + clg->state =LOST_IN_GAP_PERIOD ;return true; }else if (clg->a4 < rnd && rnd < clg->a1 + clg->a4) { - clg->state =LOST_IN_GAP_PERIOD ; + clg->state =LOST_IN_BURST_PERIOD ;return true; }else if (clg->a1 + clg->a4 < rnd) { clg->state =TX_IN_GAP_PERIOD ;
@@ -229,24 +229,24 @@ static bool loss_4state(struct netem_sched_data *q)break ;case TX_IN_BURST_PERIOD :if (rnd < clg->a5) { - clg->state =LOST_IN_GAP_PERIOD ; + clg->state =LOST_IN_BURST_PERIOD ;return true; }else { clg->state =TX_IN_BURST_PERIOD ; }break ; -case LOST_IN_GAP_PERIOD : +case LOST_IN_BURST_PERIOD :if (rnd < clg->a3) clg->state =TX_IN_BURST_PERIOD ;else if (clg->a3 < rnd && rnd < clg->a2 + clg->a3) { clg->state =TX_IN_GAP_PERIOD ; }else if (clg->a2 + clg->a3 < rnd) { - clg->state =LOST_IN_GAP_PERIOD ; + clg->state =LOST_IN_BURST_PERIOD ;return true; }break ; -case LOST_IN_BURST_PERIOD : +case LOST_IN_GAP_PERIOD : clg->state =TX_IN_GAP_PERIOD ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/776 net/sched: netem: fix probability gaps in 4-state loss model
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit 732b463449fd0ef90acd13cda68eab1c91adb00c ]
The 4-state Markov chain in loss_4state() has gaps at the boundaries between transition probability ranges. The comparisons use:
if (rnd < a4) else if (a4 < rnd && rnd < a1 + a4)
When rnd equals a boundary value exactly, neither branch matches and no state transition occurs. The redundant lower-bound check (a4 < rnd) is already implied by being in the else branch.
Remove the unnecessary lower-bound comparisons so the ranges are contiguous and every random value produces a transition, matching the GI (General and Intuitive) loss model specification.
This bug goes back to original implementation of this model.
--- net/sched/sch_netem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/sched/sch_netem.c +4 -4
@@ -219,10 +219,10 @@ static bool loss_4state(struct netem_sched_data *q)if (rnd < clg->a4) { clg->state =LOST_IN_GAP_PERIOD ;return true; - }else if (clg->a4 < rnd && rnd < clg->a1 + clg->a4) { + }else if (rnd < clg->a1 + clg->a4) { clg->state =LOST_IN_BURST_PERIOD ;return true; - }else if (clg->a1 + clg->a4 < rnd) { + }else { clg->state =TX_IN_GAP_PERIOD ; }
@@ -239,9 +239,9 @@ static bool loss_4state(struct netem_sched_data *q)case LOST_IN_BURST_PERIOD :if (rnd < clg->a3) clg->state =TX_IN_BURST_PERIOD ; -else if (clg->a3 < rnd && rnd < clg->a2 + clg->a3) { +else if (rnd < clg->a2 + clg->a3) { clg->state =TX_IN_GAP_PERIOD ; - }else if (clg->a2 + clg->a3 < rnd) { + }else { clg->state =LOST_IN_BURST_PERIOD ;return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/776 net/sched: netem: fix queue limit check to include reordered packets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit 4185701fcce6b426b6c3630b25330dddd9c47b0d ]
The queue limit check in netem_enqueue() uses q->t_len which only counts packets in the internal tfifo. Packets placed in sch->q by the reorder path (__qdisc_enqueue_head) are not counted, allowing the total queue occupancy to exceed sch->limit under reordering.
Include sch->q.qlen in the limit check.
--- net/sched/sch_netem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_netem.c +1 -1
@@ -512,7 +512,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,1 <<(prandom_u32 () %8 ); } -if (unlikely (q->t_len >= sch->limit)) { +if (unlikely (sch->q.qlen >= sch->limit)) {/* re-link segs, so that qdisc_drop_all() frees them all */ skb->next = segs;qdisc_drop_all (skb, sch, to_free);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/776 net/sched: netem: validate slot configuration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <[email protected]>
[ Upstream commit 01801c359a74737b9b1aa28568b60374d857241a ]
Reject slot configurations that have no defensible meaning:
- negative min_delay or max_delay
- min_delay greater than max_delay
- negative dist_delay or dist_jitter
- negative max_packets or max_bytes
Negative or out-of-order delays underflow in get_slot_next(), producing garbage intervals. Negative limits trip the per-slot accounting (packets_left/bytes_left <= 0) on the first packet of every slot, defeating the rate-limiting half of the slot feature.
Note that dist_jitter has been silently coerced to its absolute value by get_slot() since the feature was introduced; rejecting negatives here converts that silent coercion into -EINVAL. The abs() can be removed in a follow-up.
--- net/sched/sch_netem.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
net/sched/sch_netem.c +29 -0
@@ -815,6 +815,29 @@ static int get_dist_table(struct disttable **tbl, const struct nlattr *attr)return 0 ; } +static int validate_slot (const struct nlattr *attr,struct netlink_ext_ack *extack) +{ +const struct tc_netem_slot *c =nla_data (attr); + +if (c->min_delay <0 || c->max_delay <0 ) { +NL_SET_ERR_MSG_ATTR (extack, attr,"negative slot delay" ); +return -EINVAL ; + } +if (c->min_delay > c->max_delay) { +NL_SET_ERR_MSG_ATTR (extack, attr,"slot min delay greater than max delay" ); +return -EINVAL ; + } +if (c->dist_delay <0 || c->dist_jitter <0 ) { +NL_SET_ERR_MSG_ATTR (extack, attr,"negative dist delay" ); +return -EINVAL ; + } +if (c->max_packets <0 || c->max_bytes <0 ) { +NL_SET_ERR_MSG_ATTR (extack, attr,"negative slot limit" ); +return -EINVAL ; + } +return 0 ; +} +static void get_slot (struct netem_sched_data *q,const struct nlattr *attr) {const struct tc_netem_slot *c =nla_data (attr);
@@ -1030,6 +1053,12 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, goto table_free; } +if (tb[TCA_NETEM_SLOT ]) { + ret =validate_slot (tb[TCA_NETEM_SLOT ], extack); +if (ret) + goto table_free; + } +sch_tree_lock (sch);/* backup q->clg and q->loss_model */ old_clg = q->clg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/776 net: sched: choke: remove unused variables in struct choke_sched_data
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchao Shao <[email protected]>
[ Upstream commit 38af11717b386560f10f2891350933fc5200aeea ]
The variable "other" in the struct choke_sched_data is not used. Remove it.
Stable-dep-of: d3aeb889dcbd ("net/sched: sch_choke: annotate data-races in choke_dump_stats()")
--- net/sched/sch_choke.c | 2 -- 1 file changed, 2 deletions(-)
net/sched/sch_choke.c +0 -2
@@ -60,7 +60,6 @@ struct choke_sched_data {u32 forced_drop;/* Forced drops, qavg > max_thresh */ u32 forced_mark;/* Forced marks, qavg > max_thresh */ u32 pdrop;/* Drops due to queue limits */ -u32 other;/* Drops due to drop() calls */ u32 matched;/* Drops to flow match */ } stats;
@@ -464,7 +463,6 @@ static int choke_dump_stats(struct Qdisc *sch, struct gnet_dump *d) .early = q->stats.prob_drop + q->stats.forced_drop, .marked = q->stats.prob_mark + q->stats.forced_mark, .pdrop = q->stats.pdrop, - .other = q->stats.other, .matched = q->stats.matched, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/776 net/sched: sch_choke: annotate data-races in choke_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d3aeb889dcbd78e95f500d383799a23d949796e0 ]
choke_dump_stats() only runs with RTNL held. It reads fields that can be changed in qdisc fast path. Add READ_ONCE()/WRITE_ONCE() annotations.
--- net/sched/sch_choke.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
net/sched/sch_choke.c +16 -10
@@ -229,7 +229,7 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch,/* Draw a packet at random from queue and compare flow */ if (choke_match_random (q, skb, &idx)) { - q->stats.matched++; +WRITE_ONCE (q->stats.matched, q->stats.matched +1 );choke_drop_by_idx (sch, idx, to_free); goto congestion_drop; }
@@ -241,11 +241,13 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch,qdisc_qstats_overlimit (sch);if (use_harddrop (q) || !use_ecn (q) || !INET_ECN_set_ce (skb)) { - q->stats.forced_drop++; +WRITE_ONCE (q->stats.forced_drop, + q->stats.forced_drop +1 ); goto congestion_drop; } - q->stats.forced_mark++; +WRITE_ONCE (q->stats.forced_mark, + q->stats.forced_mark +1 ); }else if (++q->vars.qcount) {if (red_mark_probability (p, &q->vars, q->vars.qavg)) { q->vars.qcount =0 ;
@@ -253,11 +255,13 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch,qdisc_qstats_overlimit (sch);if (!use_ecn (q) || !INET_ECN_set_ce (skb)) { - q->stats.prob_drop++; +WRITE_ONCE (q->stats.prob_drop, + q->stats.prob_drop +1 ); goto congestion_drop; } - q->stats.prob_mark++; +WRITE_ONCE (q->stats.prob_mark, + q->stats.prob_mark +1 ); } }else q->vars.qR =red_random (p);
@@ -272,7 +276,7 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch,return NET_XMIT_SUCCESS ; } - q->stats.pdrop++; +WRITE_ONCE (q->stats.pdrop, q->stats.pdrop +1 );return qdisc_drop (skb, sch, to_free); congestion_drop:
@@ -460,10 +464,12 @@ static int choke_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct choke_sched_data *q =qdisc_priv (sch);struct tc_choke_xstats st = { - .early = q->stats.prob_drop + q->stats.forced_drop, - .marked = q->stats.prob_mark + q->stats.forced_mark, - .pdrop = q->stats.pdrop, - .matched = q->stats.matched, + .early =READ_ONCE (q->stats.prob_drop) + +READ_ONCE (q->stats.forced_drop), + .marked =READ_ONCE (q->stats.prob_mark) + +READ_ONCE (q->stats.forced_mark), + .pdrop =READ_ONCE (q->stats.pdrop), + .matched =READ_ONCE (q->stats.matched), };return gnet_stats_copy_app (d, &st,sizeof (st));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/776 net/sched: sch_fq_pie: annotate data-races in fq_pie_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 59b145771c7982cfe9020d4e9e22da92d6b5ae31 ]
fq_codel_dump_stats() acquires the qdisc spinlock a bit too late.
Move this acquisition before we fill tc_fq_pie_xstats with live data.
Alternative would be to add READ_ONCE() and WRITE_ONCE() annotations, but the spinlock is needed anyway to scan q->new_flows and q->old_flows.
--- net/sched/sch_fq_pie.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
net/sched/sch_fq_pie.c +10 -9
@@ -499,18 +499,19 @@ static int fq_pie_dump(struct Qdisc *sch, struct sk_buff *skb)static int fq_pie_dump_stats (struct Qdisc *sch,struct gnet_dump *d) {struct fq_pie_sched_data *q =qdisc_priv (sch); -struct tc_fq_pie_xstats st = { - .packets_in = q->stats.packets_in, - .overlimit = q->stats.overlimit, - .overmemory = q->overmemory, - .dropped = q->stats.dropped, - .ecn_mark = q->stats.ecn_mark, - .new_flow_count = q->new_flow_count, - .memory_usage = q->memory_usage, - }; +struct tc_fq_pie_xstats st = {0 };struct list_head *pos;sch_tree_lock (sch); + + st.packets_in = q->stats.packets_in; + st.overlimit = q->stats.overlimit; + st.overmemory = q->overmemory; + st.dropped = q->stats.dropped; + st.ecn_mark = q->stats.ecn_mark; + st.new_flow_count = q->new_flow_count; + st.memory_usage = q->memory_usage; +list_for_each (pos, &q->new_flows) st.new_flows_len++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/776 vrf: Fix a potential NPD when removing a port from a VRF
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 2674d603a9e6970463b2b9ebcf8e31e90beae169 ]
RCU readers that identified a net device as a VRF port using netif_is_l3_slave() assume that a subsequent call to netdev_master_upper_dev_get_rcu() will return a VRF device. They then continue to dereference its l3mdev operations.
This assumption is not always correct and can result in a NPD [1]. There is no RCU synchronization when removing a port from a VRF, so it is possible for an RCU reader to see a new master device (e.g., a bridge) that does not have l3mdev operations.
Fix by adding RCU synchronization after clearing the IFF_L3MDEV_SLAVE flag. Skip this synchronization when a net device is removed from a VRF as part of its deletion and when the VRF device itself is deleted. In the latter case an RCU grace period will pass by the time RTNL is released.
[1]
BUG: kernel NULL pointer dereference, address: 0000000000000000 [...] RIP: 0010:l3mdev_fib_table_rcu (net/l3mdev/l3mdev.c:181) [...] Call Trace: <TASK> l3mdev_fib_table_by_index (net/l3mdev/l3mdev.c:201 net/l3mdev/l3mdev.c:189) __inet_bind (net/ipv4/af_inet.c:499 (discriminator 3)) inet_bind_sk (net/ipv4/af_inet.c:469) __sys_bind (./include/linux/file.h:62 (discriminator 1) ./include/linux/file.h:83 (discriminator 1) net/socket.c:1951 (discriminator 1)) __x64_sys_bind (net/socket.c:1969 (discriminator 1) net/socket.c:1967 (discriminator 1) net/socket.c:1967 (discriminator 1)) do_syscall_64 (arch/x86/entry/syscall_64.c:63 (discriminator 1) arch/x86/entry/syscall_64.c:94 (discriminator 1))
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
--- drivers/net/vrf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/vrf.c +11 -4
@@ -1135,6 +1135,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev, err: port_dev->priv_flags &= ~IFF_L3MDEV_SLAVE ; +synchronize_net ();return ret; }
@@ -1154,10 +1155,16 @@ static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev, }/* inverse of do_vrf_add_slave */ -static int do_vrf_del_slave (struct net_device *dev,struct net_device *port_dev) +static int do_vrf_del_slave (struct net_device *dev,struct net_device *port_dev, +bool needs_sync) {netdev_upper_dev_unlink (port_dev, dev); port_dev->priv_flags &= ~IFF_L3MDEV_SLAVE ; +/* Make sure that concurrent RCU readers that identified the device +* as a VRF port see a VRF master or no master at all. +*/ +if (needs_sync) +synchronize_net ();cycle_netdev (port_dev,NULL );
@@ -1166,7 +1173,7 @@ static int do_vrf_del_slave(struct net_device *dev, struct net_device *port_dev)static int vrf_del_slave (struct net_device *dev,struct net_device *port_dev) { -return do_vrf_del_slave (dev, port_dev); +return do_vrf_del_slave (dev, port_dev, true); }static void vrf_dev_uninit (struct net_device *dev)
@@ -1731,7 +1738,7 @@ static void vrf_dellink(struct net_device *dev, struct list_head *head)struct list_head *iter;netdev_for_each_lower_dev (dev, port_dev, iter) -vrf_del_slave (dev, port_dev); +do_vrf_del_slave (dev, port_dev, false);vrf_map_unregister_dev (dev);
@@ -1862,7 +1869,7 @@ static int vrf_device_event(struct notifier_block *unused, goto out; vrf_dev =netdev_master_upper_dev_get (dev); -vrf_del_slave (vrf_dev, dev); +do_vrf_del_slave (vrf_dev, dev, false); } out:return NOTIFY_DONE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/776 net: usb: rtl8150: fix use-after-free in rtl8150_start_xmit()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Jun <[email protected]>
[ Upstream commit 23f0e34c64acba15cad4d23e50f41f533da195fa ]
syzbot reported a KASAN slab-use-after-free read in rtl8150_start_xmit() when accessing skb->len for tx statistics after usb_submit_urb() has been called:
BUG: KASAN: slab-use-after-free in rtl8150_start_xmit+0x71f/0x760
drivers/net/usb/rtl8150.c:712
Read of size 4 at addr ffff88810eb7a930 by task kworker/0:4/5226The URB completion handler write_bulk_callback() frees the skb via dev_kfree_skb_irq(dev->tx_skb). The URB may complete on another CPU in softirq context before usb_submit_urb() returns in the submitter, so by the time the submitter reads skb->len the skb has already been queued to the per-CPU completion_queue and freed by net_tx_action():
CPU A (xmit) CPU B (USB completion softirq)
------------ ------------------------------
dev->tx_skb = skb;
usb_submit_urb() --+
|-------> write_bulk_callback()
| dev_kfree_skb_irq(dev->tx_skb)
| net_tx_action()
| napi_skb_cache_put() <-- free
netdev->stats.tx_bytes |
+= skb->len; <-- UAF readFix it by caching skb->len before submitting the URB and using the cached value when updating the tx_bytes counter.
The pre-existing tx_bytes semantics are preserved: the counter tracks the original frame length (skb->len), not the ETH_ZLEN/USB-alignment padded "count" value that is handed to the device. Changing that would be a user-visible accounting change and is out of scope for this UAF fix.
--- drivers/net/usb/rtl8150.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/usb/rtl8150.c +4 -1
@@ -685,6 +685,7 @@ static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev) {rtl8150_t *dev =netdev_priv (netdev); +unsigned int skb_len;int count, res;/* pad the frame and ensure terminating USB packet, datasheet 9.2.3 */
@@ -696,6 +697,8 @@ static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } + skb_len = skb->len; +netif_stop_queue (netdev); dev->tx_skb = skb; usb_fill_bulk_urb(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2),
@@ -711,7 +714,7 @@ static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb, } }else { netdev->stats.tx_packets++; - netdev->stats.tx_bytes += skb->len; + netdev->stats.tx_bytes += skb_len;netif_trans_update (netdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/776 net: usb: rtl8150: free skb on usb_submit_urb() failure in xmit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Morduan Zang <[email protected]>
[ Upstream commit adbe2cdf75461891e50dbe11896ac78e9af1f874 ]
When rtl8150_start_xmit() fails to submit the tx URB, the URB is never handed to the USB core and write_bulk_callback() will not run. The driver returns NETDEV_TX_OK, which tells the networking stack that the skb has been consumed, but nothing actually frees the skb on this error path:
dev->tx_skb = skb;
...
if ((res = usb_submit_urb(dev->tx_urb, GFP_ATOMIC))) {
...
/* no kfree_skb here */
}
return NETDEV_TX_OK;This leaks the skb on every submit failure and also leaves dev->tx_skb pointing at memory that the driver itself may later free, which is fragile.
Free the skb with dev_kfree_skb_any() in the error path and clear dev->tx_skb so no stale pointer is left behind.
--- drivers/net/usb/rtl8150.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/usb/rtl8150.c +7 -0
@@ -712,6 +712,13 @@ static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb, netdev->stats.tx_errors++;netif_start_queue (netdev); } +/* +* The URB was not submitted, so write_bulk_callback() will +* never run to free dev->tx_skb. Drop the skb here and +* clear tx_skb to avoid leaving a stale pointer. +*/ + dev->tx_skb =NULL ; +dev_kfree_skb_any (skb); }else { netdev->stats.tx_packets++; netdev->stats.tx_bytes += skb_len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/776 NFC: trf7970a: Ignore antenna noise when checking for RF field
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Geurts <[email protected]>
[ Upstream commit a9bc28aa4e64320668131349436a650bf42591a5 ]
The main channel Received Signal Strength Indicator (RSSI) measurement is used to determine whether an RF field is present or not. RSSI != 0 is interpreted as an RF Field is present. This does not take RF noise and measurement inaccuracy into account, and results in false positives in the field.
Define a noise level and make sure the RF field is only interpreted as present when the RSSI is above the noise level.
--- drivers/nfc/trf7970a.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nfc/trf7970a.c +2 -1
@@ -311,6 +311,7 @@#define TRF7970A_RSSI_OSC_STATUS_RSSI_MASK (BIT(2) | BIT(1) | BIT(0))#define TRF7970A_RSSI_OSC_STATUS_RSSI_X_MASK (BIT(5) | BIT(4) | BIT(3))#define TRF7970A_RSSI_OSC_STATUS_RSSI_OSC_OK BIT(6) +#define TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL 1#define TRF7970A_SPECIAL_FCN_REG1_COL_7_6 BIT(0)#define TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL BIT(1)
@@ -1253,7 +1254,7 @@ static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)if (ret)return ret; -if (rssi &TRF7970A_RSSI_OSC_STATUS_RSSI_MASK ) +if ((rssi &TRF7970A_RSSI_OSC_STATUS_RSSI_MASK ) >TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL ) *is_rf_field = true;else *is_rf_field = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/776 net: phy: dp83869: fix setting CLK_O_SEL field.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Schocher <[email protected]>
[ Upstream commit 46f74a3f7d57d9cc0110b09cbc8163fa0a01afa2 ]
Table 7-121 in datasheet says we have to set register 0xc6 to value 0x10 before CLK_O_SEL can be modified. No more infos about this field found in datasheet. With this fix, setting of CLK_O_SEL field in IO_MUX_CFG register worked through dts property "ti,clk-output-sel" on a DP83869HMRGZR.
--- drivers/net/phy/dp83869.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/phy/dp83869.c +12 -1
@@ -30,6 +30,7 @@#define DP83869_RGMIICTL 0x0032#define DP83869_STRAP_STS1 0x006e#define DP83869_RGMIIDCTL 0x0086 +#define DP83869_ANA_PLL_PROG_PI 0x00c6#define DP83869_RXFCFG 0x0134#define DP83869_RXFPMD1 0x0136#define DP83869_RXFPMD2 0x0137
@@ -801,12 +802,22 @@ static int dp83869_config_init(struct phy_device *phydev)dp83869_config_port_mirroring (phydev);/* Clock output selection if muxing property is set */ -if (dp83869->clk_output_sel !=DP83869_CLK_O_SEL_REF_CLK ) +if (dp83869->clk_output_sel !=DP83869_CLK_O_SEL_REF_CLK ) { +/* +* Table 7-121 in datasheet says we have to set register 0xc6 +* to value 0x10 before CLK_O_SEL can be modified. +*/ + ret =phy_write_mmd (phydev,DP83869_DEVADDR , +DP83869_ANA_PLL_PROG_PI ,0x10 ); +if (ret) +return ret; + ret =phy_modify_mmd (phydev,DP83869_DEVADDR ,DP83869_IO_MUX_CFG ,DP83869_IO_MUX_CFG_CLK_O_SEL_MASK , dp83869->clk_output_sel <<DP83869_IO_MUX_CFG_CLK_O_SEL_SHIFT ); + }if (phy_interface_is_rgmii (phydev)) { ret = phy_write_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIIDCTL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/776 ASoC: codecs: ab8500: Fix casting of private data
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
[ Upstream commit a201aef1a88b675e9eb8487e27d14e2eef3cef80 ]
ab8500_filter_controls[i].private_value is initialized using
.private_value = (unsigned long)&(struct filter_control)
{.count = xcount, .min = xmin, .max = xmax}thus it's a pointer to a struct filter_control casted to unsigned long.
So to get back that pointer .private_data must be cast back, not its address.
--- sound/soc/codecs/ab8500-codec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/ab8500-codec.c +3 -3
@@ -2498,13 +2498,13 @@ static int ab8500_codec_probe(struct snd_soc_component *component)return status; } fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_ANC_FIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_ANC_FIR ].private_value; drvdata->anc_fir_values = (long *)fc->value; fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_ANC_IIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_ANC_IIR ].private_value; drvdata->anc_iir_values = (long *)fc->value; fc = (struct filter_control *) - &ab8500_filter_controls[AB8500_FILTER_SID_FIR ].private_value; + ab8500_filter_controls[AB8500_FILTER_SID_FIR ].private_value; drvdata->sid_fir_values = (long *)fc->value;snd_soc_dapm_disable_pin (dapm,"ANC Configure Input" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/776 netfilter: skip recording stale or retransmitted INIT
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 576a5d2bad4814c881a829576b1261b9b8159d2b ]
An INIT whose init_tag matches the peer's vtag does not provide new state information. It indicates either:
- a stale INIT (after INIT-ACK has already been seen on the same side), or
- a retransmitted INIT (after INIT has already been recorded on the same side).
In both cases, the INIT must not update ct->proto.sctp.init[] state, since it does not advance the handshake tracking and may otherwise corrupt INIT/INIT-ACK validation logic.
Allow INIT processing only when the conntrack entry is newly created (SCTP_CONNTRACK_NONE), or when the init_tag differs from the stored peer vtag.
Note it skips the check for the ct with old_state SCTP_CONNTRACK_NONE in nf_conntrack_sctp_packet(), as it is just created in sctp_new() where it set ct->proto.sctp.vtag[IP_CT_DIR_REPLY] = ih->init_tag.
--- net/netfilter/nf_conntrack_proto_sctp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_proto_sctp.c +7 -3
@@ -484,9 +484,13 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,if (!ih) goto out_unlock; -if (ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir]) - ct->proto.sctp.init[!dir] =0 ; - ct->proto.sctp.init[dir] =1 ; +/* Do not record INIT matching peer vtag (stale or retransmitted INIT). */ +if (old_state ==SCTP_CONNTRACK_NONE || + ct->proto.sctp.vtag[!dir] != ih->init_tag) { +if (ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir]) + ct->proto.sctp.init[!dir] =0 ; + ct->proto.sctp.init[dir] =1 ; + }pr_debug ("Setting vtag %x for dir %d\n" , ih->init_tag, !dir); ct->proto.sctp.vtag[!dir] = ih->init_tag;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/776 sctp: discard stale INIT after handshake completion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 8a92cb475ca90d84db769e4d4383e631ace0d6e5 ]
After an association reaches ESTABLISHED, the peer’s init_tag is already known from the handshake. Any subsequent INIT with the same init_tag is not a valid restart, but a delayed or duplicate INIT.
Drop such INIT chunks in sctp_sf_do_unexpected_init() instead of processing them as new association attempts.
--- net/sctp/sm_statefuns.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sctp/sm_statefuns.c +6 -0
@@ -1555,6 +1555,12 @@ static enum sctp_disposition sctp_sf_do_unexpected_init(/* Tag the variable length parameters. */ chunk->param_hdr.v =skb_pull (chunk->skb,sizeof (struct sctp_inithdr )); +if (asoc->state >=SCTP_STATE_ESTABLISHED ) { +/* Discard INIT matching peer vtag after handshake completion (stale INIT). */ +if (ntohl (chunk->subh.init_hdr->init_tag) == asoc->peer.i.init_tag) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); + } +/* Verify the INIT chunk before processing it. */ err_chunk =NULL ; if (!sctp_verify_init(net, ep, asoc, chunk->chunk_hdr->type,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/776 ipv4: rename and move ip_route_output_tunnel()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit bf3fcbf7e7a08015d3b169bad6281b29d45c272d ]
At the moment ip_route_output_tunnel() is used only by bareudp. Ideally, other UDP tunnel implementations should use it, but to do so the function needs to accept new parameters that are specific for UDP tunnels, such as the ports.
Prepare for these changes by renaming the function to udp_tunnel_dst_lookup() and move it to file net/ipv4/udp_tunnel_core.c.
Stable-dep-of: aa6c6d9ee064 ("bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()")
--- drivers/net/bareudp.c | 8 +++---- include/net/route.h | 6 ----- include/net/udp_tunnel.h | 6 +++++ net/ipv4/route.c | 48 -------------------------------------- net/ipv4/udp_tunnel_core.c | 48 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 58 deletions(-)
drivers/net/bareudp.c +4 -4
@@ -318,8 +318,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,if (!sock)return -ESHUTDOWN ; - rt =ip_route_output_tunnel (skb, dev, bareudp->net, &saddr, info, -IPPROTO_UDP , use_cache); + rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, info, +IPPROTO_UDP , use_cache);if (IS_ERR (rt))return PTR_ERR (rt);
@@ -498,8 +498,8 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,struct rtable *rt;__be32 saddr; - rt =ip_route_output_tunnel (skb, dev, bareudp->net, &saddr, - info,IPPROTO_UDP , use_cache); + rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, + info,IPPROTO_UDP , use_cache);if (IS_ERR (rt))return PTR_ERR (rt);
include/net/route.h +0 -6
@@ -128,12 +128,6 @@ static inline struct rtable *__ip_route_output_key(struct net *net,struct rtable *ip_route_output_flow (struct net *,struct flowi4 *flp,const struct sock *sk); -struct rtable *ip_route_output_tunnel (struct sk_buff *skb, -struct net_device *dev, -struct net *net,__be32 *saddr, -const struct ip_tunnel_info *info, -u8 protocol,bool use_cache); -struct dst_entry *ipv4_blackhole_route (struct net *net,struct dst_entry *dst_orig);
include/net/udp_tunnel.h +6 -0
@@ -161,6 +161,12 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,void udp_tunnel_sock_release (struct socket *sock); +struct rtable *udp_tunnel_dst_lookup (struct sk_buff *skb, +struct net_device *dev, +struct net *net,__be32 *saddr, +const struct ip_tunnel_info *info, +u8 protocol,bool use_cache); +struct metadata_dst *udp_tun_rx_dst (struct sk_buff *skb,unsigned short family,__be16 flags,__be64 tunnel_id,int md_size);
net/ipv4/route.c +0 -48
54 lines not on this page · raw message
net/ipv4/udp_tunnel_core.c +48 -0
52 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/776 ipv4: remove "proto" argument from udp_tunnel_dst_lookup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 78f3655adcb52412275f282267ee771421731632 ]
The function is now UDP-specific, the protocol is always IPPROTO_UDP.
Stable-dep-of: aa6c6d9ee064 ("bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()")
--- drivers/net/bareudp.c | 4 ++-- include/net/udp_tunnel.h | 2 +- net/ipv4/udp_tunnel_core.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/bareudp.c +2 -2
@@ -319,7 +319,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,return -ESHUTDOWN ; rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, info, -IPPROTO_UDP , use_cache); + use_cache);if (IS_ERR (rt))return PTR_ERR (rt);
@@ -499,7 +499,7 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,__be32 saddr; rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, - info,IPPROTO_UDP , use_cache); + info, use_cache);if (IS_ERR (rt))return PTR_ERR (rt);
include/net/udp_tunnel.h +1 -1
@@ -165,7 +165,7 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,struct net_device *dev, struct net *net, __be32 *saddr, const struct ip_tunnel_info *info, - u8 protocol, bool use_cache); + bool use_cache); struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, __be16 flags, __be64 tunnel_id,
net/ipv4/udp_tunnel_core.c +2 -2
@@ -211,7 +211,7 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,struct net_device *dev, struct net *net, __be32 *saddr, const struct ip_tunnel_info *info, - u8 protocol, bool use_cache) + bool use_cache) { #ifdef CONFIG_DST_CACHE struct dst_cache *dst_cache;
@@ -230,7 +230,7 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,#endif memset (&fl4,0 ,sizeof (fl4)); fl4.flowi4_mark = skb->mark; - fl4.flowi4_proto = protocol; + fl4.flowi4_proto =IPPROTO_UDP ; fl4.daddr = info->key.u.ipv4.dst; fl4.saddr = info->key.u.ipv4.src; tos = info->key.tos;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/776 ipv4: add new arguments to udp_tunnel_dst_lookup()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit 72fc68c6356b663a8763f02d9b0ec773d59a4949 ]
We want to make the function more generic so that it can be used by other UDP tunnel implementations such as geneve and vxlan. To do that, add the following arguments:
- source and destination UDP port;
- ifindex of the output interface, needed by vxlan;
- the tos, because in some cases it is not taken from struct ip_tunnel_info (for example, when it's inherited from the inner packet);
- the dst cache, because not all tunnel types (e.g. vxlan) want to use the one from struct ip_tunnel_info.
With these parameters, the function no longer needs the full struct ip_tunnel_info as argument and we can pass only the relevant part of it (struct ip_tunnel_key).
Stable-dep-of: aa6c6d9ee064 ("bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()")
--- drivers/net/bareudp.c | 11 +++++++---- include/net/udp_tunnel.h | 8 +++++--- net/ipv4/udp_tunnel_core.c | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 20 deletions(-)
drivers/net/bareudp.c +7 -4
@@ -318,8 +318,10 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,if (!sock)return -ESHUTDOWN ; - rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, info, - use_cache); + rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net,0 , &saddr, &info->key, +0 ,0 , key->tos, + use_cache ? + (struct dst_cache *)&info->dst_cache :NULL );if (IS_ERR (rt))return PTR_ERR (rt);
@@ -498,8 +500,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,struct rtable *rt;__be32 saddr; - rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net, &saddr, - info, use_cache); + rt =udp_tunnel_dst_lookup (skb, dev, bareudp->net,0 , &saddr, + &info->key,0 ,0 , info->key.tos, + use_cache ? &info->dst_cache :NULL );if (IS_ERR (rt))return PTR_ERR (rt);
include/net/udp_tunnel.h +5 -3
@@ -163,9 +163,11 @@ void udp_tunnel_sock_release(struct socket *sock);struct rtable *udp_tunnel_dst_lookup (struct sk_buff *skb,struct net_device *dev, -struct net *net,__be32 *saddr, -const struct ip_tunnel_info *info, -bool use_cache); +struct net *net,int oif, +__be32 *saddr, +const struct ip_tunnel_key *key, +__be16 sport,__be16 dport,u8 tos, +struct dst_cache *dst_cache); struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, __be16 flags, __be64 tunnel_id,
net/ipv4/udp_tunnel_core.c +13 -13
@@ -209,31 +209,31 @@ EXPORT_SYMBOL_GPL(udp_tun_rx_dst);struct rtable *udp_tunnel_dst_lookup (struct sk_buff *skb,struct net_device *dev, -struct net *net,__be32 *saddr, -const struct ip_tunnel_info *info, -bool use_cache) +struct net *net,int oif, +__be32 *saddr, +const struct ip_tunnel_key *key, +__be16 sport,__be16 dport,u8 tos, +struct dst_cache *dst_cache) { -#ifdef CONFIG_DST_CACHE -struct dst_cache *dst_cache; -#endif struct rtable *rt =NULL ;struct flowi4 fl4; -__u8 tos;#ifdef CONFIG_DST_CACHE - dst_cache = (struct dst_cache *)&info->dst_cache; -if (use_cache) { +if (dst_cache) { rt =dst_cache_get_ip4 (dst_cache, saddr);if (rt)return rt; }#endif +memset (&fl4,0 ,sizeof (fl4)); fl4.flowi4_mark = skb->mark; fl4.flowi4_proto =IPPROTO_UDP ; - fl4.daddr = info->key.u.ipv4.dst; - fl4.saddr = info->key.u.ipv4.src; - tos = info->key.tos; + fl4.flowi4_oif = oif; + fl4.daddr = key->u.ipv4.dst; + fl4.saddr = key->u.ipv4.src; + fl4.fl4_dport = dport; + fl4.fl4_sport = sport; fl4.flowi4_tos =RT_TOS (tos); rt =ip_route_output_key (net, &fl4);
@@ -247,7 +247,7 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,return ERR_PTR (-ELOOP ); }#ifdef CONFIG_DST_CACHE -if (use_cache) +if (dst_cache)dst_cache_set_ip4 (dst_cache, &rt->dst, fl4.saddr);#endif *saddr = fl4.saddr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/776 ipv6: rename and move ip6_dst_lookup_tunnel()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beniamino Galvani <[email protected]>
[ Upstream commit fc47e86dbfb75a864c0c9dd8e78affb6506296bb ]
At the moment ip6_dst_lookup_tunnel() is used only by bareudp. Ideally, other UDP tunnel implementations should use it, but to do so the function needs to accept new parameters that are specific for UDP tunnels, such as the ports.
Prepare for these changes by renaming the function to udp_tunnel6_dst_lookup() and move it to file net/ipv6/ip6_udp_tunnel.c.
This is similar to what already done for IPv4 in commit bf3fcbf7e7a0 ("ipv4: rename and move ip_route_output_tunnel()").
Stable-dep-of: aa6c6d9ee064 ("bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()")
--- drivers/net/bareudp.c | 10 +++--- include/net/ipv6.h | 6 ---- include/net/udp_tunnel.h | 7 ++++ net/ipv6/ip6_output.c | 68 -------------------------------------- net/ipv6/ip6_udp_tunnel.c | 69 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 79 deletions(-)
drivers/net/bareudp.c +5 -5
@@ -386,8 +386,8 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,if (!sock)return -ESHUTDOWN ; - dst =ip6_dst_lookup_tunnel (skb, dev, bareudp->net, sock, &saddr, info, -IPPROTO_UDP , use_cache); + dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, &saddr, info, +IPPROTO_UDP , use_cache);if (IS_ERR (dst))return PTR_ERR (dst);
@@ -513,9 +513,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,struct in6_addr saddr;struct socket *sock =rcu_dereference (bareudp->sock); - dst =ip6_dst_lookup_tunnel (skb, dev, bareudp->net, sock, - &saddr, info,IPPROTO_UDP , - use_cache); + dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, + &saddr, info,IPPROTO_UDP , + use_cache);if (IS_ERR (dst))return PTR_ERR (dst);
include/net/ipv6.h +0 -6
@@ -1034,12 +1034,6 @@ struct dst_entry *ip6_dst_lookup_flow(struct net *net, const struct sock *sk, ststruct dst_entry *ip6_sk_dst_lookup_flow (struct sock *sk,struct flowi6 *fl6,const struct in6_addr *final_dst,bool connected); -struct dst_entry *ip6_dst_lookup_tunnel (struct sk_buff *skb, -struct net_device *dev, -struct net *net,struct socket *sock, -struct in6_addr *saddr, -const struct ip_tunnel_info *info, -u8 protocol,bool use_cache);struct dst_entry *ip6_blackhole_route (struct net *net,struct dst_entry *orig_dst);
include/net/udp_tunnel.h +7 -0
@@ -168,6 +168,13 @@ struct rtable *udp_tunnel_dst_lookup(struct sk_buff *skb,const struct ip_tunnel_key *key, __be16 sport, __be16 dport, u8 tos, struct dst_cache *dst_cache); +struct dst_entry *udp_tunnel6_dst_lookup (struct sk_buff *skb, +struct net_device *dev, +struct net *net, +struct socket *sock, +struct in6_addr *saddr, +const struct ip_tunnel_info *info, +u8 protocol,bool use_cache); struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family, __be16 flags, __be64 tunnel_id,
net/ipv6/ip6_output.c +0 -68
74 lines not on this page · raw message
net/ipv6/ip6_udp_tunnel.c +69 -0
76 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/776 bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit aa6c6d9ee064aabfede4402fd1283424e649ca19 ]
bareudp_fill_metadata_dst() passes bareudp->sock to udp_tunnel6_dst_lookup() in the IPv6 path without a NULL check. The socket is only created in bareudp_open() and NULLed in bareudp_stop(), so calling this function while the device is down triggers a NULL dereference via sock->sk.
BUG: kernel NULL pointer dereference, address: 0000000000000018 RIP: 0010:udp_tunnel6_dst_lookup (net/ipv6/ip6_udp_tunnel.c:160) Call Trace: <TASK> bareudp_fill_metadata_dst (drivers/net/bareudp.c:532) do_execute_actions (net/openvswitch/actions.c:901) ovs_execute_actions (net/openvswitch/actions.c:1589) ovs_packet_cmd_execute (net/openvswitch/datapath.c:700) genl_family_rcv_msg_doit (net/netlink/genetlink.c:1114) genl_rcv_msg (net/netlink/genetlink.c:1209) netlink_rcv_skb (net/netlink/af_netlink.c:2550) </TASK>
Add a NULL check returning -ESHUTDOWN, consistent with the xmit paths in the same driver.
--- drivers/net/bareudp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/bareudp.c +3 -0
@@ -513,6 +513,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev,struct in6_addr saddr;struct socket *sock =rcu_dereference (bareudp->sock); +if (!sock) +return -ESHUTDOWN ; + dst =udp_tunnel6_dst_lookup (skb, dev, bareudp->net, sock, &saddr, info,IPPROTO_UDP , use_cache);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/776 net/sched: sch_cake: annotate data-races in cake_dump_stats() (V)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit a6c95b833dc17e84d16a8ac0f40fd0931616a52d ]
cake_dump_stats() runs without qdisc spinlock being held.
In this final patch, I add READ_ONCE()/WRITE_ONCE() annotations for cparams.target and cparams.interval.
--- net/sched/sch_cake.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/sched/sch_cake.c +7 -6
@@ -2313,10 +2313,11 @@ static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu, byte_target_ns = (byte_target * rate_ns) >> rate_shft; - b->cparams.target =max ((byte_target_ns *3 ) /2 , target_ns); - b->cparams.interval =max (rtt_est_ns + - b->cparams.target - target_ns, - b->cparams.target *2 ); +WRITE_ONCE (b->cparams.target, +max ((byte_target_ns *3 ) /2 , target_ns)); +WRITE_ONCE (b->cparams.interval, +max (rtt_est_ns + b->cparams.target - target_ns, + b->cparams.target *2 )); b->cparams.mtu_time = byte_target_ns; b->cparams.p_inc =1 <<24 ;/* 1/256 */ b->cparams.p_dec =1 <<20 ;/* 1/4096 */
@@ -2933,9 +2934,9 @@ static int cake_dump_stats(struct Qdisc *sch, struct gnet_dump *d)PUT_TSTAT_U32 (BACKLOG_BYTES , b->tin_backlog);PUT_TSTAT_U32 (TARGET_US , -ktime_to_us (ns_to_ktime (b->cparams.target))); +ktime_to_us (ns_to_ktime (READ_ONCE (b->cparams.target))));PUT_TSTAT_U32 (INTERVAL_US , -ktime_to_us (ns_to_ktime (b->cparams.interval))); +ktime_to_us (ns_to_ktime (READ_ONCE (b->cparams.interval))));PUT_TSTAT_U32 (SENT_PACKETS , b->packets);PUT_TSTAT_U32 (DROPPED_PACKETS , b->tin_dropped);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/776 ALSA: hda/conexant: add a new hda codec SN6140
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bo liu <[email protected]>
[ Upstream commit ca348e7fe1ab9192ad7d9ff029a82a1594e0e289 ]
The current kernel does not support the SN6140 codec chip. Add the SN6140 codec configuration item to kernel.
Stable-dep-of: b0e2333a2311 ("ALSA: hda/conexant: Fix missing error check for jack detection")
--- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_conexant.c +1 -0
@@ -1303,6 +1303,7 @@ static int patch_conexant_auto(struct hda_codec *codec)static const struct hda_device_id snd_hda_id_conexant[] = {HDA_CODEC_ENTRY (0x14f11f86 ,"CX8070" , patch_conexant_auto), +HDA_CODEC_ENTRY (0x14f11f87 ,"SN6140" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f12008 ,"CX8200" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f120d0 ,"CX11970" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f120d1 ,"SN6180" , patch_conexant_auto),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/776 ALSA: hda/conexant: fix some typos
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oldherl Oh <[email protected]>
[ Upstream commit 73253f2fd1d0a44708735c842e37163712e3f03b ]
Fix some typos in patch_conexant.c
Stable-dep-of: b0e2333a2311 ("ALSA: hda/conexant: Fix missing error check for jack detection")
--- sound/pci/hda/patch_conexant.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/pci/hda/patch_conexant.c +8 -8
@@ -166,18 +166,18 @@ static void cxt_init_gpio_led(struct hda_codec *codec)static void cx_fixup_headset_recog (struct hda_codec *codec) { -unsigned int mic_persent; +unsigned int mic_present;/* fix some headset type recognize fail issue, such as EDIFIER headset */ -/* set micbiasd output current comparator threshold from 66% to 55%. */ +/* set micbias output current comparator threshold from 66% to 55%. */ snd_hda_codec_write (codec,0x1c ,0 ,0x320 ,0x010 ); -/* set OFF voltage for DFET from -1.2V to -0.8V, set headset micbias registor +/* set OFF voltage for DFET from -1.2V to -0.8V, set headset micbias register * value adjustment trim from 2.2K ohms to 2.0K ohms. */ snd_hda_codec_write (codec,0x1c ,0 ,0x3b0 ,0xe10 );/* fix reboot headset type recognize fail issue */ - mic_persent =snd_hda_codec_read (codec,0x19 ,0 ,AC_VERB_GET_PIN_SENSE ,0x0 ); -if (mic_persent &AC_PINSENSE_PRESENCE ) + mic_present =snd_hda_codec_read (codec,0x19 ,0 ,AC_VERB_GET_PIN_SENSE ,0x0 ); +if (mic_present &AC_PINSENSE_PRESENCE )/* enable headset mic VREF */ snd_hda_codec_write (codec,0x19 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x24 );else
@@ -247,9 +247,9 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_ {unsigned int mic_present; -/* In cx8070 and sn6140, the node 16 can only be config to headphone or disabled, -* the node 19 can only be config to microphone or disabled. -* Check hp&mic tag to process headset pulgin&plugout. +/* In cx8070 and sn6140, the node 16 can only be configured to headphone or disabled, +* the node 19 can only be configured to microphone or disabled. +* Check hp&mic tag to process headset plugin & plugout. */ mic_present =snd_hda_codec_read (codec,0x19 ,0 ,AC_VERB_GET_PIN_SENSE ,0x0 );if (!(mic_present &AC_PINSENSE_PRESENCE ))/* mic plugout */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/776 ALSA: hda/conexant: Renaming the codec with device ID 0x1f86 and 0x1f87
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
[ Upstream commit 7f4c540e0859e2025675d2c5c5c6ab88eaf817e2 ]
Due to changes in the manufacturer's plan, all 0x14f11f86 will be named CX11880, and 0x14f11f87 will be named SN6140
Stable-dep-of: b0e2333a2311 ("ALSA: hda/conexant: Fix missing error check for jack detection")
--- sound/pci/hda/patch_conexant.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/pci/hda/patch_conexant.c +6 -6
@@ -42,7 +42,7 @@ struct conexant_spec {unsigned int gpio_led;unsigned int gpio_mute_led_mask;unsigned int gpio_mic_led_mask; -bool is_cx8070_sn6140; +bool is_cx11880_sn6140; };
@@ -195,7 +195,7 @@ static int cx_auto_init(struct hda_codec *codec)cxt_init_gpio_led (codec);snd_hda_apply_fixup (codec,HDA_FIXUP_ACT_INIT ); -if (spec->is_cx8070_sn6140) +if (spec->is_cx11880_sn6140)cx_fixup_headset_recog (codec);return 0 ;
@@ -247,7 +247,7 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_ {unsigned int mic_present; -/* In cx8070 and sn6140, the node 16 can only be configured to headphone or disabled, +/* In cx11880 and sn6140, the node 16 can only be configured to headphone or disabled, * the node 19 can only be configured to microphone or disabled. * Check hp&mic tag to process headset plugin & plugout. */
@@ -1210,11 +1210,11 @@ static int patch_conexant_auto(struct hda_codec *codec) codec->spec = spec; codec->patch_ops = cx_auto_patch_ops; -/* init cx8070/sn6140 flag and reset headset_present_flag */ +/* init cx11880/sn6140 flag and reset headset_present_flag */ switch (codec->core.vendor_id) {case 0x14f11f86 :case 0x14f11f87 : - spec->is_cx8070_sn6140 = true; + spec->is_cx11880_sn6140 = true;snd_hda_jack_detect_enable_callback (codec,0x19 , cx_update_headset_mic_vref);break ; }
@@ -1302,7 +1302,7 @@ static int patch_conexant_auto(struct hda_codec *codec)*/ static const struct hda_device_id snd_hda_id_conexant[] = { -HDA_CODEC_ENTRY (0x14f11f86 ,"CX8070" , patch_conexant_auto), +HDA_CODEC_ENTRY (0x14f11f86 ,"CX11880" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f11f87 ,"SN6140" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f12008 ,"CX8200" , patch_conexant_auto),HDA_CODEC_ENTRY (0x14f120d0 ,"CX11970" , patch_conexant_auto),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/776 ALSA: hda/conexant: Fix missing error check for jack detection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
[ Upstream commit b0e2333a231107adedd38c6fcfe1adc6162716fc ]
In cx_probe(), the return value of snd_hda_jack_detect_enable_callback() is ignored. This function returns a pointer, and if it fails (e.g., due to memory allocation failure), it returns an error pointer which must be checked using IS_ERR().
If the registration fails, the driver continues to probe, but the jack detection callback will not be registered. This can lead to a kernel crash later when the driver attempts to handle jack events or accesses the uninitialized structure.
Check the return value using IS_ERR() and propagate the error via PTR_ERR() to the probe caller.
--- sound/pci/hda/patch_conexant.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/hda/patch_conexant.c +7 -1
@@ -1199,6 +1199,7 @@ static void add_cx5051_fake_mutes(struct hda_codec *codec)static int patch_conexant_auto (struct hda_codec *codec) {struct conexant_spec *spec; +struct hda_jack_callback *callback;int err;codec_info (codec,"%s: BIOS auto-probing.\n" , codec->core.chip_name);
@@ -1215,7 +1216,12 @@ static int patch_conexant_auto(struct hda_codec *codec)case 0x14f11f86 :case 0x14f11f87 : spec->is_cx11880_sn6140 = true; -snd_hda_jack_detect_enable_callback (codec,0x19 , cx_update_headset_mic_vref); + callback =snd_hda_jack_detect_enable_callback (codec,0x19 , + cx_update_headset_mic_vref); +if (IS_ERR (callback)) { + err =PTR_ERR (callback); + goto error; + }break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/776 drm/amd/display: Allow DCE link encoder without AUX registers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit ac27e3f99035f132f23bc0409d0e57f11f054c70 ]
Allow constructing the DCE link encoder without DDC, which means the AUX registers array will be NULL.
This is necessary to support embedded connectors without DDC.
--- drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +3 -1
@@ -994,7 +994,9 @@ void dce110_link_encoder_hw_init(ASSERT (result ==BP_RESULT_OK ); } -aux_initialize (enc110); + +if (enc110->aux_regs) +aux_initialize (enc110);/* reinitialize HPD. * hpd_initialize() will pass DIG_FE id to HW context.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/776 drm/amd/display: Read EDID from VBIOS embedded panel info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 9ea16f64189bf7b6ba50fc7f0325b3c1f836d105 ]
Some board manufacturers hardcode the EDID for the embedded panel in the VBIOS. This EDID should be used when the panel doesn't have a DDC.
For reference, see the legacy non-DC display code:amdgpu_atombios_encoder_get_lcd_info()
This is necessary to support embedded connectors without DDC.
--- .../gpu/drm/amd/display/dc/bios/bios_parser.c | 62 +++++++++++++++++++ .../display/include/grph_object_ctrl_defs.h | 4 ++ 2 files changed, 66 insertions(+)
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +62 -0
@@ -1215,6 +1215,60 @@ static enum bp_result bios_parser_get_embedded_panel_info(return BP_RESULT_FAILURE ; } +static enum bp_result get_embedded_panel_extra_info ( +struct bios_parser *bp, +struct embedded_panel_info *info, +const uint32_t table_offset) +{ +uint8_t *record =bios_get_image (&bp->base, table_offset,1 ); +ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record; +ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record; + +while (*record !=ATOM_RECORD_END_TYPE ) { +switch (*record) { +case LCD_MODE_PATCH_RECORD_MODE_TYPE : + record +=sizeof (ATOM_PATCH_RECORD_MODE ); +break ; +case LCD_RTS_RECORD_TYPE : + record +=sizeof (ATOM_LCD_RTS_RECORD ); +break ; +case LCD_CAP_RECORD_TYPE : + record +=sizeof (ATOM_LCD_MODE_CONTROL_CAP ); +break ; +case LCD_FAKE_EDID_PATCH_RECORD_TYPE : + fake_edid_record = (ATOM_FAKE_EDID_PATCH_RECORD *)record; +if (fake_edid_record->ucFakeEDIDLength) { +if (fake_edid_record->ucFakeEDIDLength ==128 ) + info->fake_edid_size = + fake_edid_record->ucFakeEDIDLength; +else + info->fake_edid_size = + fake_edid_record->ucFakeEDIDLength *128 ; + + info->fake_edid = fake_edid_record->ucFakeEDIDString; + + record +=struct_size (fake_edid_record, + ucFakeEDIDString, + info->fake_edid_size); + }else { +/* empty fake edid record must be 3 bytes long */ + record +=sizeof (ATOM_FAKE_EDID_PATCH_RECORD ) +1 ; + } +break ; +case LCD_PANEL_RESOLUTION_RECORD_TYPE : + panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record; + info->panel_width_mm = panel_res_record->usHSize; + info->panel_height_mm = panel_res_record->usVSize; + record +=sizeof (ATOM_PANEL_RESOLUTION_PATCH_RECORD ); +break ; +default : +return BP_RESULT_BADBIOSTABLE ; + } + } + +return BP_RESULT_OK ; +} +static enum bp_result get_embedded_panel_info_v1_2 (struct bios_parser *bp,struct embedded_panel_info *info)
@@ -1331,6 +1385,10 @@ static enum bp_result get_embedded_panel_info_v1_2(if (ATOM_PANEL_MISC_API_ENABLED & lvds->ucLVDS_Misc) info->lcd_timing.misc_info.API_ENABLED = true; +if (lvds->usExtInfoTableOffset) +return get_embedded_panel_extra_info (bp, info, +le16_to_cpu (lvds->usExtInfoTableOffset) +DATA_TABLES (LCD_Info)); +return BP_RESULT_OK ; }
@@ -1456,6 +1514,10 @@ static enum bp_result get_embedded_panel_info_v1_3( (uint32_t ) (ATOM_PANEL_MISC_V13_GREY_LEVEL & lvds->ucLCD_Misc) >>ATOM_PANEL_MISC_V13_GREY_LEVEL_SHIFT ; +if (lvds->usExtInfoTableOffset) +return get_embedded_panel_extra_info (bp, info, +le16_to_cpu (lvds->usExtInfoTableOffset) +DATA_TABLES (LCD_Info)); +return BP_RESULT_OK ; }
drivers/gpu/drm/amd/display/include/grph_object_ctrl_defs.h +4 -0
@@ -153,6 +153,10 @@ struct embedded_panel_info {uint32_t drr_enabled;uint32_t min_drr_refresh_rate;bool realtek_eDPToLVDS; +uint16_t panel_width_mm; +uint16_t panel_height_mm; +uint16_t fake_edid_size; +const uint8_t *fake_edid; };struct dc_firmware_info {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/776 btrfs: tracepoints: fix sleep while in atomic context in btrfs_sync_file()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit c73370c677646e86fc4b1780fb07027bdf847375 ]
The trace event btrfs_sync_file() is called in an atomic context (all trace events are) and its call to dput(), which is needed due to the call to dget_parent(), can sleep, triggering a kernel splat.
This can be reproduced by enabling the trace event and running btrfs/056 from fstests for example. The splat shown in dmesg is the following:
[53.919] BUG: sleeping function called from invalid context at fs/dcache.c:970 [53.947] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 32773, name: xfs_io [53.988] preempt_count: 2, expected: 0 [53.967] RCU nest depth: 0, expected: 0 [53.943] Preemption disabled at: [53.944] [<0000000000000000>] 0x0 [54.078] CPU: 0 UID: 0 PID: 32773 Comm: xfs_io Tainted: G W 7.1.0-rc1-btrfs-next-232+ #1 PREEMPT(full) [54.070] Tainted: [W]=WARN [54.071] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014 [54.072] Call Trace: [54.074] <TASK> [54.076] dump_stack_lvl+0x56/0x80 [54.079] __might_resched.cold+0xd6/0x10f [54.072] dput.part.0+0x24/0x110 [54.078] trace_event_raw_event_btrfs_sync_file+0x75/0x140 [btrfs] [54.089] btrfs_sync_file+0x1ed/0x530 [btrfs] [54.087] ? __handle_mm_fault+0x8ae/0xed0 [54.089] btrfs_do_write_iter+0x172/0x210 [btrfs] [54.091] vfs_write+0x21f/0x450 [54.094] __x64_sys_pwrite64+0x8d/0xc0 [54.096] ? do_user_addr_fault+0x20c/0x670 [54.099] do_syscall_64+0x60/0xf20 [54.092] ? clear_bhb_loop+0x60/0xb0 [54.094] entry_SYSCALL_64_after_hwframe+0x76/0x7e
So stop using dget_parent() and dput() and access the parent dentry directly as dentry->d_parent. This is also what ext4 is doing in its equivalent trace event ext4_sync_file_enter().
--- include/trace/events/btrfs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/trace/events/btrfs.h +1 -3
@@ -697,10 +697,8 @@ TRACE_EVENT(btrfs_sync_file,TP_fast_assign ( struct dentry *dentry = file_dentry(file);struct inode *inode =file_inode (file); -struct dentry *parent =dget_parent (dentry); -struct inode *parent_inode =d_inode (parent); +struct inode *parent_inode =d_inode (dentry->d_parent); -dput (parent);TP_fast_assign_fsid (btrfs_sb (inode->i_sb)); __entry->ino =btrfs_ino (BTRFS_I (inode)); __entry->parent =btrfs_ino (BTRFS_I (parent_inode));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/776 SUNRPC: Check if the xprt is connected before handling sysfs reads
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Schumaker <[email protected]>
[ Upstream commit 17f09d3f619a7ad2d2b021b4e5246f08225b1b0f ]
xprts don't immediately reconnect when changing the "dstaddr" property, instead this gets handled the next time an operation uses the transport. This could lead to NULL pointer dereferences when trying to read sysfs files between the disconnect and reconnect operations. Fix this by returning an error if the xprt is not connected.
Stable-dep-of: 421ab1be43bd ("SUNRPC: Do not dereference non-socket transports in sysfs")
--- net/sunrpc/sysfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/sunrpc/sysfs.c +8 -4
@@ -109,8 +109,10 @@ static ssize_t rpc_sysfs_xprt_srcaddr_show(struct kobject *kobj,struct sock_xprt *sock;ssize_t ret =-1 ; -if (!xprt) -return 0 ; +if (!xprt || !xprt_connected (xprt)) { +xprt_put (xprt); +return -ENOTCONN ; + } sock = container_of(xprt, struct sock_xprt, xprt);mutex_lock (&sock->recv_mutex);
@@ -132,8 +134,10 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj,struct rpc_xprt *xprt =rpc_sysfs_xprt_kobj_get_xprt (kobj);ssize_t ret; -if (!xprt) -return 0 ; +if (!xprt || !xprt_connected (xprt)) { +xprt_put (xprt); +return -ENOTCONN ; + } ret =sprintf (buf,"last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n" "max_num_slots=%u\nmin_num_slots=%u\nnum_reqs=%u\n"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/776 SUNRPC: Do not dereference non-socket transports in sysfs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
[ Upstream commit 421ab1be43bd015ffe744f4ea25df4f19d1ce6fe ]
Do not cast the struct xprt to a sock_xprt unless we know it is a UDP or TCP transport. Otherwise the call to lock the mutex will scribble over whatever structure is actually there. This has been seen to cause hard system lockups when the underlying transport was RDMA.
--- include/linux/sunrpc/xprt.h | 3 ++ include/linux/sunrpc/xprtsock.h | 1 - net/sunrpc/sysfs.c | 55 ++++++++++++++++----------------- net/sunrpc/xprtsock.c | 26 ++++++++++++++-- 4 files changed, 54 insertions(+), 31 deletions(-)
include/linux/sunrpc/xprt.h +3 -0
@@ -139,6 +139,9 @@ struct rpc_xprt_ops {void (*rpcbind)(struct rpc_task *task);void (*set_port)(struct rpc_xprt *xprt,unsigned short port);void (*connect)(struct rpc_xprt *xprt,struct rpc_task *task); +int (*get_srcaddr)(struct rpc_xprt *xprt,char *buf, +size_t buflen); +unsigned short (*get_srcport)(struct rpc_xprt *xprt);int (*buf_alloc)(struct rpc_task *task);void (*buf_free)(struct rpc_task *task);void (*prepare_request)(struct rpc_rqst *req);
include/linux/sunrpc/xprtsock.h +0 -1
@@ -10,7 +10,6 @@int init_socket_xprt (void );void cleanup_socket_xprt (void ); -unsigned short get_srcport (struct rpc_xprt *);#define RPC_MIN_RESVPORT (1U)#define RPC_MAX_RESVPORT (65535U)
net/sunrpc/sysfs.c +27 -28
102 lines not on this page · raw message
net/sunrpc/xprtsock.c +24 -2
@@ -1677,7 +1677,7 @@ static int xs_get_srcport(struct sock_xprt *transport)return port; } -unsigned short get_srcport (struct rpc_xprt *xprt) +static unsigned short xs_sock_srcport (struct rpc_xprt *xprt) { struct sock_xprt *sock = container_of(xprt, struct sock_xprt, xprt);unsigned short ret =0 ;
@@ -1687,7 +1687,25 @@ unsigned short get_srcport(struct rpc_xprt *xprt)mutex_unlock (&sock->recv_mutex);return ret; } -EXPORT_SYMBOL (get_srcport); + +static int xs_sock_srcaddr (struct rpc_xprt *xprt,char *buf,size_t buflen) +{ + struct sock_xprt *sock = container_of(xprt, struct sock_xprt, xprt); +union { +struct sockaddr sa; +struct sockaddr_storage st; + } saddr; +int ret = -ENOTCONN ; + +mutex_lock (&sock->recv_mutex); +if (sock->sock) { + ret =kernel_getsockname (sock->sock, &saddr.sa); +if (ret >=0 ) + ret =snprintf (buf, buflen,"%pISc" , &saddr.sa); + } +mutex_unlock (&sock->recv_mutex); +return ret; +}static unsigned short xs_next_srcport (struct sock_xprt *transport,unsigned short port) {
@@ -2678,6 +2696,8 @@ static const struct rpc_xprt_ops xs_udp_ops = { .rpcbind = rpcb_getport_async, .set_port = xs_set_port, .connect = xs_connect, + .get_srcaddr = xs_sock_srcaddr, + .get_srcport = xs_sock_srcport, .buf_alloc = rpc_malloc, .buf_free = rpc_free, .send_request = xs_udp_send_request,
@@ -2700,6 +2720,8 @@ static const struct rpc_xprt_ops xs_tcp_ops = { .rpcbind = rpcb_getport_async, .set_port = xs_set_port, .connect = xs_connect, + .get_srcaddr = xs_sock_srcaddr, + .get_srcport = xs_sock_srcport, .buf_alloc = rpc_malloc, .buf_free = rpc_free, .prepare_request = xs_stream_prepare_request,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/776 flow_dissector: do not dissect PPPoE PFC frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit d6c19b31a3c1d519fabdcf0aa239e6b6109b9473 ]
RFC 2516 Section 7 states that Protocol Field Compression (PFC) is NOT RECOMMENDED for PPPoE. In practice, pppd does not support negotiating PFC for PPPoE sessions, and the flow dissector driver has assumed an uncompressed frame until the blamed commit.
During the review process of that commit [1], support for PFC is suggested. However, having a compressed (1-byte) protocol field means the subsequent PPP payload is shifted by one byte, causing 4-byte misalignment for the network header and an unaligned access exception on some architectures.
The exception can be reproduced by sending a PPPoE PFC frame to an ethernet interface of a MIPS board, with RPS enabled, even if no PPPoE session is active on that interface:
$ 0 : 00000000 80c40000 00000000 85144817 $ 4 : 00000008 00000100 80a75758 81dc9bb8 $ 8 : 00000010 8087ae2c 0000003d 00000000 $12 : 000000e0 00000039 00000000 00000000 $16 : 85043240 80a75758 81dc9bb8 00006488 $20 : 0000002f 00000007 85144810 80a70000 $24 : 81d1bda0 00000000 $28 : 81dc8000 81dc9aa8 00000000 805ead08 Hi : 00009d51 Lo : 2163358a epc : 805e91f0 __skb_flow_dissect+0x1b0/0x1b50 ra : 805ead08 __skb_get_hash_net+0x74/0x12c Status: 11000403 KERNEL EXL IE Cause : 40800010 (ExcCode 04) BadVA : 85144817 PrId : 0001992f (MIPS 1004Kc) Call Trace: [<805e91f0>] __skb_flow_dissect+0x1b0/0x1b50 [<805ead08>] __skb_get_hash_net+0x74/0x12c [<805ef330>] get_rps_cpu+0x1b8/0x3fc [<805fca70>] netif_receive_skb_list_internal+0x324/0x364 [<805fd120>] napi_complete_done+0x68/0x2a4 [<8058de5c>] mtk_napi_rx+0x228/0xfec [<805fd398>] __napi_poll+0x3c/0x1c4 [<805fd754>] napi_threaded_poll_loop+0x234/0x29c [<805fd848>] napi_threaded_poll+0x8c/0xb0 [<80053544>] kthread+0x104/0x12c [<80002bd8>] ret_from_kernel_thread+0x14/0x1c
Code: 02d51821 1060045b 00000000 <8c640000> 3084000f 2c820005 144001a2 00042080 8e220000
To reduce the attack surface and maintain performance, do not process PPPoE PFC frames.
[1] https://lore.kernel.org/r/[email protected]
--- net/core/flow_dissector.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
net/core/flow_dissector.c +5 -8
@@ -1239,16 +1239,13 @@ bool __skb_flow_dissect(const struct net *net,break ; } -/* least significant bit of the most significant octet -* indicates if protocol field was compressed +/* PFC (compressed 1-byte protocol) frames are not processed. +* A compressed protocol field has the least significant bit of +* the most significant octet set, which will fail the following +* ppp_proto_is_valid(), returning FLOW_DISSECT_RET_OUT_BAD. */ ppp_proto =ntohs (hdr->proto); -if (ppp_proto &0x0100 ) { - ppp_proto = ppp_proto >>8 ; - nhoff +=PPPOE_SES_HLEN -1 ; - }else { - nhoff +=PPPOE_SES_HLEN ; - } + nhoff +=PPPOE_SES_HLEN ;if (ppp_proto ==PPP_IP ) { proto =htons (ETH_P_IP );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/776 flow_dissector: Do not count vlan tags inside tunnel payload
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingqing Yang <[email protected]>
[ Upstream commit 9f87eb4246994e32a4e4ea88476b20ab3b412840 ]
We've met the problem that when there is a vlan tag inside GRE encapsulation, the match of num_of_vlans fails. It is caused by the vlan tag inside GRE payload has been counted into num_of_vlans, which is not expected.
One example packet is like this:
Ethernet II, Src: Broadcom_68:56:07 (00:10:18:68:56:07)
Dst: Broadcom_68:56:08 (00:10:18:68:56:08)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 100
Internet Protocol Version 4, Src: 192.168.1.4, Dst: 192.168.1.200 Generic Routing Encapsulation (Transparent Ethernet bridging) Ethernet II, Src: Broadcom_68:58:07 (00:10:18:68:58:07)
Dst: Broadcom_68:58:08 (00:10:18:68:58:08)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 200
...
It should match the (num_of_vlans 1) rule, but it matches the (num_of_vlans 2) rule.
The vlan tags inside the GRE or other tunnel encapsulated payload should not be taken into num_of_vlans.
The fix is to stop counting the vlan number when the encapsulation bit is set.
--- net/core/flow_dissector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/flow_dissector.c +2 -2
@@ -1180,8 +1180,8 @@ bool __skb_flow_dissect(const struct net *net, nhoff +=sizeof (*vlan); } -if (dissector_uses_key (flow_dissector, -FLOW_DISSECTOR_KEY_NUM_OF_VLANS )) { +if (dissector_uses_key (flow_dissector,FLOW_DISSECTOR_KEY_NUM_OF_VLANS ) && + !(key_control->flags &FLOW_DIS_ENCAPSULATION )) {struct flow_dissector_key_num_of_vlans *key_nvs; key_nvs = skb_flow_dissector_target(flow_dissector,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/776 net/sched: sch_pie: annotate more data-races in pie_dump_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 6d4106e8df94c0c52cf3ca6a6a0d01567fb3844e ]
My prior patch missed few READ_ONCE()/WRITE_ONCE() annotations.
--- net/sched/sch_pie.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/sched/sch_pie.c +6 -8
@@ -215,16 +215,14 @@ void pie_process_dequeue(struct sk_buff *skb, struct pie_params *params,* packet timestamp. */ if (!params->dq_rate_estimator) { - vars->qdelay = now -pie_get_enqueue_time (skb); +WRITE_ONCE (vars->qdelay, + backlog ? now -pie_get_enqueue_time (skb) :0 );if (vars->dq_tstamp !=DTIME_INVALID ) dtime = now - vars->dq_tstamp; vars->dq_tstamp = now; -if (backlog ==0 ) - vars->qdelay =0 ; -if (dtime ==0 )return ;
@@ -372,7 +370,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,if (qdelay > (PSCHED_NS2TICKS (250 *NSEC_PER_MSEC ))) delta +=MAX_PROB / (100 /2 ); - vars->prob += delta; +WRITE_ONCE (vars->prob, vars->prob + delta);if (delta >0 ) {/* prevent overflow */
@@ -397,7 +395,7 @@ void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,if (qdelay ==0 && qdelay_old ==0 && update_prob)/* Reduce drop probability to 98.4% */ - vars->prob -= vars->prob /64 ; +WRITE_ONCE (vars->prob, vars->prob - vars->prob /64 );WRITE_ONCE (vars->qdelay, qdelay); vars->backlog_old = backlog;
@@ -493,7 +491,7 @@ static int pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) {struct pie_sched_data *q =qdisc_priv (sch);struct tc_pie_xstats st = { - .prob = q->vars.prob <<BITS_PER_BYTE , + .prob =READ_ONCE (q->vars.prob) <<BITS_PER_BYTE , .delay = ((u32 )PSCHED_TICKS2NS (READ_ONCE (q->vars.qdelay))) /NSEC_PER_USEC , .packets_in =READ_ONCE (q->stats.packets_in),
@@ -504,7 +502,7 @@ static int pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) };/* avg_dq_rate is only valid if dq_rate_estimator is enabled */ - st.dq_rate_estimating = q->params.dq_rate_estimator; + st.dq_rate_estimating =READ_ONCE (q->params.dq_rate_estimator);/* unscale and return dq_rate in bytes per sec */ if (st.dq_rate_estimating)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/776 crypto: af_alg - Cap AEAD AD length to 0x80000000
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit e4c06479d7059888adf2f22bc1ebcf053bf691a2 upstream.
In order to prevent arithmetic overflows when checking the TX buffer size, cap the associated data length to 0x80000000.
--- crypto/af_alg.c | 2 ++ 1 file changed, 2 insertions(+)
crypto/af_alg.c +2 -0
@@ -478,6 +478,8 @@ static int af_alg_cmsg_send(struct msghdif (cmsg->cmsg_len <CMSG_LEN (sizeof (u32)))return -EINVAL ; con->aead_assoclen = *(u32 *)CMSG_DATA (cmsg); +if (con->aead_assoclen >=0x80000000u ) +return -EINVAL ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 648/776 i40e: Cleanup PTP pins on probe failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Vollrath <[email protected]>
commit 678b713ece1e853f11e670a84cb887c35e1381b7 upstream.
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling i40e_ptp_free_pins in the error path.
To support this, i40e_ptp_free_pins is added to the header and pin_config is correctly nullified after being freed.
This has been an issue since i40e_ptp_alloc_pins was introduced.
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
@@ -1269,6 +1269,7 @@ void i40e_ptp_restore_hw_time(struct i40void i40e_ptp_init (struct i40e_pf *pf);void i40e_ptp_stop (struct i40e_pf *pf);int i40e_ptp_alloc_pins (struct i40e_pf *pf); +void i40e_ptp_free_pins (struct i40e_pf *pf);int i40e_update_adq_vsi_queues (struct i40e_vsi *vsi,int vsi_offset);int i40e_is_vsi_uplink_mode_veb (struct i40e_vsi *vsi);int i40e_get_partition_bw_setting (struct i40e_pf *pf);
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -16183,6 +16183,7 @@ err_vsis:i40e_clear_interrupt_scheme (pf);kfree (pf->vsi); err_switch_setup: +i40e_ptp_free_pins (pf);i40e_reset_interrupt_capability (pf);del_timer_sync (&pf->service_timer); err_mac_addr:
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2 -1
@@ -955,12 +955,13 @@ int i40e_ptp_get_ts_config(struct i40e_p* * Release memory allocated for PTP pins. **/ -static void i40e_ptp_free_pins (struct i40e_pf *pf) +void i40e_ptp_free_pins (struct i40e_pf *pf) {if (i40e_is_ptp_pin_dev (&pf->hw)) {kfree (pf->ptp_pins);kfree (pf->ptp_caps.pin_config); pf->ptp_pins =NULL ; + pf->ptp_caps.pin_config =NULL ; } }
Greg Kroah-Hartman
maintainerPATCH 649/776 audit: fix incorrect inheritable capability in CAPSET records
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Correia <[email protected]>
commit e4a640475e43f406fdfd56d370b1f34b0cbbc18d upstream.
__audit_log_capset() records the effective capability set into the inheritable field due to a copy-paste error. Every CAPSET audit record therefore reports cap_pi (process inheritable) with the value of cap_effective instead of cap_inheritable.
This silently corrupts audit data used for compliance and forensic
analysis: an attacker who modifies inheritable capabilities to prepare for a privilege-escalating exec would have the change masked in the audit trail.
The bug has been present since the original introduction of CAPSET audit records in 2008.
--- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/auditsc.c +1 -1
@@ -2585,7 +2585,7 @@ void __audit_log_capset(const struct cre context->capset.pid =task_tgid_nr (current); context->capset.cap.effective = new->cap_effective; - context->capset.cap.inheritable = new->cap_effective; + context->capset.cap.inheritable = new->cap_inheritable; context->capset.cap.permitted = new->cap_permitted; context->capset.cap.ambient = new->cap_ambient; context->type =AUDIT_CAPSET ;
Greg Kroah-Hartman
maintainerPATCH 650/776 netfilter: nft_ct: fix missing expect put in obj eval
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Xiasong <[email protected]>
commit 19f94b6fee75b3ef7fbc06f3745b9a771a8a19a4 upstream.
nft_ct_expect_obj_eval() allocates an expectation and may call nf_ct_expect_related(), but never drops its local reference.
Add nf_ct_expect_put(exp) before return to balance allocation.
--- net/netfilter/nft_ct.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nft_ct.c +2 -0
@@ -1299,6 +1299,8 @@ static void nft_ct_expect_obj_eval(strucif (nf_ct_expect_related (exp,0 ) !=0 ) regs->verdict.code =NF_DROP ; + +nf_ct_expect_put (exp); }static const struct nla_policy nft_ct_expect_policy[NFTA_CT_EXPECT_MAX +1 ] = {
Greg Kroah-Hartman
maintainerPATCH 651/776 net: atlantic: preserve PCI wake-from-D3 on shutdown when WOL enabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoran Ilievski <[email protected]>
commit 2c308cf34284420963607d677d576a2b4124d8bd upstream.
The shutdown handler aq_pci_shutdown() unconditionally calls pci_wake_from_d3(pdev, false), clearing the PCI PME_En bit even when wake-on-LAN has been configured. While aq_nic_shutdown() correctly programs the NIC firmware via aq_nic_set_power() to listen for magic packets, the PCI subsystem will not propagate the resulting PME wake event from D3, so the system never wakes after poweroff.
WOL from suspend (S3) is unaffected because aq_suspend_common() does not touch pci_wake_from_d3() and relies on the PM core's wake configuration via device_may_wakeup().
This affects all atlantic-supported NICs (AQC107/108/111/112/113); users have reported that WOL works if the atlantic driver is never loaded, but breaks once it has run its shutdown path.
Pass the configured WOL state to pci_wake_from_d3() instead of a literal false, so the PCI PME_En bit is preserved when the user has armed WOL via ethtool.
--- 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
@@ -374,7 +374,7 @@ static void aq_pci_shutdown(struct pci_dpci_disable_device (pdev);if (system_state ==SYSTEM_POWER_OFF ) { -pci_wake_from_d3 (pdev, false); +pci_wake_from_d3 (pdev, self->aq_hw->aq_nic_cfg->wol);pci_set_power_state (pdev, PCI_D3hot); } }
Greg Kroah-Hartman
maintainerPATCH 652/776 audit: enforce AUDIT_LOCKED for AUDIT_TRIM and AUDIT_MAKE_EQUIV
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Correia <[email protected]>
commit f9e1c1324b4d98d591a6f7568fdebf5cf456dfc2 upstream.
AUDIT_ADD_RULE and AUDIT_DEL_RULE correctly check for AUDIT_LOCKED and return -EPERM, but AUDIT_TRIM and AUDIT_MAKE_EQUIV do not. This allows a process with CAP_AUDIT_CONTROL to modify directory tree watches and equivalence mappings even when the audit configuration has been locked, undermining the purpose of the lock.
Add AUDIT_LOCKED checks to both commands.
--- kernel/audit.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/audit.c +4 -0
@@ -1430,6 +1430,8 @@ static int audit_receive_msg(struct sk_b err =audit_list_rules_send (skb, seq);break ;case AUDIT_TRIM : +if (audit_enabled ==AUDIT_LOCKED ) +return -EPERM ;audit_trim_trees ();audit_log_common_recv_msg (audit_context (), &ab,AUDIT_CONFIG_CHANGE );
@@ -1442,6 +1444,8 @@ static int audit_receive_msg(struct sk_bsize_t msglen = data_len;char *old, *new; +if (audit_enabled ==AUDIT_LOCKED ) +return -EPERM ; err = -EINVAL ;if (msglen <2 *sizeof (u32))break ;
Greg Kroah-Hartman
maintainerPATCH 653/776 KVM: Reject wrapped offset in kvm_reset_dirty_gfn()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Sacks <[email protected]>
commit 577a8d3bae0531f0e5ccfac919cd8192f920a804 upstream.
kvm_reset_dirty_gfn() guards the gfn range with
if (!memslot || (offset + __fls(mask)) >= memslot->npages) return;
but offset is u64 and the addition is unchecked. The check can be silently bypassed by a u64 wrap.
The dirty ring backing those entries is MAP_SHARED at KVM_DIRTY_LOG_PAGE_OFFSET of the vcpu fd, so the VMM can rewrite the slot and offset fields of any entry between when the kernel pushes them and when KVM_RESET_DIRTY_RINGS consumes them. On reset, kvm_dirty_ring_reset() re-reads the values via READ_ONCE() and feeds them straight back into this check; only the flags handshake is treated as the handover, the slot/offset payload is taken on trust.
Crafting two entries
entry[i].offset = 0xffffffffffffffc1 entry[i+1].offset = 0
makes the coalescing loop in kvm_dirty_ring_reset() compute
delta = (s64)(0 - 0xffffffffffffffc1) = 63
which falls in [0, BITS_PER_LONG), so it folds entry[i+1] into the existing mask by setting bit 63. The trailing kvm_reset_dirty_gfn() call then sees offset = 0xffffffffffffffc1 and __fls(mask) = 63; the sum is 0 in u64 and the bounds check passes.
That offset propagates into kvm_arch_mmu_enable_log_dirty_pt_masked() unchanged. On the legacy MMU path -- kvm_memslots_have_rmaps() == true, i.e. shadow paging, any VM that has allocated shadow roots, or a write-tracked slot -- it reaches gfn_to_rmap(), which indexes slot->arch.rmap[0][] with a near-U64_MAX gfn. That is an out-of-bounds load of a kvm_rmap_head, followed by a conditional clear of PT_WRITABLE_MASK in whatever the loaded pointer points at. The path is reachable from any process holding /dev/kvm.
Range-check offset on its own first, so the addition cannot wrap. memslot->npages is bounded well below U64_MAX, so once offset < npages holds, offset + __fls(mask) (with __fls(mask) < BITS_PER_LONG) stays in range.
--- virt/kvm/dirty_ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/dirty_ring.c +2 -1
@@ -58,7 +58,8 @@ static void kvm_reset_dirty_gfn(struct k memslot =id_to_memslot (__kvm_memslots (kvm, as_id), id); -if (!memslot || (offset +__fls (mask)) >= memslot->npages) +if (!memslot || offset >= memslot->npages || + offset +__fls (mask) >= memslot->npages)return ;KVM_MMU_LOCK (kvm);
Greg Kroah-Hartman
maintainerPATCH 654/776 KVM: x86: Fix Xen hypercall tracepoint argument assignment
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Ma <[email protected]>
commit 2b72f1674e427c56e3772c5ccf785fdda2138820 upstream.
TRACE_EVENT(kvm_xen_hypercall) stores a5 in __entry->a4 instead of __entry->a5.
That overwrites the recorded a4 argument and leaves a5 unset in the trace entry. Fix the typo so both arguments are captured correctly.
--- arch/x86/kvm/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/trace.h +1 -1
@@ -133,7 +133,7 @@ TRACE_EVENT(kvm_xen_hypercall, __entry->a2 = a2; __entry->a3 = a3; __entry->a4 = a4; - __entry->a4 = a5; + __entry->a5 = a5; ), TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx a4 0x%lx a5 %lx",
Greg Kroah-Hartman
maintainerPATCH 655/776 drm/i915/dp: Fix VSC dynamic range signaling for RGB formats
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kumar Borah <[email protected]>
commit 1ae15b6c7965d137eef21f2cc7d367b29cb88369 upstream.
For RGB, set dynamic_range to CTA or VESA based on crtc_state->limited_color_range so sinks apply correct quantization. YCbCr remains limited (CTA) range. (DP v1.4, Table 5-1)
v2:
- Added Reported-by and Tested-by tags
v3:
- Add back YCbCr comment(Suraj)
--- drivers/gpu/drm/i915/display/intel_dp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_dp.c +7 -2
@@ -1540,8 +1540,13 @@ static void intel_dp_compute_vsc_colorimdrm_WARN_ON (&dev_priv->drm, vsc->bpc ==6 && vsc->pixelformat !=DP_PIXELFORMAT_RGB ); -/* all YCbCr are always limited range */ - vsc->dynamic_range =DP_DYNAMIC_RANGE_CTA ; +/* All YCbCr formats are always limited range. */ +if (vsc->pixelformat ==DP_PIXELFORMAT_RGB ) + vsc->dynamic_range = crtc_state->limited_color_range ? +DP_DYNAMIC_RANGE_CTA :DP_DYNAMIC_RANGE_VESA ; +else + vsc->dynamic_range =DP_DYNAMIC_RANGE_CTA ; + vsc->content_type =DP_CONTENT_TYPE_NOT_DEFINED ; }
Greg Kroah-Hartman
maintainerPATCH 656/776 ALSA: usb-audio: Bound MIDI endpoint descriptor scans
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit d6854daa67be623860f4e1873fd3d3c275aba4ed upstream.
snd_usbmidi_get_ms_info() validates the internal MIDIStreaming endpoint descriptor size before using baAssocJackID[], but the descriptor walker can still return a class-specific endpoint descriptor whose bLength exceeds the remaining bytes in the endpoint-extra scan.
That leaves later flexible-array reads bounded by bLength, but not by the remaining bytes in the endpoint-extra scan.
Stop walking when bLength is zero or
extends past the remaining endpoint-extra scan.
--- sound/usb/midi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/usb/midi.c +7 -5
@@ -1974,15 +1974,17 @@ static struct usb_ms_endpoint_descriptorwhile (extralen >3 ) {struct usb_ms_endpoint_descriptor *ms_ep = (struct usb_ms_endpoint_descriptor *)extra; +int length = ms_ep->bLength; -if (ms_ep->bLength >3 && +if (!length || length > extralen) +break ; + +if (length >3 && ms_ep->bDescriptorType ==USB_DT_CS_ENDPOINT && ms_ep->bDescriptorSubtype ==UAC_MS_GENERAL )return ms_ep; -if (!extra[0 ]) -break ; - extralen -= extra[0 ]; - extra += extra[0 ]; + extralen -= length; + extra += length; }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 657/776 ceph: fix a buffer leak in __ceph_setxattr()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
commit 5d3cc36b4e77a27ce7b686b7c59c7072bcb3fa8e upstream.
The old_blob in __ceph_setxattr() can store ci->i_xattrs.prealloc_blob value during the retry. However, it is never called the ceph_buffer_put() for the old_blob object. This patch fixes the issue of the buffer leak.
--- fs/ceph/xattr.c | 1 + 1 file changed, 1 insertion(+)
fs/ceph/xattr.c +1 -0
@@ -1233,6 +1233,7 @@ retry: do_sync:spin_unlock (&ci->i_ceph_lock); +ceph_buffer_put (old_blob); do_sync_unlocked:if (lock_snap_rwsem)up_read (&mdsc->snap_rwsem);
Greg Kroah-Hartman
maintainerPATCH 658/776 powerpc/warp: Fix error handling in pika_dtm_thread
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 108d7f951271cbd36ca36efc5e5d106966f5180c upstream.
pika_dtm_thread() acquires client through of_find_i2c_device_by_node() but fails to release it in error handling path. This could result in a reference count leak, preventing proper cleanup and potentially leading to resource exhaustion. Add put_device() to release the reference in the error handling path.
Found by code review.
--- arch/powerpc/platforms/44x/warp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/platforms/44x/warp.c +2 -0
@@ -261,6 +261,8 @@ static int pika_dtm_thread(void __iomemschedule_timeout (HZ ); } +put_device (&client->dev); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 659/776 libceph: Fix potential out-of-bounds access in osdmap_decode()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 35d0ed82d03e5ee77ea4f31f20e29562a7721649 upstream.
When decoding osd_state and osd_weight from an incoming osdmap in osdmap_decode(), both are decoded for each osd, i.e., map->max_osd times. The ceph_decode_need() check only accounts for sizeof(*map->osd_weight) once. This can potentially result in an out-of-bounds memory access if the incoming message is corrupted such that the max_osd value exceeds the actual content of the osdmap message.
This patch fixes the issue by changing the corresponding part in the ceph_decode_need() check to account for map->max_osd*sizeof(*map->osd_weight).
--- net/ceph/osdmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/osdmap.c +1 -1
@@ -1689,7 +1689,7 @@ static int osdmap_decode(void **p, voidceph_decode_need (p, end,3 *sizeof (u32) + map->max_osd*(struct_v >=5 ?sizeof (u32) :sizeof (u8)) + -sizeof (*map->osd_weight), e_inval); + map->max_osd*sizeof (*map->osd_weight), e_inval);if (ceph_decode_32 (p) != map->max_osd) goto e_inval;
Greg Kroah-Hartman
maintainerPATCH 660/776 libceph: Fix potential null-ptr-deref in decode_choose_args()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 28b0a2ab8c82d0bbdeb8013029c67c978ce6e4bf upstream.
A message of type CEPH_MSG_OSD_MAP contains an OSD map that itself contains a CRUSH map. When decoding this CRUSH map in crush_decode(), an array of max_buckets CRUSH buckets is decoded, where some indices may not refer to actual buckets and are therefore set to NULL. The received CRUSH map may optionally contain choose_args that get decoded in decode_choose_args(). When decoding a crush_choose_arg_map, a series of choose_args for different buckets is decoded, with the bucket_index being read from the incoming message. It is only checked that the bucket index does not exceed max_buckets, but not that it doesn't point to an index with a NULL bucket. If a (potentially corrupted) message contains a crush_choose_arg_map including such a bucket_index, a null pointer dereference may occur in the subsequent processing when attempting to access the bucket with the given index.
This patch fixes the issue by extending the affected check. Now, it is only attempted to access the bucket if it is not NULL.
--- net/ceph/osdmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ceph/osdmap.c +2 -1
@@ -374,7 +374,8 @@ static int decode_choose_args(void **p, goto fail;if (arg->ids_size && - arg->ids_size != c->buckets[bucket_index]->size) + (!c->buckets[bucket_index] || + arg->ids_size != c->buckets[bucket_index]->size)) goto e_inval; }
Greg Kroah-Hartman
maintainerPATCH 661/776 libceph: Fix potential out-of-bounds access in crush_decode()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 4c79fc2d598694bda845b46229c9d48b65042970 upstream.
A message of type CEPH_MSG_OSD_MAP containing a crush map with at least one bucket has two fields holding the bucket algorithm. If the values in these two fields differ, an out-of-bounds access can occur. This is the case because the first algorithm field (alg) is used to allocate the correct amount of memory for a bucket of this type, while the second algorithm field inside the bucket (b->alg) is used in the subsequent processing.
This patch fixes the issue by adding a check that compares alg and b->alg and aborts the processing in case they differ. Furthermore, b->alg is set to 0 in this case, because the destruction of the crush map also uses this field to determine the bucket type, which can again result in an out-of-bounds access when trying to free the memory pointed to by the fields of the bucket. To correctly free the memory allocated for the bucket in such a case, the corresponding call to kfree is moved from the algorithm-specific crush_destroy_bucket functions to the generic crush_destroy_bucket().
--- net/ceph/crush/crush.c | 6 +----- net/ceph/osdmap.c | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-)
net/ceph/crush/crush.c +1 -5
@@ -47,7 +47,6 @@ int crush_get_bucket_item_weight(const svoid crush_destroy_bucket_uniform (struct crush_bucket_uniform *b) {kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_list (struct crush_bucket_list *b)
@@ -55,14 +54,12 @@ void crush_destroy_bucket_list(struct crkfree (b->item_weights);kfree (b->sum_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_tree (struct crush_bucket_tree *b) {kfree (b->h.items);kfree (b->node_weights); -kfree (b); }void crush_destroy_bucket_straw (struct crush_bucket_straw *b)
@@ -70,14 +67,12 @@ void crush_destroy_bucket_straw(struct ckfree (b->straws);kfree (b->item_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket_straw2 (struct crush_bucket_straw2 *b) {kfree (b->item_weights);kfree (b->h.items); -kfree (b); }void crush_destroy_bucket (struct crush_bucket *b)
@@ -99,6 +94,7 @@ void crush_destroy_bucket(struct crush_bcrush_destroy_bucket_straw2 ((struct crush_bucket_straw2 *)b);break ; } +kfree (b); }/**
net/ceph/osdmap.c +4 -0
@@ -502,6 +502,10 @@ static struct crush_map *crush_decode(vo b->id =ceph_decode_32 (p); b->type =ceph_decode_16 (p); b->alg =ceph_decode_8 (p); +if (b->alg != alg) { + b->alg =0 ; + goto bad; + } b->hash =ceph_decode_8 (p); b->weight =ceph_decode_32 (p); b->size =ceph_decode_32 (p);
Greg Kroah-Hartman
maintainerPATCH 662/776 libceph: handle rbtree insertion error in decode_choose_args()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit d289478cfc0bcf81c7914200d6abdcb78bd04ded upstream.
A message of type CEPH_MSG_OSD_MAP contains an OSD map that itself contains a CRUSH map. The received CRUSH map may optionally contain choose_args that get decoded in decode_choose_args(). In this function, num_choose_arg_maps is read from the message, and a corresponding number of crush_choose_arg_maps gets decoded afterwards. Each crush_choose_arg_map has a choose_args_index, which serves as the key when inserting it into the choose_args rbtree of the decoded crush_map. If a (potentially corrupted) message contains two crush_choose_arg_maps with the same index, the assertion in insert_choose_arg_map() triggers a kernel BUG when trying to insert the second crush_choose_arg_map.
This patch fixes the issue by switching to the non-asserting rbtree insertion function and rejecting the message if the insertion fails.
[ idryomov: changelog ]
--- net/ceph/osdmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ceph/osdmap.c +4 -1
@@ -379,7 +379,10 @@ static int decode_choose_args(void **p, goto e_inval; } -insert_choose_arg_map (&c->choose_args, arg_map); +if (!__insert_choose_arg_map (&c->choose_args, arg_map)) { + ret = -EEXIST ; + goto fail; + } }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 663/776 iommu/vt-d: Disable DMAR for Intel Q35 IGFX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naval Alcalá <[email protected]>
commit 2cda2e10dc8343ae01eae9e999a876b7e7d37861 upstream.
Intel Q35 integrated graphics (8086:29b2) exhibits broken DMAR behaviour similar to other G4x/GM45 devices for which DMAR is already disabled via quirks.
When DMAR is enabled, the system may hard lock up during boot or early device initialization, requiring a reset.
Add the missing PCI ID to the existing quirk list to disable DMAR for this device.
--- drivers/iommu/intel/iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/intel/iommu.c +3 -0
@@ -5651,6 +5651,9 @@ static void quirk_iommu_igfx(struct pci_ dmar_map_gfx =0 ; } +/* Q35 integrated gfx dmar support is totally busted. */ +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x29b2 , quirk_iommu_igfx); +/* G4x/GM45 integrated gfx dmar support is totally busted. */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x2a40 , quirk_iommu_igfx);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x2e00 , quirk_iommu_igfx);
Greg Kroah-Hartman
maintainerPATCH 664/776 drm/i915: skip __i915_request_skip() for already signaled requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Brzezinka <[email protected]>
commit 4cfe4c0efbdcde742a47813180cc69b132d7598e upstream.
After a GPU reset the HWSP is zeroed, so previously completed requests appear incomplete. If such a request is picked up during reset_rewind() and marked guilty, i915_request_set_error_once() returns early (fence already signaled), leaving fence.error without a fatal error code. The subsequent __i915_request_skip() then hits:
``` GEM_BUG_ON(!fatal_error(rq->fence.error)) ```
Fixes a kernel BUG observed on Sandy Bridge (Gen6) during heartbeat-triggered engine resets.
``` kernel BUG at drivers/gpu/drm/i915/i915_request.c:556! RIP: __i915_request_skip+0x15e/0x1d0 [i915] ... __i915_request_reset+0x212/0xa70 [i915] reset_rewind+0xe4/0x280 [i915] intel_gt_reset+0x30d/0x5b0 [i915] heartbeat+0x516/0x530 [i915] ```
Guard __i915_request_skip() with i915_request_signaled(), if the fence is already signaled, the ring content is committed and there is nothing left to skip.
--- drivers/gpu/drm/i915/gt/intel_reset.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_reset.c +2 -1
@@ -137,7 +137,8 @@ void __i915_request_reset(struct i915_rercu_read_lock ();/* protect the GEM context */ if (guilty) {i915_request_set_error_once (rq, -EIO ); -__i915_request_skip (rq); +if (!i915_request_signaled (rq)) +__i915_request_skip (rq); banned =mark_guilty (rq); }else {i915_request_set_error_once (rq, -EAGAIN );
Greg Kroah-Hartman
maintainerPATCH 665/776 drm/panfrost: Fix wait_bo ioctl leaking positive return from dma_resv_wait_timeout()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gyeyoung Baek <[email protected]>
commit 459d75523b71c0ec254d153d8850d0b7008af396 upstream.
dma_resv_wait_timeout() returns a positive 'remaining jiffies' value on success, 0 on timeout, and -errno on failure.
panfrost_ioctl_wait_bo() returns this 'long' result from an int-typed ioctl handler, so positive values reach userspace as bogus errors. Explicitly set ret to 0 on the success path.
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +2 -0
@@ -319,6 +319,8 @@ panfrost_ioctl_wait_bo(struct drm_device ret =dma_resv_wait_timeout (gem_obj->resv, true, true, timeout);if (!ret) ret = timeout ? -ETIMEDOUT : -EBUSY ; +else if (ret >0 ) + ret =0 ;drm_gem_object_put (gem_obj);
Greg Kroah-Hartman
maintainerPATCH 666/776 drm/gma500/oaktrail_hdmi: fix i2c adapter leak on setup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 950953f774b3f69da6f413e045ef075e1f3da2df upstream.
Make sure to drop the reference taken to the I2C adapter (and its module) when setting up HDMI to allow the adapter to be deregistered.
--- drivers/gpu/drm/gma500/oaktrail_hdmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/gma500/oaktrail_hdmi.c +1 -0
@@ -576,6 +576,7 @@ static int oaktrail_hdmi_get_modes(struc }else { edid = (struct edid *)raw_edid;/* FIXME ? edid = drm_get_edid(connector, i2c_adap); */ +i2c_put_adapter (i2c_adap); }if (edid) {
Greg Kroah-Hartman
maintainerPATCH 667/776 io-wq: check that the predecessor is hashed in io_wq_remove_pending()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Carlini <[email protected]>
io_wq_remove_pending() needs to fix up wq->hash_tail[] if the cancelled work was the tail of its hash bucket. When doing this, it checks whether the preceding entry in acct->work_list has the same hash value, but never checks that the predecessor is hashed at all. io_get_work_hash() is simply atomic_read(&work->flags) >> IO_WQ_HASH_SHIFT, and the hash bits are never set for non-hashed work, so it returns 0. Thus, when a hashed bucket-0 work is cancelled while a non-hashed work is its list predecessor, the check spuriously passes and a pointer to the non-hashed io_kiocb is stored in wq->hash_tail[0].
Because non-hashed work is dequeued via the fast path in io_get_next_work(), which never touches hash_tail[], the stale pointer is never cleared. Therefore, after the non-hashed io_kiocb completes and is freed back to req_cachep, wq->hash_tail[0] is a dangling pointer. The io_wq is per-task (tctx->io_wq) and survives ring open/close, so the dangling pointer persists for the lifetime of the task; the next hashed bucket-0 enqueue dereferences it in io_wq_insert_work() and wq_list_add_after() writes through freed memory.
Add the missing io_wq_is_hashed() check so a non-hashed predecessor never inherits a hash_tail[] slot.
--- io_uring/io-wq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
io_uring/io-wq.c +2 -1
@@ -1014,7 +1014,8 @@ static inline void io_wqe_remove_pendingif (io_wq_is_hashed (work) && work == wqe->hash_tail[hash]) {if (prev) prev_work = container_of(prev, struct io_wq_work, list); -if (prev_work &&io_get_work_hash (prev_work) == hash) +if (prev_work &&io_wq_is_hashed (prev_work) && +io_get_work_hash (prev_work) == hash) wqe->hash_tail[hash] = prev_work;else wqe->hash_tail[hash] =NULL ;
Greg Kroah-Hartman
maintainerPATCH 668/776 net/rds: reset op_nents when zerocopy page pin fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
commit e174929793195e0cd6a4adb0cad731b39f9019b4 upstream.
When iov_iter_get_pages2() fails in rds_message_zcopy_from_user(), the pinned pages are released with put_page(), and rm->data.op_mmp_znotifier is cleared. But we fail to properly clear rm->data.op_nents.
Later when rds_message_purge() is called from rds_sendmsg() the cleanup loop iterates over the incorrectly non zero number of op_nents and frees them again.
Fix this by properly resetting op_nents when it should be in rds_message_zcopy_from_user().
--- net/rds/message.c | 1 + 1 file changed, 1 insertion(+)
net/rds/message.c +1 -0
@@ -409,6 +409,7 @@ static int rds_message_zcopy_from_user(sfor (i =0 ; i < rm->data.op_nents; i++)put_page (sg_page (&rm->data.op_sg[i])); + rm->data.op_nents =0 ; mmp = &rm->data.op_mmp_znotifier->z_mmp;mm_unaccount_pinned_pages (mmp); ret = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 669/776 io_uring: prevent opcode speculation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit 1e988c3fe1264708f4f92109203ac5b1d65de50b ]
sqe->opcode is used for different tables, make sure we santitise it against speculations.
--- io_uring/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/io_uring.c +2 -0
@@ -7366,6 +7366,8 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,return -EINVAL ;if (unlikely (req->opcode >=IORING_OP_LAST ))return -EINVAL ; + req->opcode =array_index_nospec (req->opcode,IORING_OP_LAST ); +if (!io_check_restriction (ctx, req, sqe_flags))return -EACCES ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/776 s390/debug: Reject zero-length input before trimming a newline
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit c366a7b5ed7564e41345c380285bd3f6cb98971b ]
debug_get_user_string() copies the userspace buffer into a newly allocated NUL-terminated buffer and then unconditionally looks at buffer[user_len - 1] to strip a trailing newline.
A zero-length write reaches this helper unchanged, so the newline trim reads before the start of the allocated buffer.
Reject empty writes before accessing the last input byte.
--- arch/s390/kernel/debug.c | 3 +++ 1 file changed, 3 insertions(+)
arch/s390/kernel/debug.c +3 -0
@@ -1268,6 +1268,9 @@ static inline char *debug_get_user_string(const char __user *user_buf, {char *buffer; +if (!user_len) +return ERR_PTR (-EINVAL ); + buffer =kmalloc (user_len +1 ,GFP_KERNEL );if (!buffer)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/776 Revert "x86/vdso: Fix output operand size of RDPID"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 64f14b1ab6f39a704b62bf9b3fa28803cf2b3ebe.
--- arch/x86/include/asm/segment.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/segment.h +4 -4
@@ -242,7 +242,7 @@ static inline unsigned long vdso_encode_cpunode(int cpu, unsigned long node)static inline void vdso_read_cpunode (unsigned *cpu,unsigned *node) { -unsigned long p; +unsigned int p;/* * Load CPU and node number from the GDT. LSL is faster than RDTSCP
@@ -252,10 +252,10 @@ static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)* * If RDPID is available, use it. */ -alternative_io ("lsl %[seg],%k[p]" , -"rdpid %[p]" , +alternative_io ("lsl %[seg],%[p]" , +".byte 0xf3,0x0f,0xc7,0xf8" ,/* RDPID %eax/rax */ X86_FEATURE_RDPID, - [p] "=r" (p), [seg] "r" (__CPUNODE_SEG)); + [p] "=a" (p), [seg] "r" (__CPUNODE_SEG)); if (cpu) *cpu = (p & VDSO_CPUNODE_MASK);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/776 net: dsa: sja1105: fix kasan out-of-bounds warning in sja1105_table_delete_entry()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 5f2b28b79d2d1946ee36ad8b3dc0066f73c90481 ]
There are actually 2 problems:
- deleting the last element doesn't require the memmove of elements [i + 1, end) over it. Actually, element i+1 is out of bounds.
- The memmove itself should move size - i - 1 elements, because the last element is out of bounds.
The out-of-bounds element still remains out of bounds after being accessed, so the problem is only that we touch it, not that it becomes in active use. But I suppose it can lead to issues if the out-of-bounds element is part of an unmapped page.
--- drivers/net/dsa/sja1105/sja1105_static_config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/dsa/sja1105/sja1105_static_config.c +4 -2
@@ -1921,8 +1921,10 @@ int sja1105_table_delete_entry(struct sja1105_table *table, int i)if (i > table->entry_count)return -ERANGE ; -memmove (entries + i * entry_size, entries + (i +1 ) * entry_size, - (table->entry_count - i) * entry_size); +if (i +1 < table->entry_count) { +memmove (entries + i * entry_size, entries + (i +1 ) * entry_size, + (table->entry_count - i -1 ) * entry_size); + } table->entry_count--;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/776 wifi: mac80211: check tdls flag in ieee80211_tdls_oper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit 7d73872d949c488a1d7c308031d6a9d89b5e0a8b ]
When NL80211_TDLS_ENABLE_LINK is called, the code only checks if the station exists but not whether it is actually a TDLS station. This allows the operation to proceed for non-TDLS stations, causing unintended side effects like modifying channel context and HT protection before failing.
Add a check for sta->sta.tdls early in the ENABLE_LINK case, before any side effects occur, to ensure the operation is only allowed for actual TDLS peers.
--- net/mac80211/tdls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tdls.c +1 -1
@@ -1380,7 +1380,7 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,mutex_lock (&local->sta_mtx); sta =sta_info_get (sdata, peer); -if (!sta) { +if (!sta || !sta->sta.tdls) {mutex_unlock (&local->sta_mtx); ret = -ENOLINK ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/776 KVM: x86: Acquire SRCU in KVM_GET_MP_STATE to protect guest memory accesses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit ef01cac401f18647d62720cf773d7bb0541827da upstream.
Acquire a lock on kvm->srcu when userspace is getting MP state to handle a rather extreme edge case where "accepting" APIC events, i.e. processing pending INIT or SIPI, can trigger accesses to guest memory. If the vCPU is in L2 with INIT *and* a TRIPLE_FAULT request pending, then getting MP state will trigger a nested VM-Exit by way of ->check_nested_events(), and emuating the nested VM-Exit can access guest memory.
The splat was originally hit by syzkaller on a Google-internal kernel, and reproduced on an upstream kernel by hacking the triple_fault_event_test selftest to stuff a pending INIT, store an MSR on VM-Exit (to generate a memory access on VMX), and do vcpu_mp_state_get() to trigger the scenario.
=============================
WARNING: suspicious RCU usage 6.14.0-rc3-b112d356288b-vmx/pi_lockdep_false_pos-lock #3 Not tainted
-----------------------------
include/linux/kvm_host.h:1058 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by triple_fault_ev/1256:
#0: ffff88810df5a330 (&vcpu->mutex){+.+.}-{4:4}, at: kvm_vcpu_ioctl+0x8b/0x9a0 [kvm]
stack backtrace: CPU: 11 UID: 1000 PID: 1256 Comm: triple_fault_ev Not tainted 6.14.0-rc3-b112d356288b-vmx #3 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 Call Trace: <TASK> dump_stack_lvl+0x7f/0x90 lockdep_rcu_suspicious+0x144/0x190 kvm_vcpu_gfn_to_memslot+0x156/0x180 [kvm] kvm_vcpu_read_guest+0x3e/0x90 [kvm] read_and_check_msr_entry+0x2e/0x180 [kvm_intel] __nested_vmx_vmexit+0x550/0xde0 [kvm_intel] kvm_check_nested_events+0x1b/0x30 [kvm] kvm_apic_accept_events+0x33/0x100 [kvm] kvm_arch_vcpu_ioctl_get_mpstate+0x30/0x1d0 [kvm] kvm_vcpu_ioctl+0x33e/0x9a0 [kvm] __x64_sys_ioctl+0x8b/0xb0 do_syscall_64+0x6c/0x170 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK>
Message-ID: <[email protected]>
[ Based on kernel 5.15 available functions, using srcu_read_lock/srcu_read_unlock instead of kvm_vcpu_srcu_read_lock/kvm_vcpu_srcu_read_unlock ]
--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -10617,6 +10617,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,if (kvm_mpx_supported ())kvm_load_guest_fpu (vcpu); + vcpu->srcu_idx =srcu_read_lock (&vcpu->kvm->srcu); + r =kvm_apic_accept_events (vcpu);if (r <0 ) goto out;
@@ -10630,6 +10632,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, mp_state->mp_state = vcpu->arch.mp_state; out: +srcu_read_unlock (&vcpu->kvm->srcu, vcpu->srcu_idx); +if (kvm_mpx_supported ())kvm_put_guest_fpu (vcpu);vcpu_put (vcpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/776 Revert "s390/cio: Fix device lifecycle handling in css_alloc_subchannel()"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit b1d4e6fb241672850296956c4d782a69363a3807.
--- drivers/s390/cio/css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/css.c +1 -1
@@ -247,7 +247,7 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid, err_lock:kfree (sch->lock); err: -put_device (&sch->dev); +kfree (sch);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/776 smb: client: reject userspace cifs.spnego descriptions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Asim Viladi Oglu Manizada <[email protected]>
commit 3da1fdf4efbc490041eb4f836bf596201203f8f2 upstream.
cifs.spnego key descriptions contain authority-bearing fields such as pid, uid, creduid, and upcall_target that cifs.upcall treats as kernel-originating inputs. However, userspace can also create keys of this type through request_key(2) or add_key(2), allowing those fields to be supplied without CIFS origin.
Only accept cifs.spnego descriptions while CIFS is using its private spnego_cred to request the key.
[Salvatore Bonaccorso: Apply changes to fs/cifs/cifs_spnego.c instead of fs/smb/client/cifs_spnego.c before 38c8a9a52082 ("smb: move client and server files to common directory fs/smb") in v6.4-rc1 and backported to v6.1.36]
--- fs/cifs/cifs_spnego.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/cifs/cifs_spnego.c +16 -0
@@ -8,6 +8,7 @@*/ #include <linux/list.h> +#include <linux/cred.h> #include <linux/slab.h> #include <linux/string.h> #include <keys/user-type.h>
@@ -46,12 +47,27 @@ cifs_spnego_key_destroy(struct key *key)kfree (key->payload.data[0 ]); } +static int +cifs_spnego_key_vet_description (const char *description) +{ +/* +* cifs.spnego descriptions are authority-bearing inputs to cifs.upcall. +* They are only valid when produced by CIFS while using the private +* spnego_cred installed below. Do not let userspace create this type +* of key through request_key(2)/add_key(2), since the helper treats +* pid/uid/creduid/upcall_target as kernel-originating fields. +*/ +if (current_cred () != spnego_cred) +return -EPERM ; +return 0 ; +}/* * keytype for CIFS spnego keys */ struct key_type cifs_spnego_key_type = { .name ="cifs.spnego" , + .vet_description = cifs_spnego_key_vet_description, .instantiate = cifs_spnego_key_instantiate, .destroy = cifs_spnego_key_destroy, .describe = user_describe,
Greg Kroah-Hartman
maintainerPATCH 677/776 i3c: mipi-i3c-hci: Correct RING_CTRL_ABORT handling in DMA dequeue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit b795e68bf3073d67bebbb5a44d93f49efc5b8cc7 ]
The logic used to abort the DMA ring contains several flaws:
1. The driver unconditionally issues a ring abort even when the ring has already stopped.
2. The completion used to wait for abort completion is never re-initialized, resulting in incorrect wait behavior.
3. The abort sequence unintentionally clears RING_CTRL_ENABLE, which resets hardware ring pointers and disrupts the controller state.
4. If the ring is already stopped, the abort operation should be considered successful without attempting further action.
Fix the abort handling by checking whether the ring is running before issuing an abort, re-initializing the completion when needed, ensuring that RING_CTRL_ENABLE remains asserted during abort, and treating an already stopped ring as a successful condition.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +17 -10
@@ -448,16 +448,23 @@ static bool hci_dma_dequeue_xfer(struct i3c_hci *hci,struct hci_rh_data *rh = &rings->headers[xfer_list[0 ].ring_number];unsigned int i;bool did_unqueue = false; - -/* stop the ring */ -rh_reg_write (RING_CONTROL ,RING_CTRL_ABORT ); -if (wait_for_completion_timeout (&rh->op_done,HZ ) ==0 ) { -/* -* We're deep in it if ever this condition is ever met. -* Hardware might still be writing to memory, etc. -*/ -dev_crit (&hci->master.dev,"unable to abort the ring\n" ); -WARN_ON (1 ); +u32 ring_status; + + ring_status =rh_reg_read (RING_STATUS ); +if (ring_status &RING_STATUS_RUNNING ) { +/* stop the ring */ +reinit_completion (&rh->op_done); +rh_reg_write (RING_CONTROL ,RING_CTRL_ENABLE |RING_CTRL_ABORT ); +wait_for_completion_timeout (&rh->op_done,HZ ); + ring_status =rh_reg_read (RING_STATUS ); +if (ring_status &RING_STATUS_RUNNING ) { +/* +* We're deep in it if ever this condition is ever met. +* Hardware might still be writing to memory, etc. +*/ +dev_crit (&hci->master.dev,"unable to abort the ring\n" ); +WARN_ON (1 ); + } }for (i =0 ; i < n; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/776 sysfs: dont remove existing directory on update failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 237557b8a81ab948e8332f7c0058e758f081c0a3 upstream.
When sysfs_update_group() is called for a named group and create_files() fails (e.g. -ENOMEM), internal_create_group() calls kernfs_remove(kn) on the group directory. In the update path, kn was obtained via kernfs_find_and_get() and refers to a directory that already existed before this call. Removing it silently destroys a sysfs group that the caller did not create.
Only remove the directory if we created it ourselves. On update failure the directory remains as it is left empty by remove_files() inside create_files(), but can be repopulated by a retry.
--- fs/sysfs/group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/sysfs/group.c +1 -1
@@ -148,7 +148,7 @@ static int internal_create_group(structkernfs_get (kn); error =create_files (kn, kobj, uid, gid, grp, update);if (error) { -if (grp->name) +if (grp->name && !update)kernfs_remove (kn); }kernfs_put (kn);
Greg Kroah-Hartman
maintainerPATCH 679/776 hwmon: (pmbus/adm1266) widen blackbox-info buffer to I2C_SMBUS_BLOCK_MAX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit eee213daa1e1b402eb631bcd1b8c5aa340a6b081 upstream.
adm1266_nvmem_read_blackbox() declares a 5-byte stack buffer and passes it to i2c_smbus_read_block_data() to retrieve the 4-byte BLACKBOX_INFO response. i2c_smbus_read_block_data() does not honour caller buffer sizes -- it memcpy()s data.block[0] bytes from the SMBus transaction (where data.block[0] is the length byte returned by the slave device, up to I2C_SMBUS_BLOCK_MAX = 32):
memcpy(values, &data.block[1], data.block[0]);
If the device returns any block length above 5, the call overflows the caller's 5-byte stack buffer before the post-call
if (ret != 4) return -EIO;
check has a chance to reject the response.
Widen the local buffer to I2C_SMBUS_BLOCK_MAX so the helper has room for any well-formed SMBus block response, matching the convention used by the other i2c_smbus_read_block_data() callers in this driver.
--- drivers/hwmon/pmbus/adm1266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1266.c +1 -1
@@ -351,7 +351,7 @@ static int adm1266_nvmem_read_blackbox(s {int record_count;char index; -u8 buf[5 ]; +u8 buf[I2C_SMBUS_BLOCK_MAX ];int ret; ret =i2c_smbus_read_block_data (data->client,ADM1266_BLACKBOX_INFO , buf);
Greg Kroah-Hartman
maintainerPATCH 680/776 ALSA: ua101: Reject too-short USB descriptors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit b59d5c51bb328a60749b4dd5fe7e649bfb4089b4 upstream.
find_format_descriptor() walks the class-specific interface extras by advancing with bLength. It rejects descriptors that extend past the remaining buffer, but it does not reject descriptor lengths smaller than a USB descriptor header.
Reject too-short descriptors before using bLength to advance the local scan. This keeps the UA-101 parser robust against malformed descriptor data and matches the usual USB descriptor walking rules.
--- sound/usb/misc/ua101.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/usb/misc/ua101.c +3 -2
@@ -914,8 +914,9 @@ find_format_descriptor(struct usb_interfstruct uac_format_type_i_discrete_descriptor *desc; desc = (struct uac_format_type_i_discrete_descriptor *)extra; -if (desc->bLength > extralen) { -dev_err (&interface->dev,"descriptor overflow\n" ); +if (desc->bLength <sizeof (struct usb_descriptor_header ) || + desc->bLength > extralen) { +dev_err (&interface->dev,"invalid descriptor length\n" );return NULL ; } if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) &&
Greg Kroah-Hartman
maintainerPATCH 681/776 ALSA: asihpi: Fix potential OOB array access at reading cache
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7b7d6572145c1dab2dd9bfb550b188e5f0ff3c3f upstream.
find_control() to retrieve a cached info accesses the array with the given index blindly, which may lead to an OOB array access. Add a sanity check for avoiding it.
--- sound/pci/asihpi/hpicmn.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/pci/asihpi/hpicmn.c +6 -0
@@ -276,6 +276,12 @@ static short find_control(u16 control_inreturn 0 ; } +if (control_index >= p_cache->control_count) { +HPI_DEBUG_LOG (VERBOSE ,"control_index out of bounce %d\n" , + control_index); +return 0 ; + } + *pI = p_cache->p_info[control_index];if (!*pI) { HPI_DEBUG_LOG(VERBOSE, "Uncached Control %d\n",
Greg Kroah-Hartman
maintainerPATCH 682/776 net: wwan: iosm: fix potential memory leaks in ipc_imem_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit c5d93b2c40355e999715262a824965aac025a427 upstream.
The memory allocated in ipc_protocol_init() is not freed on the error paths that follow in ipc_imem_init(). Fix that by calling the corresponding release function ipc_protocol_deinit() in the error path.
--- drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wwan/iosm/iosm_ipc_imem.c +2 -0
@@ -1338,6 +1338,8 @@ imem_config_fail: protocol_init_fail:cancel_work_sync (&ipc_imem->run_state_worker);ipc_task_deinit (ipc_imem->ipc_task); +if (ipc_imem->ipc_protocol) +ipc_protocol_deinit (ipc_imem->ipc_protocol); ipc_task_init_fail:kfree (ipc_imem->ipc_task); ipc_task_fail:
Greg Kroah-Hartman
maintainerPATCH 683/776 Bluetooth: bnep: Fix UAF read of dev->name
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 59e932ded949fa6f0340bf7c6d7818f962fa4fd2 upstream.
bnep_add_connection() needs to keep holding the bnep_session_sem while reading dev->name (just like bnep_get_connlist() does); otherwise the bnep_session() thread can concurrently free the net_device, which can for example be triggered by a concurrent bnep_del_connection().
(This UAF is fairly uninteresting from a security perspective; calling bnep_add_connection() requires passing a capable(CAP_NET_ADMIN) check. It also requires completely tearing down a netdev during a fairly tight race window.)
--- net/bluetooth/bnep/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/bnep/core.c +1 -1
@@ -638,8 +638,8 @@ int bnep_add_connection(struct bnep_conn goto failed; } -up_write (&bnep_session_sem);strcpy (req->device, dev->name); +up_write (&bnep_session_sem);return 0 ; failed:
Greg Kroah-Hartman
maintainerPATCH 684/776 Bluetooth: hci_uart: fix UAFs and race conditions in close and init paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingyu Wang <[email protected]>
commit c1bb9336ae6b54a5f6a353c4bd4ed9a4307e429b upstream.
Vulnerabilities leading to Use-After-Free (UAF) and Null Pointer Dereference (NPD) conditions were observed in the lifecycle management of hci_uart.
The primary issue arises because the workqueues (init_ready and write_work) are only flushed/cancelled if the HCI_UART_PROTO_READY flag is set during TTY close. If a hangup occurs before setup completes, hci_uart_tty_close() skips the teardown of these workqueues and proceeds to free the hu struct. When the scheduled work executes later, it blindly dereferences the freed hu struct.
Furthermore, several data races and UAFs were identified in the teardown sequence:
1. Calling hci_uart_flush() from hci_uart_close() without effectively disabling write_work causes a race condition where both can concurrently double-free hu->tx_skb. This happens because protocol timers can concurrently invoke hci_uart_tx_wakeup() and requeue write_work.
2. Calling hci_free_dev(hdev) before hu->proto->close(hu) causes a UAF when vendor specific protocol close callbacks dereference hu->hdev.
3. In the initialization error paths, failing to take the proto_lock write lock before clearing PROTO_READY leads to races with active readers. Additionally, hci_uart_tty_receive() accesses hu->hdev outside the read lock, leading to UAFs if the initialization error path frees hdev concurrently.
Fix these synchronization and lifecycle issues by:
1. Re-ordering hci_uart_tty_close() to clear HCI_UART_PROTO_READY first, followed immediately by a cancel_work_sync(&hu->write_work). Clearing the flag locks out concurrent protocol timers from successfully invoking hci_uart_tx_wakeup(), effectively rendering the cancellation permanent and preventing the tx_skb double-free.
2. Note: Clearing PROTO_READY early causes hci_uart_close() to skip hu->proto->flush(). This is perfectly safe in the tty_close path because hu->proto->close() executes shortly after, which intrinsically purges all protocol SKB queues and tears down the state.
3. Relocating hu->proto->close(hu) strictly prior to hci_free_dev(hdev) across all close and error paths to prevent vendor-level UAFs.
4. Moving the hdev->stat.byte_rx increment in hci_uart_tty_receive() inside the proto_lock read-side critical section to safely synchronize with device unregistration.
5. Adding cancel_work_sync(&hu->write_work) to hci_uart_close() to safely flush the workqueue before hci_uart_flush() is invoked via the HCI core.
6. Utilizing cancel_work_sync() instead of disable_work_sync() across all paths to prevent permanently breaking user-space retry capabilities.
--- drivers/bluetooth/hci_ldisc.c | 48 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-)
drivers/bluetooth/hci_ldisc.c +40 -8
@@ -194,7 +194,15 @@ void hci_uart_init_work(struct work_stru err =hci_register_dev (hu->hdev);if (err <0 ) {BT_ERR ("Can't register HCI device" ); + +percpu_down_write (&hu->proto_lock);clear_bit (HCI_UART_PROTO_READY , &hu->flags); +percpu_up_write (&hu->proto_lock); + +/* Safely cancel work after clearing flags */ +cancel_work_sync (&hu->write_work); + +/* Close protocol before freeing hdev */ hu->proto->close (hu); hdev = hu->hdev; hu->hdev =NULL ;
@@ -263,8 +271,12 @@ static int hci_uart_open(struct hci_dev/* Close device */ static int hci_uart_close (struct hci_dev *hdev) { +struct hci_uart *hu =hci_get_drvdata (hdev); +BT_DBG ("hdev %p" , hdev); +cancel_work_sync (&hu->write_work); +hci_uart_flush (hdev); hdev->flush =NULL ;return 0 ;
@@ -525,6 +537,7 @@ static void hci_uart_tty_close(struct tt {struct hci_uart *hu = tty->disc_data;struct hci_dev *hdev; +bool proto_ready;BT_DBG ("tty %p" , tty);
@@ -534,24 +547,38 @@ static void hci_uart_tty_close(struct ttif (!hu)return ; - hdev = hu->hdev; -if (hdev) -hci_uart_close (hdev); +/* Wait for init_ready to finish to prevent registration races */ +cancel_work_sync (&hu->init_ready); -if (test_bit (HCI_UART_PROTO_READY , &hu->flags)) { + proto_ready =test_bit (HCI_UART_PROTO_READY , &hu->flags); +if (proto_ready) {percpu_down_write (&hu->proto_lock);clear_bit (HCI_UART_PROTO_READY , &hu->flags);percpu_up_write (&hu->proto_lock); + } -cancel_work_sync (&hu->init_ready); -cancel_work_sync (&hu->write_work); +/* +* Unconditionally cancel write_work AFTER clearing PROTO_READY. +* This ensures that concurrent protocol timers cannot requeue +* write_work via hci_uart_tx_wakeup(), permanently preventing +* double-free races and UAFs. +*/ +cancel_work_sync (&hu->write_work); + + hdev = hu->hdev; +if (hdev) +hci_uart_close (hdev);/* proto->flush is safely skipped */ +if (proto_ready) {if (hdev) {if (test_bit (HCI_UART_REGISTERED , &hu->flags))hci_unregister_dev (hdev); -hci_free_dev (hdev); } +/* Close protocol before freeing hdev (intrinsically purges queues) */ hu->proto->close (hu); + +if (hdev) +hci_free_dev (hdev); }clear_bit (HCI_UART_PROTO_SET , &hu->flags);
@@ -619,11 +646,12 @@ static void hci_uart_tty_receive(struct* tty caller */ hu->proto->recv (hu, data, count); -percpu_up_read (&hu->proto_lock);if (hu->hdev) hu->hdev->stat.byte_rx += count; +percpu_up_read (&hu->proto_lock); +tty_unthrottle (tty); }
@@ -694,6 +722,10 @@ static int hci_uart_register_dev(structpercpu_down_write (&hu->proto_lock);clear_bit (HCI_UART_PROTO_INIT , &hu->flags);percpu_up_write (&hu->proto_lock); +/* Cancel work after clearing flags */ +cancel_work_sync (&hu->write_work); + +/* Close protocol before freeing hdev */ hu->proto->close (hu); hu->hdev =NULL ;hci_free_dev (hdev);
Greg Kroah-Hartman
maintainerPATCH 685/776 phonet/pep: disable BH around forwarded sk_receive_skb()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijing Yin <[email protected]>
commit dbc81608e3a653dea6cf403f20cae35468b8ab9c upstream.
The networking receive path is usually run from softirq context, but protocols that take the socket lock may have packets stored in the backlog and processed later from process context. In that case release_sock() -> __release_sock() drops the slock with spin_unlock_bh() and then calls sk->sk_backlog_rcv() with bottom halves enabled.
Typical sk_backlog_rcv handlers process the socket whose backlog is being drained, so the BH state at entry is irrelevant for the slocks they touch. pep_do_rcv() is different: when the inbound skb targets an existing PEP pipe, it forwards the skb to a different *child* socket via sk_receive_skb(). That helper takes the child slock with bh_lock_sock_nested(), which is just spin_lock_nested() and assumes BH is already off. The same child slock therefore ends up acquired with BH on (process path) and with BH off (softirq path):
process context softirq context
--------------- ---------------
release_sock(listener) __netif_receive_skb()
__release_sock() phonet_rcv()
spin_unlock_bh() __sk_receive_skb(listener)
[BH now ENABLED] [BH already disabled]
sk_backlog_rcv: sk_backlog_rcv: pep_do_rcv() pep_do_rcv()
sk_receive_skb(child) sk_receive_skb(child)
bh_lock_sock_nested(child) bh_lock_sock_nested(child)
=> SOFTIRQ-ON-W => IN-SOFTIRQ-W
Lockdep flags this as inconsistent lock state, and it can become a real self-deadlock if a softirq on the same CPU tries to receive to the same child socket while its slock is held in the BH-enabled path:
WARNING: inconsistent lock state
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
(slock-AF_PHONET/1){+.?.}-{3:3}, at: __sk_receive_skb+0x1cf/0x900
__sk_receive_skb net/core/sock.c:563
sk_receive_skb include/net/sock.h:2022 [inline]
pep_do_rcv net/phonet/pep.c:675
sk_backlog_rcv include/net/sock.h:1190
__release_sock net/core/sock.c:3216
release_sock net/core/sock.c:3815
pep_sock_accept net/phonet/pep.c:879Wrap the forwarded sk_receive_skb() in local_bh_disable() / local_bh_enable() so the child slock is always acquired with BH off. local_bh_disable() nests safely on the softirq path.
Discovered via in-house syzkaller fuzzing; the same root cause also on the linux-6.1.y syzbot dashboard as extid 44f0626dd6284f02663c. Reproduced under KASAN + LOCKDEP + PROVE_LOCKING, reproducer:
https://pastebin.com/A3t8xzCR
--- net/phonet/pep.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
net/phonet/pep.c +17 -2
@@ -671,8 +671,23 @@ static int pep_do_rcv(struct sock *sk, s/* Look for an existing pipe handle */ sknode =pep_find_pipe (&pn->hlist, &dst, pipe_handle); -if (sknode) -return sk_receive_skb (sknode, skb,1 ); +if (sknode) { +int rc; + +/* pep_do_rcv() runs from two contexts: from softirq via +* phonet_rcv() -> __sk_receive_skb() with BH disabled, +* and from process context via +* release_sock() -> __release_sock(), which drops +* the listener slock with spin_unlock_bh() before draining +* the backlog. The child pipe slock is taken below via +* bh_lock_sock_nested(), which does not itself disable BH, so +* disable BH here to keep both acquire contexts consistent. +*/ +local_bh_disable (); + rc =sk_receive_skb (sknode, skb,1 ); +local_bh_enable (); +return rc; + }switch (hdr->message_id) {case PNS_PEP_CONNECT_REQ :
Greg Kroah-Hartman
maintainerPATCH 686/776 net: bcmgenet: keep RBUF EEE/PM disabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
commit 9a1730245e416d11ad5c0f2c100061d61cc43f60 upstream.
Setting RBUF_EEE_EN | RBUF_PM_EN in RBUF_ENERGY_CTRL breaks the RX path on GENET hardware once MAC EEE becomes active. RX traffic stops flowing while the link stays up and the usual descriptor/RX error counters remain quiet. In that state the MAC still accepts frames (rbuf_ovflow_cnt keeps climbing) but RBUF no longer forwards them to DMA, so rx_packets is no longer incremented at the netdev level. On some boards the corruption ends up as a paging fault in skb_release_data via bcmgenet_rx_poll on an LPI exit.
Reproduced on Pi 4B (BCM2711 + BCM54213PE) and confirmed by Florian Fainelli on an internal Broadcom 4908-family board with the same crash signature. RBUF_PM_EN is not publicly documented.
This shows up more often now that phy_support_eee() enables EEE by default, but it also affects older kernels as soon as TX LPI is turned on via ethtool, so it is not specific to recent changes.
Always clear RBUF_EEE_EN | RBUF_PM_EN in bcmgenet_eee_enable_set so the bits stay off across resets. UMAC and TBUF setup is left alone so TX-side EEE keeps working.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -5
@@ -1275,13 +1275,12 @@ void bcmgenet_eee_enable_set(struct net_ reg &= ~(TBUF_EEE_EN |TBUF_PM_EN );bcmgenet_writel (reg, priv->base + off); -/* Do the same for thing for RBUF */ +/* RBUF EEE/PM can break the RX path on GENET. Keep it disabled. */ reg =bcmgenet_rbuf_readl (priv,RBUF_ENERGY_CTRL ); -if (enable) - reg |=RBUF_EEE_EN |RBUF_PM_EN ; -else +if (reg & (RBUF_EEE_EN |RBUF_PM_EN )) { reg &= ~(RBUF_EEE_EN |RBUF_PM_EN ); -bcmgenet_rbuf_writel (priv, reg,RBUF_ENERGY_CTRL ); +bcmgenet_rbuf_writel (priv, reg,RBUF_ENERGY_CTRL ); + }if (!enable && priv->clk_eee_enabled) {clk_disable_unprepare (priv->clk_eee);
Greg Kroah-Hartman
maintainerPATCH 687/776 netfilter: ip6t_hbh: reject oversized option lists
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
commit 4322dcde6b4173c2d8e8e6118ed290794263bcc8 upstream.
struct ip6t_opts stores at most IP6T_OPTS_OPTSNR option descriptors, but hbh_mt6_check() does not reject larger optsnr values supplied from userspace.
Validate optsnr in the rule setup path so only match data that fits the fixed-size opts array can be installed. This follows the existing xtables pattern of rejecting invalid user-provided counts in checkentry() and keeps the packet matching path unchanged.
struct ip6t_opts has a fixed opts[IP6T_OPTS_OPTSNR] array, where IP6T_OPTS_OPTSNR is 16, then off-by-one array access is possible:
[ 137.924693][ T8692] UBSAN: array-index-out-of-bounds in ../net/ipv6/netfilter/ip6t_hbh.c:110:29 [ 137.926167][ T8692] index 16 is out of range for type '__u16 [16]'
--- net/ipv6/netfilter/ip6t_hbh.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/netfilter/ip6t_hbh.c +4 -0
@@ -168,6 +168,10 @@ static int hbh_mt6_check(const struct xtpr_debug ("unknown flags %X\n" , optsinfo->invflags);return -EINVAL ; } +if (optsinfo->optsnr >IP6T_OPTS_OPTSNR ) { +pr_debug ("too many supported opts specified\n" ); +return -EINVAL ; + }if (optsinfo->flags &IP6T_OPTS_NSTRICT ) {pr_debug ("Not strict - not implemented" );
Greg Kroah-Hartman
maintainerPATCH 688/776 netfilter: nf_queue: hold bridge skb->dev while queued
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoze Xie <[email protected]>
commit e196115ec330a18de415bdb9f5071aa9f08e53ce upstream.
br_pass_frame_up() rewrites skb->dev from the ingress port to the bridge master before queueing bridge LOCAL_IN packets. NFQUEUE only holds references on state.in/out and bridge physdevs, so a queued bridge packet can retain a freed bridge master in skb->dev until reinjection.
When the verdict is reinjected later, br_netif_receive_skb() re-enters the receive path with skb->dev still pointing at the freed bridge master, triggering a use-after-free.
Store skb->dev in the queue entry, hold a reference on it for the queue lifetime, and use the saved device when dropping queued packets during NETDEV_DOWN handling.
--- include/net/netfilter/nf_queue.h | 1 + net/netfilter/nf_queue.c | 4 +++- net/netfilter/nfnetlink_queue.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-)
include/net/netfilter/nf_queue.h +1 -0
@@ -12,6 +12,7 @@struct nf_queue_entry {struct list_head list;struct sk_buff *skb; +struct net_device *skb_dev;unsigned int id;unsigned int hook_index;/* index in hook_entries->hook[] */ #if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )
net/netfilter/nf_queue.c +3 -1
@@ -60,6 +60,7 @@ static void nf_queue_entry_release_refs(struct nf_hook_state *state = &entry->state;/* Release those devices we held, or Alexey will kill me. */ +dev_put (entry->skb_dev);dev_put (state->in);dev_put (state->out);if (state->sk)
@@ -103,6 +104,7 @@ bool nf_queue_entry_get_refs(struct nf_qif (state->sk && !refcount_inc_not_zero (&state->sk->sk_refcnt))return false; +dev_hold (entry->skb_dev);dev_hold (state->in);dev_hold (state->out);
@@ -203,11 +205,11 @@ static int __nf_queue(struct sk_buff *sk *entry = (struct nf_queue_entry ) { .skb = skb, + .skb_dev = skb->dev, .state = *state, .hook_index = index, .size =sizeof (*entry) + route_key_size, }; -__nf_queue_entry_init_physdevs (entry);if (!nf_queue_entry_get_refs (entry)) {
net/netfilter/nfnetlink_queue.c +2 -0
@@ -944,6 +944,8 @@ dev_cmp(struct nf_queue_entry *entry, unif (physinif == ifindex || physoutif == ifindex)return 1 ;#endif +if (entry->skb_dev && entry->skb_dev->ifindex == ifindex) +return 1 ;if (entry->state.in)if (entry->state.in->ifindex == ifindex)return 1 ;
Greg Kroah-Hartman
maintainerPATCH 689/776 netfilter: ipset: stop hash:* range iteration at end
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nan Li <[email protected]>
commit 0d3a282ab5f165fc207ff49ea5b6ad8f54616bd6 upstream.
The following hash set variants:
hash:ip,mark
hash:ip,port
hash:ip,port,ip
hash:ip,port,net
iterate IPv4 ranges with a 32-bit iterator.
The iterator must stop once the last address in the requested range has been processed. Advancing it once more can move the traversal state past the end of the request, so a later retry may continue from an unintended position.
Handle the iterator increment explicitly at the end of the loop and stop once the upper bound has been processed. This keeps the existing retry behaviour intact for valid ranges while preventing traversal from continuing past the original boundary.
--- net/netfilter/ipset/ip_set_hash_ipmark.c | 6 +++++- net/netfilter/ipset/ip_set_hash_ipport.c | 5 ++++- net/netfilter/ipset/ip_set_hash_ipportip.c | 5 ++++- net/netfilter/ipset/ip_set_hash_ipportnet.c | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-)
net/netfilter/ipset/ip_set_hash_ipmark.c +5 -1
@@ -150,7 +150,7 @@ hash_ipmark4_uadt(struct ip_set *set, stif (retried) ip =ntohl (h->next.ip); -for (; ip <= ip_to; ip++, i++) { +for (; ip <= ip_to; i++) { e.ip =htonl (ip);if (i >IPSET_MAX_RANGE ) {hash_ipmark4_data_next (&h->next, &e);
@@ -162,6 +162,10 @@ hash_ipmark4_uadt(struct ip_set *set, streturn ret; ret =0 ; + +if (ip == ip_to) +break ; + ip++; }return ret; }
net/netfilter/ipset/ip_set_hash_ipport.c +4 -1
@@ -175,7 +175,7 @@ hash_ipport4_uadt(struct ip_set *set, stif (retried) ip =ntohl (h->next.ip); -for (; ip <= ip_to; ip++) { +for (; ip <= ip_to;) { p = retried && ip ==ntohl (h->next.ip) ?ntohs (h->next.port) : port;for (; p <= port_to; p++, i++) {
@@ -192,6 +192,9 @@ hash_ipport4_uadt(struct ip_set *set, st ret =0 ; } +if (ip == ip_to) +break ; + ip++; }return ret; }
net/netfilter/ipset/ip_set_hash_ipportip.c +4 -1
@@ -182,7 +182,7 @@ hash_ipportip4_uadt(struct ip_set *set,if (retried) ip =ntohl (h->next.ip); -for (; ip <= ip_to; ip++) { +for (; ip <= ip_to;) { p = retried && ip ==ntohl (h->next.ip) ?ntohs (h->next.port) : port;for (; p <= port_to; p++, i++) {
@@ -199,6 +199,9 @@ hash_ipportip4_uadt(struct ip_set *set, ret =0 ; } +if (ip == ip_to) +break ; + ip++; }return ret; }
net/netfilter/ipset/ip_set_hash_ipportnet.c +4 -1
@@ -274,7 +274,7 @@ hash_ipportnet4_uadt(struct ip_set *set, p = port; ip2 = ip2_from; } -for (; ip <= ip_to; ip++) { +for (; ip <= ip_to;) { e.ip =htonl (ip);for (; p <= port_to; p++) { e.port =htons (p);
@@ -298,6 +298,9 @@ hash_ipportnet4_uadt(struct ip_set *set, ip2 = ip2_from; } p = port; +if (ip == ip_to) +break ; + ip++; }return ret; }
Greg Kroah-Hartman
maintainerPATCH 690/776 ring-buffer: Fix reporting of missed events in iterator
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit a254b6d13b0edd6272926674d2afc46d46e496b7 upstream.
When tracing is active while reading the trace file, if the iterator reading the buffer detects that the writer has passed the iterator head, it will reset and set a "missed events" flag. This flag is passed to the output processing to show the user that events were missed:
CPU:4 [LOST EVENTS]
The problem is that the flag is reset after it is checked in ring_buffer_iter_dropped(). But the "trace" file iterates over all the CPU ring buffers and it will check if they are dropped when figuring out which buffer to print next. This prematurely clears the missed_events flag if the CPU buffer with the missed events is not the one that is printed next.
On the iteration where the CPU buffer with the missed events is printed, the check if it had missed events would return false and the output does not show that events were missed.
Do not reset the missed_events flag when checking if there were missed events, but instead clear it when moving the iterator head to the next event.
--- kernel/trace/ring_buffer.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/trace/ring_buffer.c +3 -5
@@ -4346,6 +4346,7 @@ static void rb_iter_reset(struct ring_bu iter->head_page = cpu_buffer->reader_page; iter->head = cpu_buffer->reader_page->read; iter->next_event = iter->head; + iter->missed_events =0 ; iter->cache_reader_page = iter->head_page; iter->cache_read = cpu_buffer->read;
@@ -4955,10 +4956,7 @@ ring_buffer_peek(struct trace_buffer *bu*/ bool ring_buffer_iter_dropped (struct ring_buffer_iter *iter) { -bool ret = iter->missed_events !=0 ; - - iter->missed_events =0 ; -return ret; +return iter->missed_events !=0 ; }EXPORT_SYMBOL_GPL (ring_buffer_iter_dropped);
@@ -5175,7 +5173,7 @@ void ring_buffer_iter_advance(struct rinunsigned long flags;raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); - + iter->missed_events =0 ;rb_advance_iter (iter);raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 691/776 vsock/vmci: fix UAF when peer resets connection during handshake
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minh Nguyen <[email protected]>
commit 99e22ddf4edb63dc8382bc028af928056d3450cf upstream.
vmci_transport_recv_connecting_server() returned err = 0 for a peer RST in its default switch arm:
err = pkt->type == VMCI_TRANSPORT_PACKET_TYPE_RST ? 0 : -EINVAL;
That made vmci_transport_recv_listen() skip vsock_remove_pending(), leaving the pending socket on the listener's pending_links with sk_state = TCP_CLOSE while destroy: still dropped the explicit reference taken before schedule_delayed_work().
One second later vsock_pending_work() observed is_pending=true and performed full cleanup: vsock_remove_pending() then the two trailing sock_put(sk) calls -- the first reached refcount 0 and __sk_freed the socket, and the second wrote into the freed object:
BUG: KASAN: slab-use-after-free in refcount_warn_saturate Write of size 4 at addr ffff88800b1cac80 by task kworker Workqueue: events vsock_pending_work
Treat peer RST like any other unexpected packet type (err = -EINVAL). All destroy: arms now return err < 0, so vmci_transport_recv_listen() removes pending from pending_links synchronously and vsock_pending_work() takes the is_pending=false / !rejected branch, dropping only its own work reference. This also closes the multi-packet race Sashiko reported on v2: pending is removed from the list before any subsequent packet can find it.
The pre-existing sk_acceptq_removed() gap on the err < 0 path of vmci_transport_recv_listen() that Sashiko also noted is not introduced or changed by this patch.
Tested on lts-6.12.79 with KASAN: 52/100 unpatched -> 0/100 patched.
--- net/vmw_vsock/vmci_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/vmw_vsock/vmci_transport.c +1 -1
@@ -1156,7 +1156,7 @@ vmci_transport_recv_connecting_server(st/* Close and cleanup the connection. */ vmci_transport_send_reset (pending, pkt); skerr =EPROTO ; - err = pkt->type ==VMCI_TRANSPORT_PACKET_TYPE_RST ?0 : -EINVAL ; + err = -EINVAL ; goto destroy; }
Greg Kroah-Hartman
maintainerPATCH 692/776 wifi: ath11k: clear shared SRNG pointer state on restart
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Farnung <[email protected]>
commit f51e4b3b5574ad8cb5b16b11f8a1452147ece87a upstream.
LMAC rings reuse the shared rdp/wrp pointer buffers without going through the normal SRNG hw-init path that zeros non-LMAC ring pointers. After restart, ath11k_hal_srng_clear() can therefore hand stale hp/tp state from the previous firmware instance back to the new one.
Clear the shared pointer buffers while keeping the allocations in place so restart still avoids reallocating SRNG DMA memory, but starts with fresh ring-pointer state.
--- drivers/net/wireless/ath/ath11k/hal.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/hal.c +11 -3
@@ -1315,14 +1315,22 @@ EXPORT_SYMBOL(ath11k_hal_srng_deinit);void ath11k_hal_srng_clear (struct ath11k_base *ab) { -/* No need to memset rdp and wrp memory since each individual -* segment would get cleared in ath11k_hal_srng_src_hw_init() -* and ath11k_hal_srng_dst_hw_init(). +/* +* Preserve the shared pointer buffers, but clear the previous +* firmware instance's hp/tp state before handing them back to FW. +* LMAC rings reuse this shared memory without going through the +* normal SRNG hw-init path that zeros non-LMAC ring pointers. */ memset (ab->hal.srng_list,0 ,sizeof (ab->hal.srng_list));memset (ab->hal.shadow_reg_addr,0 ,sizeof (ab->hal.shadow_reg_addr)); +if (ab->hal.rdp.vaddr) +memset (ab->hal.rdp.vaddr,0 , +sizeof (*ab->hal.rdp.vaddr) *HAL_SRNG_RING_ID_MAX ); +if (ab->hal.wrp.vaddr) +memset (ab->hal.wrp.vaddr,0 , +sizeof (*ab->hal.wrp.vaddr) *HAL_SRNG_NUM_LMAC_RINGS ); ab->hal.avail_blk_resource =0 ; ab->hal.current_blk_index =0 ; ab->hal.num_shadow_reg_configured =0 ;
Greg Kroah-Hartman
maintainerPATCH 693/776 ipv4: raw: reject IP_HDRINCL packets with ihl < 5
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 915fab69823a14c170dbaa3b41978768e0fe62fc upstream.
raw_send_hdrinc() validates that the caller-supplied IPv4 header fits within the message length:
iphlen = iph->ihl * 4;
err = -EINVAL;
if (iphlen > length)
goto error_free;
if (iphlen >= sizeof(*iph)) {
/* fix up saddr, tot_len, id, csum, transport_header */
}It does not, however, reject ihl < 5. For such a packet the "if (iphlen >= sizeof(*iph))" branch is skipped, leaving the crafted iphdr untouched, but the packet is still handed to __ip_local_out() and onward. Downstream consumers that read iph->ihl assume a sane value: net/ipv4/ah4.c:ah_output() in particular subtracts sizeof(struct iphdr) from top_iph->ihl * 4 and passes the (signed-int-negative, then cast to size_t) result to memcpy(), producing an OOB access of length close to SIZE_MAX and a host kernel panic.
An IPv4 header with ihl < 5 is malformed by definition (RFC 791:
"Internet Header Length is the length of the internet header in 32 bit words ... Note that the minimum value for a correct header is 5."). The kernel should not be willing to inject such a packet into its own output path.
Reject "iphlen < sizeof(*iph)" alongside the existing "iphlen > length" check. This matches the principle that locally constructed packets that re-enter the IP stack must pass the same basic sanity tests that a foreign packet would be subjected to.
Once this lands, the "if (iphlen >= sizeof(*iph))" wrapper around the fixup branch becomes redundant; left in place to keep the patch minimal and backport-friendly. A follow-up can unwrap it.
Note that commit 86f4c90a1c5c ("ipv4, ipv6: ensure raw socket message is big enough to hold an IP header") ensures the message buffer is large enough to hold an iphdr, but does not constrain the self-reported iph->ihl.
Reachability: the malformed packet source is any caller with CAP_NET_RAW, including an unprivileged process in a user+net namespace on a kernel with CONFIG_USER_NS=y. The reproduced AH crash also requires a matching xfrm AH policy on the outgoing route; a container granted CAP_NET_ADMIN can install that state and policy in its netns. Loopback bypasses xfrm_output, so the trigger uses a real netdev.
Reproduced on UML + KASAN: kernel-mode fault at addr 0x0 with memcpy_orig at the crash site. Same shape reproduces inside a rootless Docker container with --cap-add NET_ADMIN on a stock distro kernel.
--- net/ipv4/raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/raw.c +1 -1
@@ -407,7 +407,7 @@ static int raw_send_hdrinc(struct sock ** in, reject the frame as invalid */ err = -EINVAL ; -if (iphlen > length) +if (iphlen > length || iphlen <sizeof (*iph)) goto error_free;if (iphlen >=sizeof (*iph)) {
Greg Kroah-Hartman
maintainerPATCH 694/776 ixgbevf: fix use-after-free in VEPA multicast source pruning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 5d49b568c188dc77199d8d2b959c91da8cc27cf1 upstream.
ixgbevf_clean_rx_irq() prunes frames whose source MAC matches the VF's own address (VEPA multicast workaround) by freeing the skb and continuing to the next descriptor:
dev_kfree_skb_irq(skb);
continue;The skb pointer is declared outside the while loop and persists across iterations. Because the continue skips the "skb = NULL" reset at the bottom of the loop, the next iteration enters the "else if (skb)" path and calls ixgbevf_add_rx_frag() on the freed skb, dereferencing skb_shinfo(skb)->nr_frags - a use-after-free in NAPI softirq context.
The sibling driver iavf already handles this correctly by nulling the pointer before continuing. Apply the same pattern here.
I do not have ixgbevf hardware; the bug was found by static analysis (scan_drop_continue_loops.py + semgrep drop_continue_in_loop, multi-tool corroboration with the highest score in the scan). The UAF was confirmed under KASAN by loading a test module that reproduces the exact code pattern (alloc skb, kfree_skb, then read skb_shinfo(skb)->nr_frags):
BUG: KASAN: slab-use-after-free in ixgbevf_uaf_test_init+0x100/0x1000 Read of size 8 at addr 000000006163ae78 by task insmod/30 freed 208-byte region [000000006163adc0, 000000006163ae90)
QEMU emulates igb (82576) but not ixgbe (82599), and the igbvf VF driver does not include the VEPA source pruning path, so a full end-to-end reproduction with emulated hardware was not possible.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +1 -0
@@ -1220,6 +1220,7 @@ static int ixgbevf_clean_rx_irq(struct i ether_addr_equal(rx_ring->netdev->dev_addr, eth_hdr(skb)->h_source)) {dev_kfree_skb_irq (skb); + skb =NULL ;continue ; }
Greg Kroah-Hartman
maintainerPATCH 695/776 wifi: cfg80211: advance loop vars in cfg80211_merge_profile()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Walker <[email protected]>
commit 7666dbb1bacc4ba522b96740cba7283d243d16e1 upstream.
cfg80211_merge_profile() reassembles a Multi-BSSID non-transmitted BSS profile that has been split across multiple consecutive MBSSID elements. Its while-loop calls
cfg80211_get_profile_continuation(ie, ielen, mbssid_elem, sub_elem)
but never advances mbssid_elem or sub_elem inside the body. Each iteration therefore searches for a continuation that follows the same fixed pair; the helper returns the same next_mbssid; and the same next_sub bytes are memcpy()'d into merged_ie at a growing offset until the buffer fills.
Advance both mbssid_elem and sub_elem to the just-consumed continuation so the next call to cfg80211_get_profile_continuation() searches for a further continuation beyond it (or returns NULL when none exists).
A specially-crafted malicious beacon can take advantage of this bug to cause the kernel to spend an excessive amount of time in cfg80211_merge_profile (up to as much as 2ms per beacon received), which could theoretically be abused in some way.
--- net/wireless/scan.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/scan.c +3 -0
@@ -2180,6 +2180,9 @@ size_t cfg80211_merge_profile(const u8 *memcpy (merged_ie + copied_len, next_sub->data, next_sub->datalen); copied_len += next_sub->datalen; + + mbssid_elem = next_mbssid; + sub_elem = next_sub; }return copied_len;
Greg Kroah-Hartman
maintainerPATCH 696/776 tracing: Do not call map->ops->elt_free() if elt_alloc() fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
commit 8f0f5c4fb9df0e19a341e0c6ed8dc4fda9124f03 upstream.
In paths where tracing_map_elt_alloc() failed to allocate objects, the map->ops->elt_alloc() call was never successful. In this case, map->ops->elt_free() should not be called.
--- kernel/trace/tracing_map.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
kernel/trace/tracing_map.c +13 -4
@@ -386,13 +386,11 @@ static void tracing_map_elt_init_fields( } } -static void tracing_map_elt_free (struct tracing_map_elt *elt) +static void __tracing_map_elt_free (struct tracing_map_elt *elt) {if (!elt)return ; -if (elt->map->ops && elt->map->ops->elt_free) - elt->map->ops->elt_free (elt);kfree (elt->fields);kfree (elt->vars);kfree (elt->var_set);
@@ -400,6 +398,17 @@ static void tracing_map_elt_free(structkfree (elt); } +static void tracing_map_elt_free (struct tracing_map_elt *elt) +{ +if (!elt) +return ; + +/* Only objects initialized with alloc_elt() should be passed to free_elt().*/ +if (elt->map->ops && elt->map->ops->elt_free) + elt->map->ops->elt_free (elt); +__tracing_map_elt_free (elt); +} +static struct tracing_map_elt *tracing_map_elt_alloc (struct tracing_map *map) {struct tracing_map_elt *elt;
@@ -444,7 +453,7 @@ static struct tracing_map_elt *tracing_m }return elt; free: -tracing_map_elt_free (elt); +__tracing_map_elt_free (elt);return ERR_PTR (err); }
Greg Kroah-Hartman
maintainerPATCH 697/776 scsi: isci: Fix use-after-free in device removal path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit b52a8d52c3125ec9a93106ed816582368de34426 upstream.
The ISCI completion tasklet is initialized in isci_host_alloc() (drivers/scsi/isci/init.c:496) and scheduled from both MSI-X and legacy interrupt handlers (drivers/scsi/isci/host.c:223,613).
isci_host_deinit() stops the controller and waits for stop completion, but it never kills completion_tasklet before teardown continues. A top-of-function tasklet_kill() is not sufficient here: interrupts are only disabled when isci_host_stop_complete() runs, so until wait_for_stop() returns the IRQ handlers can still requeue the tasklet. The tasklet callback also re-enables interrupts after draining completions, so killing the tasklet before the source is quiesced leaves the same race open.
Once wait_for_stop() returns, no further IRQ-driven scheduling can occur. Kill completion_tasklet there so teardown cannot race a queued tasklet running on a dead ihost. On remove or unload, the stale callback can otherwise dereference ihost and touch ihost->smu_registers after the host lifetime ends.
A UML + KASAN analogue reproduced the failure class both with no tasklet_kill() and with tasklet_kill() placed before source quiesce, and stayed clean once the kill happened after quiescing the scheduling source.
This mirrors commit f6ab594672d4 ("scsi: aic94xx: fix use-after-free in device removal path"), but ISCI needs the kill after wait_for_stop().
--- drivers/scsi/isci/host.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/isci/host.c +3 -0
@@ -1252,6 +1252,9 @@ void isci_host_deinit(struct isci_host *wait_for_stop (ihost); +/* No further IRQ-driven scheduling can happen past wait_for_stop(). */ +tasklet_kill (&ihost->completion_tasklet); +/* phy stop is after controller stop to allow port and device to * go idle before shutting down the phys, but the expectation is * that i/o has been shut off well before we reach this
Greg Kroah-Hartman
maintainerPATCH 698/776 spi: sprd: fix error pointer deref after DMA setup failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3d67fffb74267772d461c02c67f1eff893ad547d upstream.
The driver falls back to PIO mode if DMA setup fails during probe.
Make sure to check the dma.enabled flag before trying to release the DMA channels also on late probe errors to avoid dereferencing an error pointer (or attempting to release a channel a second time).
This issue was flagged by Sashiko when reviewing a devres allocation conversion patch.
--- drivers/spi/spi-sprd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-sprd.c +2 -1
@@ -995,7 +995,8 @@ err_rpm_put: disable_clk:clk_disable_unprepare (ss->clk); release_dma: -sprd_spi_dma_release (ss); +if (ss->dma.enable) +sprd_spi_dma_release (ss); free_controller:spi_controller_put (sctlr);
Greg Kroah-Hartman
maintainerPATCH 699/776 spi: ti-qspi: fix use-after-free after DMA setup failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ea6ec3343e05f7937a53eb6d7617b3abdb4abc19 upstream.
The driver falls back to PIO mode if DMA setup fails during probe.
Make sure to clear the DMA channel pointer also if buffer allocation fails to avoid passing a pointer to the released channel to the DMA engine (or trying to free the channel a second time on late probe errors or driver unbind).
This issue was flagged by Sashiko when reviewing a devres allocation conversion patch.
--- drivers/spi/spi-ti-qspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-ti-qspi.c +1 -0
@@ -873,6 +873,7 @@ static int ti_qspi_probe(struct platformdev_err (qspi->dev,"dma_alloc_coherent failed, using PIO mode\n" );dma_release_channel (qspi->rx_chan); + qspi->rx_chan =NULL ; goto no_dma; } master->dma_rx = qspi->rx_chan;
Greg Kroah-Hartman
maintainerPATCH 700/776 RDMA/siw: Reject MPA FPDU length underflow before signed receive math
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 0ce1bc9e46ecabe84772bb561e373c0d9876d6f2 upstream.
A malicious connected siw peer can send an iWARP FPDU whose MPA length field (c_hdr->mpa_len, 16 bit big-endian, peer-controlled) is smaller than the fixed DDP/RDMAP header for the announced opcode. Soft-iWARP parses the full header in siw_get_hdr() based on iwarp_pktinfo[opcode] .hdr_len, but never compares mpa_len against that header length.
siw_tcp_rx_data() then derives
srx->fpdu_part_rem = be16_to_cpu(mpa_len) - fpdu_part_rcvd
+ MPA_HDR_SIZE;
where fpdu_part_rcvd equals iwarp_pktinfo[opcode].hdr_len at this point. For a tagged WRITE (hdr_len 16, MPA_HDR_SIZE 2) the smallest on-wire mpa_len of 0 yields fpdu_part_rem = -14, and any mpa_len below hdr_len - MPA_HDR_SIZE underflows to a negative int.
The signed value then flows into siw_proc_write()/siw_proc_rresp() as
bytes = min(srx->fpdu_part_rem, srx->skb_new);
is handed to siw_check_mem() as an int len (whose interval check addr + len > mem->va + mem->len is satisfied for a valid base when len is negative), and reaches siw_rx_data() -> siw_rx_kva() / siw_rx_umem() -> skb_copy_bits() as a signed copy length. The header copy branch in skb_copy_bits() promotes that to size_t, producing a multi-gigabyte read.
KASAN under a KUnit harness that drives the real kernel TCP receive path -- a loopback AF_INET socketpair, the malformed FPDU written via kernel_sendmsg, sk_data_ready firing in softirq, tcp_read_sock dispatching to siw_tcp_rx_data -- reports:
BUG: KASAN: use-after-free in skb_copy_bits+0x284/0x480
Read of size 4294967295 at addr ffff888...
Call Trace:
skb_copy_bits
siw_rx_kva
siw_rx_data
siw_check_mem
siw_proc_write
siw_tcp_rx_data
__tcp_read_sock
siw_qp_llp_data_ready
tcp_data_ready
tcp_data_queueAdd the missing invariant at the earliest point where the peer header is fully assembled. iwarp_pktinfo[*].hdr_len - MPA_HDR_SIZE is exactly the value the siw transmitter uses as the minimum mpa_len for each opcode (drivers/infiniband/sw/siw/siw_qp.c:33), so this matches the protocol contract. Out-of-range FPDUs terminate the connection with TERM_ERROR_LAYER_LLP / LLP_ETYPE_MPA / LLP_ECODE_FPDU_START -- which is RFC 5044 Section 8 error code 3 ("Marker and ULPDU Length fields do not agree on the start of an FPDU"), the correct framing-error class for this inconsistency.
--- drivers/infiniband/sw/siw/siw_qp_rx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/infiniband/sw/siw/siw_qp_rx.c +15 -0
@@ -1102,6 +1102,21 @@ static int siw_get_hdr(struct siw_rx_str }/* +* Peer-controlled mpa_len must not underflow srx->fpdu_part_rem +* in siw_tcp_rx_data(); a negative value flows as a signed copy +* length into siw_check_mem() and skb_copy_bits(). +*/ +if (unlikely (be16_to_cpu (c_hdr->mpa_len) +MPA_HDR_SIZE < + iwarp_pktinfo[opcode].hdr_len)) { +pr_warn_ratelimited ("siw: short mpa_len %u for opcode %u (hdr_len %u)\n" , +be16_to_cpu (c_hdr->mpa_len), opcode, + iwarp_pktinfo[opcode].hdr_len); +siw_init_terminate (rx_qp (srx),TERM_ERROR_LAYER_LLP , +LLP_ETYPE_MPA ,LLP_ECODE_FPDU_START ,0 ); +return -EINVAL ; + } + +/* * DDP/RDMAP header receive completed. Check if the current * DDP segment starts a new RDMAP message or continues a previously * started RDMAP message.
Greg Kroah-Hartman
maintainerPATCH 701/776 device property: set fwnode->secondary to NULL in fwnode_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit 215c90ee656114f5e8c32408228d97082f8e0eef upstream.
If a firmware node is allocated on the stack (for instance: temporary software node whose life-time we control) or on the heap - but using a non-zeroing allocation function - and initialized using fwnode_init(), its secondary pointer will contain uninitalized memory which likely will be neither NULL nor IS_ERR() and so may end up being dereferenced (for
example: in dev_to_swnode()). Set fwnode->secondary to NULL on initialization.
--- include/linux/fwnode.h | 1 + 1 file changed, 1 insertion(+)
include/linux/fwnode.h +1 -0
@@ -172,6 +172,7 @@ struct fwnode_operations {static inline void fwnode_init (struct fwnode_handle *fwnode,const struct fwnode_operations *ops) { + fwnode->secondary =NULL ; fwnode->ops = ops;INIT_LIST_HEAD (&fwnode->consumers);INIT_LIST_HEAD (&fwnode->suppliers);
Greg Kroah-Hartman
maintainerPATCH 702/776 drm/bridge: it66121: acquire reset GPIO in probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julien Chauveau <[email protected]>
commit e02b5262fd288cc235f14e12233ea54e78c04611 upstream.
The it66121_ctx structure has a gpio_reset field, and it66121_hw_reset() calls gpiod_set_value() on it. However, the GPIO descriptor is never acquired via devm_gpiod_get(), leaving gpio_reset as NULL throughout the driver lifetime.
gpiod_set_value() silently returns when passed a NULL descriptor, so the hardware reset sequence in it66121_hw_reset() is a no-op. This leaves the chip in an undefined state at probe time, which can prevent it from responding on the I2C bus.
The DT binding marks reset-gpios as a required property, so all compliant device trees provide this GPIO. Add the missing devm_gpiod_get() call after enabling power supplies and before the hardware reset, so the chip is properly reset with power applied.
--- drivers/gpu/drm/bridge/ite-it66121.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/bridge/ite-it66121.c +5 -0
@@ -955,6 +955,11 @@ static int it66121_probe(struct i2c_clieif (ret)return ret; + ctx->gpio_reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_LOW ); +if (IS_ERR (ctx->gpio_reset)) +return dev_err_probe (dev,PTR_ERR (ctx->gpio_reset), +"Failed to get reset GPIO\n" ); +it66121_hw_reset (ctx); ctx->regmap =devm_regmap_init_i2c (client, &it66121_regmap_config);
Greg Kroah-Hartman
maintainerPATCH 703/776 drm/bridge: megachips: remove bridge when irq request fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Osama Abdelkader <[email protected]>
commit d45d5c819f2cd0b6b5d76a194a537a5f4aeefecb upstream.
If devm_request_threaded_irq() fails after drm_bridge_add(), remove the bridge before returning.
Keep drm_bridge_add() rather than devm_drm_bridge_add(): registration is tied to the STDP4028 device while ge_b850v3_register() may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.
--- drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 16 +++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +10 -6
@@ -302,7 +302,6 @@ static void ge_b850v3_lvds_remove(void) goto out;drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); - ge_b850v3_lvds_ptr =NULL ; out:mutex_unlock (&ge_b850v3_lvds_dev_mutex);
@@ -312,6 +311,7 @@ static int ge_b850v3_register(void) {struct i2c_client *stdp4028_i2c = ge_b850v3_lvds_ptr->stdp4028_i2c;struct device *dev = &stdp4028_i2c->dev; +int ret;/* drm bridge initialization */ ge_b850v3_lvds_ptr->bridge.funcs = &ge_b850v3_lvds_funcs;
@@ -329,11 +329,15 @@ static int ge_b850v3_register(void)if (!stdp4028_i2c->irq)return 0 ; -return devm_request_threaded_irq (&stdp4028_i2c->dev, - stdp4028_i2c->irq,NULL , - ge_b850v3_lvds_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , -"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); + ret =devm_request_threaded_irq (&stdp4028_i2c->dev, + stdp4028_i2c->irq,NULL , + ge_b850v3_lvds_irq_handler, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); +if (ret) +drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); + +return ret; } static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c,
Greg Kroah-Hartman
maintainerPATCH 704/776 drm/amd/display: Fix integer overflow in bios_get_image()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit cd86529ec61474a38c3837fb7823790a7c3f8cce upstream.
[Why&How]
The bounds check in bios_get_image() computes 'offset + size' using unsigned 32-bit arithmetic before comparing against bios_size. If a VBIOS image contains a near-UINT32_MAX offset the addition wraps to a small value, the comparison passes, and the function returns a wild pointer past the VBIOS mapping.
Additionally, the comparison uses '<' (strict), which incorrectly rejects the valid exact-fit case where offset + size == bios_size.
Fix both issues by restructuring the check to avoid the addition
entirely: first reject if offset alone exceeds bios_size, then check size against the remaining space (bios_size - offset). This eliminates the overflow and correctly permits exact-fit accesses.
--- drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser_helper.c +6 -3
@@ -37,10 +37,13 @@ uint8_t *bios_get_image(struct dc_bios * uint32_t offset, uint32_t size) { -if (bp->bios && offset + size < bp->bios_size) -return bp->bios + offset; -else +if (!bp->bios)return NULL ; + +if (offset > bp->bios_size || size > bp->bios_size - offset) +return NULL ; + +return bp->bios + offset; }#include "reg_helper.h"
Greg Kroah-Hartman
maintainerPATCH 705/776 drm/amd/display: Validate payload length and link_index in dc_process_dmub_aux_transfer_async
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 6c92f6d9600efa3ef0d9e560a2b52776d9803c29 upstream.
[Why&How]dc_process_dmub_aux_transfer_async() copies payload->length bytes into a 16-byte stack buffer (dpaux.data[16]) guarded only by an ASSERT(), which is a no-op in release builds. If a caller ever passes length > 16 this results in a stack buffer overflow via memcpy.
Additionally, link_index is used to dereference dc->links[] without bounds checking against dc->link_count, risking an out-of-bounds access.
Replace the ASSERT with a hard runtime check that returns false when payload->length exceeds the destination buffer size, and add a bounds check for link_index before it is used.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +5 -1
@@ -3755,7 +3755,11 @@ bool dc_process_dmub_aux_transfer_async(union dmub_rb_cmd cmd = {0 };struct dc_dmub_srv *dmub_srv = dc->ctx->dmub_srv; -ASSERT (payload->length <=16 ); +if (link_index >= dc->link_count || !dc->links[link_index]) +return false; + +if (payload->length >sizeof (cmd.dp_aux_access.aux_control.dpaux.data)) +return false; cmd.dp_aux_access.header.type =DMUB_CMD__DP_AUX_ACCESS ; cmd.dp_aux_access.header.payload_bytes =0 ;
Greg Kroah-Hartman
maintainerPATCH 706/776 batman-adv: mcast: fix use-after-free in orig_node RCU release
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 20c2d6a20ca936f5aaa6dd40f73f262ac45c87cc upstream.
batadv_mcast_purge_orig() removes entries from RCU-protected hlists but does not wait for an RCU grace period before returning. Concurrent RCU readers may still accesses references to those entries at the point of removal. RCU-protected readers trying to operate on entries like orig->mcast_want_all_ipv6_node will then access already freed memory.
Fix this by moving batadv_mcast_purge_orig() to batadv_orig_node_release(), just before the call_rcu() invocation. This ensures RCU readers that were active at purge time have drained before the orig_node memory is reclaimed.
--- net/batman-adv/originator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/originator.c +2 -2
@@ -823,8 +823,6 @@ static void batadv_orig_node_free_rcu(st orig_node = container_of(rcu, struct batadv_orig_node, rcu); -batadv_mcast_purge_orig (orig_node); -batadv_frag_purge_orig (orig_node,NULL );kfree (orig_node->tt_buff);
@@ -878,6 +876,8 @@ void batadv_orig_node_release(struct kre/* Free nc_nodes */ batadv_nc_purge_orig (orig_node->bat_priv, orig_node,NULL ); +batadv_mcast_purge_orig (orig_node); +call_rcu (&orig_node->rcu, batadv_orig_node_free_rcu); }
Greg Kroah-Hartman
maintainerPATCH 707/776 batman-adv: clear current gateway during teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruijie Li <[email protected]>
commit a340a51ed801eab7bb454150c226323b865263cc upstream.
batadv_gw_node_free() removes the gateway list entries during mesh teardown, but it does not clear the currently selected gateway. This leaves stale gateway state behind across cleanup and can break a later mesh recreation.
Clear bat_priv->gw.curr_gw before walking the gateway list so the selected gateway reference is dropped as part of teardown.
--- net/batman-adv/gateway_client.c | 4 ++++ 1 file changed, 4 insertions(+)
net/batman-adv/gateway_client.c +4 -0
@@ -478,10 +478,14 @@ void batadv_gw_node_delete(struct batadv*/ void batadv_gw_node_free (struct batadv_priv *bat_priv) { +struct batadv_gw_node *curr_gw;struct batadv_gw_node *gw_node;struct hlist_node *node_tmp;spin_lock_bh (&bat_priv->gw.list_lock); + curr_gw =rcu_replace_pointer (bat_priv->gw.curr_gw,NULL , true); +batadv_gw_node_put (curr_gw); +hlist_for_each_entry_safe (gw_node, node_tmp, &bat_priv->gw.gateway_list, list) {hlist_del_init_rcu (&gw_node->list);
Greg Kroah-Hartman
maintainerPATCH 708/776 batman-adv: dat: handle forward allocation error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 2d8826a2d3657cea66fb0370f9e521575a673871 upstream.
batadv_dat_forward_data() calls pskb_copy_for_clone() to duplicate an skb for each DHT candidate, but does not check the return value before passing it to batadv_send_skb_prepare_unicast_4addr(). That function dereferences the skb unconditionally, so a failed allocation triggers a NULL pointer dereference.
Skip forwarding to the current DHT candidate on allocation failure.
--- net/batman-adv/distributed-arp-table.c | 3 +++ 1 file changed, 3 insertions(+)
net/batman-adv/distributed-arp-table.c +3 -0
@@ -698,6 +698,9 @@ static bool batadv_dat_forward_data(stru goto free_orig; tmp_skb =pskb_copy_for_clone (skb,GFP_ATOMIC ); +if (!tmp_skb) + goto free_neigh; +if (!batadv_send_skb_prepare_unicast_4addr (bat_priv, tmp_skb, cand[i].orig_node, packet_subtype)) {
Greg Kroah-Hartman
maintainerPATCH 709/776 batman-adv: fix fragment reassembly length accounting
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
commit 9cd3f16c320bfdadd4509358122368deb56a5741 upstream.
batman-adv keeps a running payload length for queued fragments and uses it to validate a fragment chain before reassembly.
That accounting currently allows the accumulated fragment length to be truncated during updates. As a result, malformed fragment chains can bypass the intended validation and drive reassembly with inconsistent length state, leading to a local denial of service.
Fix the accounting by storing the accumulated length in a length-typed field and rejecting update overflows before the existing validation logic runs.
The fix was verified against the original reproducer and against valid fragment reassembly paths.
--- net/batman-adv/fragmentation.c | 23 +++++++++++++++++------ net/batman-adv/types.h | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-)
net/batman-adv/fragmentation.c +17 -6
@@ -17,6 +17,7 @@#include <linux/lockdep.h> #include <linux/minmax.h> #include <linux/netdevice.h> +#include <linux/overflow.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -81,9 +82,9 @@ void batadv_frag_purge_orig(struct batad* * Return: the maximum size of payload that can be fragmented. */ -static int batadv_frag_size_limit (void ) +static size_t batadv_frag_size_limit (void ) { -int limit =BATADV_FRAG_MAX_FRAG_SIZE ; +size_t limit =BATADV_FRAG_MAX_FRAG_SIZE ; limit -=sizeof (struct batadv_frag_packet ); limit *=BATADV_FRAG_MAX_FRAGMENTS ;
@@ -144,7 +145,9 @@ static bool batadv_frag_insert_packet(ststruct batadv_frag_packet *frag_packet;u8 bucket;u16 seqno, hdr_size =sizeof (struct batadv_frag_packet ); +bool overflow = false;bool ret = false; +size_t data_len;/* Linearize packet to avoid linearizing 16 packets in a row when doing * the later merge. Non-linear merge should be added to remove this
@@ -154,6 +157,7 @@ static bool batadv_frag_insert_packet(st goto err; frag_packet = (struct batadv_frag_packet *)skb->data; + data_len = skb->len - hdr_size; seqno =ntohs (frag_packet->seqno); bucket = seqno %BATADV_FRAG_BUFFER_COUNT ;
@@ -172,7 +176,7 @@ static bool batadv_frag_insert_packet(stspin_lock_bh (&chain->lock);if (batadv_frag_init_chain (chain, seqno)) {hlist_add_head (&frag_entry_new->list, &chain->fragment_list); - chain->size = skb->len - hdr_size; + chain->size = data_len; chain->timestamp = jiffies; chain->total_size =ntohs (frag_packet->total_size); ret = true;
@@ -189,7 +193,11 @@ static bool batadv_frag_insert_packet(stif (frag_entry_curr->no < frag_entry_new->no) {hlist_add_before (&frag_entry_new->list, &frag_entry_curr->list); - chain->size += skb->len - hdr_size; + +if (check_add_overflow (chain->size, data_len, + &chain->size)) + overflow = true; + chain->timestamp = jiffies; ret = true; goto out;
@@ -202,13 +210,16 @@ static bool batadv_frag_insert_packet(st/* Reached the end of the list, so insert after 'frag_entry_last'. */ if (likely (frag_entry_last)) {hlist_add_behind (&frag_entry_new->list, &frag_entry_last->list); - chain->size += skb->len - hdr_size; + +if (check_add_overflow (chain->size, data_len, &chain->size)) + overflow = true; + chain->timestamp = jiffies; ret = true; } out: -if (chain->size >batadv_frag_size_limit () || +if (overflow || chain->size >batadv_frag_size_limit () || chain->total_size !=ntohs (frag_packet->total_size) || chain->total_size >batadv_frag_size_limit ()) {/* Clear chain if total size of either the list or the packet
net/batman-adv/types.h +1 -1
@@ -294,7 +294,7 @@ struct batadv_frag_table_entry {u16 seqno;/** @size: accumulated size of packets in list */ -u16 size; +size_t size;/** @total_size: expected size of the assembled packet */ u16 total_size;
Greg Kroah-Hartman
maintainerPATCH 710/776 batman-adv: fix tp_meter counter underflow during shutdown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
commit 94f3b133168d1c49895e7cc6afbcf1cc0b354602 upstream.
batadv_tp_sender_shutdown() unconditionally decrements the "sending" atomic counter. If multiple paths (e.g. timeout, user cancel, and normal finish) call this function, the counter can underflow to -1.
Since the sender logic treats any non-zero value as "still sending", a negative value causes the sender kthread to loop indefinitely. This leads to a use-after-free when the interface is removed while the zombie thread is still active.
Fix this by using atomic_xchg() to ensure the counter only transitions from 1 to 0 once.
--- net/batman-adv/tp_meter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/batman-adv/tp_meter.c +2 -2
@@ -435,7 +435,7 @@ static void batadv_tp_sender_end(structstatic void batadv_tp_sender_shutdown (struct batadv_tp_vars *tp_vars,enum batadv_tp_meter_reason reason) { -if (!atomic_dec_and_test (&tp_vars->sending)) +if (atomic_xchg (&tp_vars->sending,0 ) !=1 )return ; tp_vars->reason = reason;
@@ -869,7 +869,7 @@ static int batadv_tp_send(void *arg)"Meter: %s() cannot send packets (%d)\n" , __func__, err);/* ensure nobody else tries to stop the thread now */ -if (atomic_dec_and_test (&tp_vars->sending)) +if (atomic_xchg (&tp_vars->sending,0 ) ==1 ) tp_vars->reason = err;break ; }
Greg Kroah-Hartman
maintainerPATCH 711/776 batman-adv: frag: disallow unicast fragment in fragment
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit bc62216dc8e221e3781afa14430f45208bfa9af9 upstream.
batadv_frag_skb_buffer() is called by batadv_batman_skb_recv() when a BATADV_UNICAST_FRAG packet is received. Once all fragments are collected and the packet is reassembled, batadv_recv_frag_packet() calls batadv_batman_skb_recv() again to process the defragmented payload.
A malicious sender can craft a BATADV_UNICAST_FRAG packet whose reassembled payload is itself a BATADV_UNICAST_FRAG packet (matryoshka-style nesting). Each nesting level recurses through batadv_batman_skb_recv() without bound, growing the kernel stack until it is exhausted.
Since refragmentation or fragments in fragments are not actually allowed, discard all packets which are still BATADV_UNICAST_FRAG packets after the defragmentation process.
--- net/batman-adv/fragmentation.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
net/batman-adv/fragmentation.c +35 -0
@@ -306,6 +306,31 @@ free: }/** +* batadv_skb_is_frag() - check if newly merged skb is gain a unicast packet +* @skb: newly merged skb +* +* Return: if newly skb is of type BATADV_UNICAST_FRAG +*/ +static bool batadv_skb_is_frag (struct sk_buff *skb) +{ +struct batadv_ogm_packet *batadv_ogm_packet; + +/* packet should hold at least type and version */ +if (unlikely (!pskb_may_pull (skb,2 ))) +return false; + + batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data; + +if (batadv_ogm_packet->version !=BATADV_COMPAT_VERSION ) +return false; + +if (batadv_ogm_packet->packet_type !=BATADV_UNICAST_FRAG ) +return false; + +return true; +} + +/** * batadv_frag_skb_buffer() - buffer fragment for later merge * @skb: skb to buffer * @orig_node_src: originator that the skb is received from
@@ -338,6 +363,16 @@ bool batadv_frag_skb_buffer(struct sk_buif (!skb_out) goto out_err; +/* fragment in fragment is not allowed. otherwise it is possible +* to exhaust the stack when receiving a matryoshka-style +* "fragments in a fragment packet" +*/ +if (batadv_skb_is_frag (skb_out)) { +kfree_skb (skb_out); + skb_out =NULL ; + goto out_err; + } + out: ret = true; out_err:
Greg Kroah-Hartman
maintainerPATCH 712/776 batman-adv: bla: fix report_work leak on backbone_gw purge
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 0459430add32ea41f3e2ef9351610e6d33627a6b upstream.
batadv_bla_purge_backbone_gw() removes stale backbone gateway entries, but fails to properly handle their associated report_work:
- If report_work is running, the purge must wait for it to finish before freeing the backbone_gw, otherwise the worker may access freed memory (e.g. bat_priv).
- If report_work is pending, the purge must cancel it and release the reference held for that pending work item.
The previous implementation called hlist_for_each_entry_safe() inside a spin_lock_bh() section, but cancel_work_sync() may sleep and therefore cannot be called from within a spinlock-protected region.
Restructure the loop to handle one entry per spinlock critical section:
acquire the lock, find the next entry to purge, remove it from the hash list, then release the lock before calling cancel_work_sync() and dropping the hash_entry reference. Repeat until no more entries require purging.
--- net/batman-adv/bridge_loop_avoidance.c | 60 ++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 22 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +38 -22
@@ -1223,6 +1223,7 @@ static void batadv_bla_purge_backbone_gwstruct hlist_head *head;struct batadv_hashtable *hash;spinlock_t *list_lock;/* protects write access to the hash lists */ +bool purged;int i; hash = bat_priv->bla.backbone_hash;
@@ -1233,30 +1234,45 @@ static void batadv_bla_purge_backbone_gw head = &hash->table[i]; list_lock = &hash->list_locks[i]; -spin_lock_bh (list_lock); -hlist_for_each_entry_safe (backbone_gw, node_tmp, - head, hash_entry) { -if (now) - goto purge_now; -if (!batadv_has_timed_out (backbone_gw->lasttime, -BATADV_BLA_BACKBONE_TIMEOUT )) -continue ; - -batadv_dbg (BATADV_DBG_BLA , backbone_gw->bat_priv, -"%s(): backbone gw %pM timed out\n" , - __func__, backbone_gw->orig); +do { + purged = false; + +spin_lock_bh (list_lock); +hlist_for_each_entry_safe (backbone_gw, node_tmp, + head, hash_entry) { +if (now) + goto purge_now; +if (!batadv_has_timed_out (backbone_gw->lasttime, +BATADV_BLA_BACKBONE_TIMEOUT )) +continue ; + +batadv_dbg (BATADV_DBG_BLA , backbone_gw->bat_priv, +"%s(): backbone gw %pM timed out\n" , + __func__, backbone_gw->orig); purge_now: -/* don't wait for the pending request anymore */ -if (atomic_read (&backbone_gw->request_sent)) -atomic_dec (&bat_priv->bla.num_requests); - -batadv_bla_del_backbone_claims (backbone_gw); - -hlist_del_rcu (&backbone_gw->hash_entry); -batadv_backbone_gw_put (backbone_gw); - } -spin_unlock_bh (list_lock); + purged = true; + +/* don't wait for the pending request anymore */ +if (atomic_read (&backbone_gw->request_sent)) +atomic_dec (&bat_priv->bla.num_requests); + +batadv_bla_del_backbone_claims (backbone_gw); + +hlist_del_rcu (&backbone_gw->hash_entry); +break ; + } +spin_unlock_bh (list_lock); + +if (purged) { +/* reference for pending report_work */ +if (cancel_work_sync (&backbone_gw->report_work)) +batadv_backbone_gw_put (backbone_gw); + +/* reference for hash_entry */ +batadv_backbone_gw_put (backbone_gw); + } + }while (purged); } }
Greg Kroah-Hartman
maintainerPATCH 713/776 batman-adv: tp_meter: avoid use of uninit sender vars
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 6c65cf23d4c6170fcf5714c32aa64689718cb142 upstream.
batadv_tp_recv_ack() and batadv_tp_stop() are only valid for tp_vars in the BATADV_TP_SENDER role. When called with a BATADV_TP_RECEIVER role, it proceeds to read sender-only members that were never initialized, leading to undefined behavior.
This can be triggered when a node that is currently acting as a receiver in an ongoing tp_meter session receives a malicious ACK packet.
Guard against this by checking tp_vars->role immediately after the lookup and bailing out if it is not BATADV_TP_SENDER, before any of those members are accessed.
--- net/batman-adv/tp_meter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/batman-adv/tp_meter.c +9 -2
@@ -647,6 +647,9 @@ static void batadv_tp_recv_ack(struct baif (unlikely (!tp_vars))return ; +if (unlikely (tp_vars->role !=BATADV_TP_SENDER )) + goto out; +if (unlikely (atomic_read (&tp_vars->sending) ==0 )) goto out;
@@ -1080,12 +1083,16 @@ void batadv_tp_stop(struct batadv_priv *if (!tp_vars) {batadv_dbg (BATADV_DBG_TP_METER , bat_priv,"Meter: trying to interrupt an already over connection\n" ); - goto out; + goto out_put_orig_node; } +if (unlikely (tp_vars->role !=BATADV_TP_SENDER )) + goto out_put_tp_vars; +batadv_tp_sender_shutdown (tp_vars, return_value); +out_put_tp_vars:batadv_tp_vars_put (tp_vars); -out: +out_put_orig_node:batadv_orig_node_put (orig_node); }
Greg Kroah-Hartman
maintainerPATCH 714/776 batman-adv: tt: fix negative last_changeset_len
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit fc92cdfcb295cefa4344d71a527d61b638b7bfc4 upstream.
batadv_piv_tt::last_changeset_len len was declared as s16, but the field is never intended to hold a negative value. When a value greater than 32767 is assigned, it wraps to a negative signed integer.
In batadv_send_my_tt_response(), last_changeset_len is temporarily widened to s32. The incorrectly negative s16 value propagates into the s32, causing batadv_tt_prepare_tvlv_local_data() to allocate a full sized buffer but populates only a small portion of it with the collected changeset. All remaining bits are kept uninitialized.
Using an u16 avoids this type confusion and ensures that no (negative) sign extension is performed in batadv_send_my_tt_response().
--- net/batman-adv/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/types.h +1 -1
@@ -993,7 +993,7 @@ struct batadv_priv_tt {* @last_changeset_len: length of last tt changeset this host has * generated */ -s16 last_changeset_len; +u16 last_changeset_len;/** * @last_changeset_lock: lock protecting last_changeset &
Greg Kroah-Hartman
maintainerPATCH 715/776 batman-adv: tt: fix negative tt_buff_len
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit b64963a2ceeb7529310b6cf253a1e540784422f4 upstream.
batadv_orig_node::tt_buff_len was declared as s16, but the field is never intended to hold a negative value. When a value greater than 32767 is assigned, it wraps to a negative signed integer.
In batadv_send_other_tt_response(), tt_buff_len is temporarily widened to s32. The incorrectly negative s16 value propagates into the s32, causing batadv_tt_prepare_tvlv_global_data() to allocate a full sized buffer but populates only a small portion of it with the collected changeset. All remaining bits are kept uninitialized.
Using an u16 avoids this type confusion and ensures that no (negative) sign extension is performed in batadv_send_other_tt_response().
--- net/batman-adv/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/types.h +1 -1
@@ -445,7 +445,7 @@ struct batadv_orig_node {* @tt_buff_len: length of the last tt changeset this node received * from the orig node */ -s16 tt_buff_len; +u16 tt_buff_len;/** @tt_buff_lock: lock that protects tt_buff and tt_buff_len */ spinlock_t tt_buff_lock;
Greg Kroah-Hartman
maintainerPATCH 716/776 hwmon: (pmbus/adm1266) seed timestamp from the real-time clock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit b86095e3d7dcf2bf80c747349a35912a87a85098 upstream.
adm1266_set_rtc() seeds the chip's SET_RTC register from ktime_get_seconds(), which returns CLOCK_MONOTONIC -- i.e. seconds since the host last booted, not seconds since the Unix epoch.
The chip stamps that value into every blackbox record it captures. Userspace reading those timestamps back expects wall-clock seconds:
that's what the SET_RTC frame layout documents (datasheet Rev. D, Table 84) and what every other consumer of "seconds since epoch" assumes. Seeding from CLOCK_MONOTONIC gives blackbox records a timestamp that is only meaningful within a single boot of the host and silently resets to small values on every reboot.
Switch to ktime_get_real_seconds() so the seed matches what the register is documented to hold.
--- drivers/hwmon/pmbus/adm1266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1266.c +1 -1
@@ -434,7 +434,7 @@ static int adm1266_set_rtc(struct adm126char write_buf[6 ];int i; - kt =ktime_get_seconds (); + kt =ktime_get_real_seconds ();memset (write_buf,0 ,sizeof (write_buf));
Greg Kroah-Hartman
maintainerPATCH 717/776 hwmon: (pmbus/adm1266) reject implausible blackbox record_count
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 4afca954622d672ea65ed961bed01cf91caa034e upstream.
adm1266_nvmem_read_blackbox() loops over a record_count that comes straight from byte 3 of the BLACKBOX_INFO response. The destination buffer is data->dev_mem, sized for the nvmem cell's declared 2048 bytes (ADM1266_BLACKBOX_MAX_RECORDS * ADM1266_BLACKBOX_SIZE = 32 * 64). A device that reports a record_count greater than 32 -- whether due to firmware bugs, bus corruption, or a non-responsive slave returning 0xff -- would walk read_buff past the end of the dev_mem allocation on the trailing iterations.
Cap record_count at ADM1266_BLACKBOX_MAX_RECORDS (introduced here) before entering the loop and return -EIO on any larger value, so a malformed BLACKBOX_INFO response cannot drive the loop out of bounds.
--- drivers/hwmon/pmbus/adm1266.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/pmbus/adm1266.c +3 -0
@@ -46,6 +46,7 @@#define ADM1266_BLACKBOX_OFFSET 0#define ADM1266_BLACKBOX_SIZE 64 +#define ADM1266_BLACKBOX_MAX_RECORDS 32#define ADM1266_PMBUS_BLOCK_MAX 255
@@ -362,6 +363,8 @@ static int adm1266_nvmem_read_blackbox(sreturn -EIO ; record_count = buf[3 ]; +if (record_count >ADM1266_BLACKBOX_MAX_RECORDS ) +return -EIO ;for (index =0 ; index < record_count; index++) { ret =adm1266_pmbus_block_xfer (data,ADM1266_READ_BLACKBOX ,1 , &index, read_buff);
Greg Kroah-Hartman
maintainerPATCH 718/776 hwmon: (pmbus/adm1266) include PEC byte in pmbus_block_xfer read buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 487566cb1ccdf3756fdd7bf8d875e612ff3169bb upstream.
adm1266_pmbus_block_xfer() sets up the read transaction with
.buf = data->read_buf, .len = ADM1266_PMBUS_BLOCK_MAX + 2,
but read_buf in struct adm1266_data is declared as
u8 read_buf[ADM1266_PMBUS_BLOCK_MAX + 1];
For a max-length block response (length byte = 255 + up to 1 PEC byte), the i2c controller is told to write 257 bytes into a 256-byte buffer, putting one byte past the end of read_buf. The same response also makes the subsequent PEC compare
if (crc != msgs[1].buf[msgs[1].buf[0] + 1])
read a byte beyond the array.
Bump the read_buf declaration to ADM1266_PMBUS_BLOCK_MAX + 2 so the buffer can hold the length byte, up to 255 payload bytes, and the PEC byte the i2c_msg length already accounts for.
--- drivers/hwmon/pmbus/adm1266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1266.c +1 -1
@@ -61,7 +61,7 @@ struct adm1266_data {u8 *dev_mem;struct mutex buf_mutex;u8 write_buf[ADM1266_PMBUS_BLOCK_MAX +1 ]____cacheline_aligned ; -u8 read_buf[ADM1266_PMBUS_BLOCK_MAX +1 ]____cacheline_aligned ; +u8 read_buf[ADM1266_PMBUS_BLOCK_MAX +2 ]____cacheline_aligned ; };static const struct nvmem_cell_info adm1266_nvmem_cells[] = {
Greg Kroah-Hartman
maintainerPATCH 719/776 hwmon: (pmbus/adm1266) bounce blackbox records through a protocol-sized buffer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 43cae21424ff8e33894a0f86c6b80b840c049fd7 upstream.
adm1266_pmbus_block_xfer() copies the device-supplied block payload into the caller-provided buffer using the device-supplied length:
memcpy(data_r, &msgs[1].buf[1], msgs[1].buf[0]);
The helper does not know how large data_r is and trusts the device to return at most one record's worth of bytes. adm1266_nvmem_read_blackbox() violates that contract: it advances read_buff inside data->dev_mem in ADM1266_BLACKBOX_SIZE (64-byte) strides while the helper is willing to write up to ADM1266_PMBUS_BLOCK_MAX (255) bytes. A device that returns more than 64 bytes on the trailing record (read_buff offset 1984 in the 2048-byte dev_mem allocation) overflows dev_mem by up to 191 bytes before the post-call
if (ret != ADM1266_BLACKBOX_SIZE) return -EIO;
can reject the response.
Contain the fix in the caller without changing the helper signature:
read each record into a 255-byte local bounce buffer that matches the helper's maximum output, validate the returned length, and only then copy exactly ADM1266_BLACKBOX_SIZE bytes into the dev_mem slot.
--- drivers/hwmon/pmbus/adm1266.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/adm1266.c +3 -1
@@ -350,6 +350,7 @@ static void adm1266_init_debugfs(structstatic int adm1266_nvmem_read_blackbox (struct adm1266_data *data,u8 *read_buff) { +u8 record[ADM1266_PMBUS_BLOCK_MAX ];int record_count;char index;u8 buf[I2C_SMBUS_BLOCK_MAX ];
@@ -367,13 +368,14 @@ static int adm1266_nvmem_read_blackbox(sreturn -EIO ;for (index =0 ; index < record_count; index++) { - ret =adm1266_pmbus_block_xfer (data,ADM1266_READ_BLACKBOX ,1 , &index, read_buff); + ret =adm1266_pmbus_block_xfer (data,ADM1266_READ_BLACKBOX ,1 , &index, record);if (ret <0 )return ret;if (ret !=ADM1266_BLACKBOX_SIZE )return -EIO ; +memcpy (read_buff, record,ADM1266_BLACKBOX_SIZE ); read_buff +=ADM1266_BLACKBOX_SIZE ; }