6.18.35-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 68/315 ethtool: tsconfig: fix missing ethnl_ops_complete()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 6386bd772de64e6760306eb91c7e86163af6c22f ]
tsconfig_prepare_data() calls ethnl_ops_begin(), we need to call ethnl_ops_complete() before returning the error.
--- net/ethtool/tsconfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ethtool/tsconfig.c +4 -2
@@ -69,8 +69,10 @@ static int tsconfig_prepare_data(const struct ethnl_req_info *req_base,if (ret) goto out; -if (ts_info.phc_index ==-1 ) -return -ENODEV ; +if (ts_info.phc_index ==-1 ) { + ret = -ENODEV ; + goto out; + } data->hwprov_desc.index = ts_info.phc_index; data->hwprov_desc.qualifier = ts_info.phc_qualifier;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 56/315 tunnels: do not assume transport header in iptunnel_pmtud_check_icmp()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 509323077ef79a26ba0c60bb556e45c12c398b2d ]
In some cases, iptunnel_pmtud_check_icmp() can be called while skb transport header is not set.
This triggers an out-of-bound access, because
(typeof(skb->transport_header))~0U is 65535.
Access the icmp header based on IPv4 network header, after making sure icmp->type is present in skb linear part.
Note that iptunnel_pmtud_check_icmpv6()) is fine.
--- net/ipv4/ip_tunnel_core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
net/ipv4/ip_tunnel_core.c +10 -3
@@ -280,7 +280,6 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu)*/ static int iptunnel_pmtud_check_icmp (struct sk_buff *skb,int mtu) { -const struct icmphdr *icmph =icmp_hdr (skb);const struct iphdr *iph =ip_hdr (skb);if (mtu <576 || iph->frag_off !=htons (IP_DF ))
@@ -291,9 +290,17 @@ static int iptunnel_pmtud_check_icmp(struct sk_buff *skb, int mtu) ipv4_is_lbcast(iph->saddr) || ipv4_is_multicast(iph->saddr))return 0 ; -if (iph->protocol ==IPPROTO_ICMP &&icmp_is_err (icmph->type)) -return 0 ; +if (iph->protocol ==IPPROTO_ICMP ) { +const struct icmphdr *icmph; +if (!pskb_network_may_pull (skb, iph->ihl *4 + + offsetofend(struct icmphdr, type))) +return 0 ; + iph =ip_hdr (skb); + icmph = (void *)iph + iph->ihl *4 ; +if (icmp_is_err (icmph->type)) +return 0 ; + }return iptunnel_pmtud_build_icmp (skb, mtu); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 50/307 ethtool: module: avoid leaking a netdev ref on module flash errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit fb7f511d62692661846c47f199e0afe25c2982db ]
module_flash_fw_schedule() is missing undo for setting the "in_progress" flag and taking the netdev reference. Delay taking these, the device can't disappear while we are holding rtnl_lock.
--- net/ethtool/module.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ethtool/module.c +3 -2
@@ -318,8 +318,6 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name,if (err <0 ) goto err_release_firmware; - dev->ethtool->module_fw_flash_in_progress = true; -netdev_hold (dev, &module_fw->dev_tracker,GFP_KERNEL ); fw_update->dev = dev; fw_update->ntf_params.portid = info->snd_portid; fw_update->ntf_params.seq = info->snd_seq;
@@ -334,6 +332,9 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name,if (err <0 ) goto err_release_firmware; + dev->ethtool->module_fw_flash_in_progress = true; +netdev_hold (dev, &module_fw->dev_tracker,GFP_KERNEL ); +schedule_work (&module_fw->work);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 69/315 ethtool: tsinfo: fix uninitialized stats on the by-PHC path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 1de405699c62c3a9544bcdcfb9eff8a01cfc7582 ]
tsinfo_prepare_data() has two code paths: a "by-PHC" path for user-specified hardware timestamping providers, and the old path. Commit 89e281ebff72 ("ethtool: init tsinfo stats if requested") added ethtool_stats_init() to mark stat slots as ETHTOOL_STAT_NOT_SET before the driver callback populates them, but placed the call inside the old-path block.
When commit b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology") added the by-PHC early return, it landed above the stats initialization. On that path the stats array retains the zero-fill from ethnl_init_reply_data()'s zalloc. This leads to the reply including a stats nest with four zero-valued attributes that should have been absent.
Reject GET requests for stats with HWTSTAMP_PROVIDER or dump.
--- net/ethtool/tsinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/ethtool/tsinfo.c +13 -0
@@ -81,6 +81,11 @@ tsinfo_parse_request(struct ethnl_req_info *req_base, struct nlattr **tb,if (!tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ])return 0 ; +if (req_base->flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (extack,"can't query statistics for a provider" ); +return -EOPNOTSUPP ; + } +return ts_parse_hwtst_provider (tb[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER ], &req->hwprov_desc, extack, &mod); }
@@ -521,6 +526,12 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)if (ret <0 ) goto free_reply_data; +if (req_info->base.flags ÐTOOL_FLAG_STATS ) { +NL_SET_ERR_MSG (cb->extack,"stats not supported in dump" ); + ret = -EOPNOTSUPP ; + goto err_dev_put; + } + ctx->req_info = req_info; ctx->reply_data = reply_data; ctx->pos_ifindex =0 ;
@@ -530,6 +541,8 @@ int ethnl_tsinfo_start(struct netlink_callback *cb)return 0 ; +err_dev_put: +ethnl_parse_header_dev_put (&req_info->base); free_reply_data:kfree (reply_data); free_req_info:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 51/307 ethtool: module: check fw_flash_in_progress under rtnl_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 504eaefa44c8dec50f7499edcb36d24f3aefab2a ]
ethnl_set_module_validate() inspects module_fw_flash_in_progress but validate is meant for _input_ validation, not state validation. rtnl_lock is not held, yet. Move the check into ethnl_set_module().
--- net/ethtool/module.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/ethtool/module.c +6 -6
@@ -119,12 +119,6 @@ ethnl_set_module_validate(struct ethnl_req_info *req_info,if (!tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY ])return 0 ; -if (req_info->dev->ethtool->module_fw_flash_in_progress) { -NL_SET_ERR_MSG (info->extack, -"Module firmware flashing is in progress" ); -return -EBUSY ; - } -if (!ops->get_module_power_mode || !ops->set_module_power_mode) { NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY],
@@ -147,6 +141,12 @@ ethnl_set_module(struct ethnl_req_info *req_info, struct genl_info *info) ops = dev->ethtool_ops; +if (dev->ethtool->module_fw_flash_in_progress) { +NL_SET_ERR_MSG (info->extack, +"Module firmware flashing is in progress" ); +return -EBUSY ; + } + power_new.policy =nla_get_u8 (tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY ]); ret = ops->get_module_power_mode (dev, &power, info->extack);if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 70/315 ethtool: tsinfo: dont pass ERR_PTR to genlmsg_cancel on prepare failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit c3fc9976f686f9a95baf87db9d387f218fd65394 ]
The goto err label leads to:
genlmsg_cancel(skb, ehdr); return ret;
If ethnl_tsinfo_prepare_dump() failed, it has not started a genlmsg. There's nothing to cancel, and passing an error pointer to genlmsg_cancel() would cause a crash.
--- net/ethtool/tsinfo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ethtool/tsinfo.c +2 -4
@@ -405,10 +405,8 @@ static int ethnl_tsinfo_dump_one_netdev(struct sk_buff *skb,continue ; ehdr =ethnl_tsinfo_prepare_dump (skb, dev, reply_data, cb); -if (IS_ERR (ehdr)) { - ret =PTR_ERR (ehdr); - goto err; - } +if (IS_ERR (ehdr)) +return PTR_ERR (ehdr); reply_data->ts_info.phc_qualifier = ctx->pos_phcqualifier; ret = ops->get_ts_info (dev, &reply_data->ts_info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 52/307 ethtool: module: fix cleanup if socket used for flashing multiple devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 760d04ebad5c4304f22c0d2251c9623b87a117c8 ]
When a single Netlink socket issues MODULE_FW_FLASH_ACT against multiple devices, ethnl_sock_priv_set() overwrites sk_priv->dev on each call, retaining only the last one. The socket priv is used on socket close, to walk the global work list and mark the uncompleted flashing work as "orphaned". Otherwise if another socket reuses the PID it will unexpectedly receive the flashing notifications.
Don't record the device, record net pointer instead. The purpose of the dev is to scope the work to a netns, anyway. If we store netns the overrides are safe/a nop since all flashed devices must be in the same netns as the socket.
--- net/ethtool/module.c | 9 ++++----- net/ethtool/netlink.c | 4 ++-- net/ethtool/netlink.h | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-)
net/ethtool/module.c +4 -5
@@ -282,11 +282,9 @@ void ethnl_module_fw_flash_sock_destroy(struct ethnl_sock_priv *sk_priv)spin_lock (&module_fw_flash_work_list_lock);list_for_each_entry (work, &module_fw_flash_work_list, list) { -if (work->fw_update.dev == sk_priv->dev && - work->fw_update.ntf_params.portid == sk_priv->portid) { +if (work->fw_update.ntf_params.portid == sk_priv->portid && +dev_net (work->fw_update.dev) == sk_priv->net) work->fw_update.ntf_params.closed_sock = true; -break ; - } }spin_unlock (&module_fw_flash_work_list_lock); }
@@ -323,7 +321,8 @@ module_flash_fw_schedule(struct net_device *dev, const char *file_name, fw_update->ntf_params.seq = info->snd_seq; fw_update->ntf_params.closed_sock = false; - err =ethnl_sock_priv_set (skb, dev, fw_update->ntf_params.portid, + err =ethnl_sock_priv_set (skb,dev_net (dev), + fw_update->ntf_params.portid,ETHTOOL_SOCK_TYPE_MODULE_FW_FLASH );if (err <0 ) goto err_release_firmware;
net/ethtool/netlink.c +2 -2
@@ -50,7 +50,7 @@ const struct nla_policy ethnl_header_policy_phy_stats[] = { [ETHTOOL_A_HEADER_PHY_INDEX] = NLA_POLICY_MIN(NLA_U32, 1), }; -int ethnl_sock_priv_set (struct sk_buff *skb,struct net_device *dev,u32 portid, +int ethnl_sock_priv_set (struct sk_buff *skb,struct net *net,u32 portid,enum ethnl_sock_type type) {struct ethnl_sock_priv *sk_priv;
@@ -59,7 +59,7 @@ int ethnl_sock_priv_set(struct sk_buff *skb, struct net_device *dev, u32 portid,if (IS_ERR (sk_priv))return PTR_ERR (sk_priv); - sk_priv->dev = dev; + sk_priv->net = net; sk_priv->portid = portid; sk_priv->type = type;
net/ethtool/netlink.h +2 -2
@@ -315,12 +315,12 @@ enum ethnl_sock_type { };struct ethnl_sock_priv { -struct net_device *dev; +struct net *net;u32 portid;enum ethnl_sock_type type; }; -int ethnl_sock_priv_set (struct sk_buff *skb,struct net_device *dev,u32 portid, +int ethnl_sock_priv_set (struct sk_buff *skb,struct net *net,u32 portid,enum ethnl_sock_type type);/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 71/315 ethtool: strset: fix header attribute index in ethnl_req_get_phydev()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit a8d8bef6b45bf7cc0b1f6110c5cd8d0160a9bad7 ]
strset_prepare_data() passes ETHTOOL_A_HEADER_FLAGS (3) as the header attribute to ethnl_req_get_phydev(). This is incorrect, in the main attr space 3 is ETHTOOL_A_STRSET_COUNTS_ONLY, not the request header attr. The correct constant is ETHTOOL_A_STRSET_HEADER (1).
ethnl_req_get_phydev() only uses this value for the extack, so this is not a "functionally visible"(?) bug.
--- net/ethtool/strset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/strset.c +1 -1
@@ -309,7 +309,7 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,return 0 ; } - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_HEADER_FLAGS , + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_STRSET_HEADER , info->extack);/* phydev can be NULL, check for errors only */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 53/307 ethtool: cmis: require exact CDB reply length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 6c3f999a9d1338c6c89a9ff4549eafe72bc2e7b1 ]
Malicious SFP module could respond with rpl_len longer than what cmis_cdb_process_reply() expected, leading to OOB writes. Malicious HW is a bit theoretical but some modules may just be buggy and/or the reads may occasionally get corrupted, so let's protect the kernel.
The existing check protects from short replies. We need to protect from long ones, too. All callers that pass a non-zero rpl_exp_len cast the reply payload to a fixed-layout struct and read fields at fixed offsets, with no version negotiation or short-reply handling:
- cmis_cdb_validate_password()
- cmis_cdb_module_features_get()
- cmis_fw_update_fw_mng_features_get()
so let's assume that responses longer than expected do not have to be handled gracefully here. Add a warning message to make the debug easier in case my understanding is wrong...
Note that page_data->length (argument of kmalloc) comes from last arg to ethtool_cmis_page_init() which is rpl_exp_len.
Note2 that AIs also like to point out overflows in args->req.payload itself (which is a fixed-size 120 B buffer, on the stack), but callers should be reading structs defined by the standard, so protecting from requests for more data than max seem like defensive programming.
--- net/ethtool/cmis_cdb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ethtool/cmis_cdb.c +7 -2
@@ -508,8 +508,13 @@ static int cmis_cdb_process_reply(struct net_device *dev, } rpl = (struct ethtool_cmis_cdb_rpl *)page_data->data; -if ((args->rpl_exp_len > rpl->hdr.rpl_len + rpl_hdr_len) || - !rpl->hdr.rpl_chk_code) { +if (rpl->hdr.rpl_len != args->rpl_exp_len) { +netdev_warn (dev,"CDB reply length mismatch, expected %u got %u\n" , + args->rpl_exp_len, rpl->hdr.rpl_len); + err = -EIO ; + goto out; + } +if (!rpl->hdr.rpl_chk_code) { err = -EIO ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 38/307 net: netlink: dont set nsid on local notifications
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 88b126b39f9757e9debc322d4679239e9af089c7 ]
In most cases, notifications on sockets with NETLINK_LISTEN_ALL_NSID do not contain NSID in their ancillary data in case the event is local to the listener.
However, when a self-referential NSID is allocated for a namespace, every local notification starts sending this ID to the user space.
This is problematic, because the listener cannot tell if those notifications are local or not anymore without making extra requests to figure out if the provided NSID is local or not. The listener can also not figure out the local NSID beforehand as it can be allocated at any point in time by other processes, changing the structure of the future notifications for everyone.
The value is practically not useful, since it's the namespace's own ID that the application has to obtain from other sources in order to figure out if it's the same or not. So, for the application it's just an extra busy work with no benefits. Moreover, applications that do not know about this quirk may be mishandling notifications with NSID set as notifications from remote namespaces. This is the case for ovs-vswitchd and the iproute2's 'ip monitor' that stops printing 'current' and starts printing the nsid number mid-session.
Lack of clear documentation for this behavior is also not helping.
A search though open-source projects doesn't reveal any projects that use NETNSA_NSID_NOT_ASSIGNED and rely on metadata to contain self-referential NSIDs (expected, since the value is not useful). Quite the opposite, as already mentioned, there are few applications that rely on NSID to not be present in local events.
Since the value is not useful and actively harmful in some cases, let's not report it for local events, making the notifications more consistent.
Also adding some blank lines for readability.
--- net/netlink/af_netlink.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +7 -3
@@ -1477,10 +1477,14 @@ static void do_one_broadcast(struct sock *sk, p->skb2 =NULL ; goto out; } +NETLINK_CB (p->skb2).nsid_is_set = false; -NETLINK_CB (p->skb2).nsid =peernet2id (sock_net (sk), p->net); -if (NETLINK_CB (p->skb2).nsid !=NETNSA_NSID_NOT_ASSIGNED ) -NETLINK_CB (p->skb2).nsid_is_set = true; +if (!net_eq (sock_net (sk), p->net)) { +NETLINK_CB (p->skb2).nsid =peernet2id (sock_net (sk), p->net); +if (NETLINK_CB (p->skb2).nsid !=NETNSA_NSID_NOT_ASSIGNED ) +NETLINK_CB (p->skb2).nsid_is_set = true; + } + val =netlink_broadcast_deliver (sk, p->skb2);if (val <0 ) {netlink_overrun (sk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 72/315 ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during fallback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 2376586f85f972fefe701f095bb37dcfe7405d21 ]
All ethtool driver op calls should be sandwiched between ethnl_ops_begin() / ethnl_ops_complete(). In Netlink eeprom code, if the paged access failed we fall back to old API, but we first call _complete() and the fallback never does its own ethnl_ops_begin(). Move the fallback into the _begin() / _complete() section.
--- net/ethtool/eeprom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/ethtool/eeprom.c +2 -3
@@ -140,12 +140,11 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,return 0 ; err_ops: +if (ret == -EOPNOTSUPP ) + ret =eeprom_fallback (request, reply);ethnl_ops_complete (dev); err_free:kfree (page_data.data); - -if (ret == -EOPNOTSUPP ) -return eeprom_fallback (request, reply);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 54/307 ethtool: cmis: fix u16-to-u8 truncation of msleep_pre_rpl
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 3e8c3d464c36bb342fe377b026577c7ec27fdbb4 ]
ethtool_cmis_cdb_compose_args() accepts msleep_pre_rpl as u16 but stores it into the u8 field ethtool_cmis_cdb_cmd_args::msleep_pre_rpl, silently truncating values >= 256. Seven of the nine call sites pass 1000 ms (it's the third argument from the end).
--- net/ethtool/cmis.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ethtool/cmis.h +2 -2
@@ -59,9 +59,9 @@ struct ethtool_cmis_cdb_request {* struct ethtool_cmis_cdb_cmd_args - CDB commands execution arguments * @req: CDB command fields as described in the CMIS standard. * @max_duration: Maximum duration time for command completion in msec. +* @msleep_pre_rpl: Waiting time before checking reply in msec. * @read_write_len_ext: Allowable additional number of byte octets to the LPL * in a READ or a WRITE commands. -* @msleep_pre_rpl: Waiting time before checking reply in msec. * @rpl_exp_len: Expected reply length in bytes. * @flags: Validation flags for CDB commands. * @err_msg: Error message to be sent to user space.
@@ -69,8 +69,8 @@ struct ethtool_cmis_cdb_request {struct ethtool_cmis_cdb_cmd_args {struct ethtool_cmis_cdb_request req;u16 max_duration; +u16 msleep_pre_rpl;u8 read_write_len_ext; -u8 msleep_pre_rpl;u8 rpl_exp_len;u8 flags;char *err_msg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 73/315 ethtool: eeprom: add more safeties to EEPROM Netlink fallback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 67cfdd9210b99f260b3e0afeb9525e0acc7be31e ]
The Netlink fallback path for reading module EEPROM (fallback_set_params()) validates that offset < eeprom_len, but does not check that offset + length stays within eeprom_len. The ioctl equivalent (ethtool_get_any_eeprom() in ioctl.c) has always enforced both bounds:
if (eeprom.offset + eeprom.len > total_len)
return -EINVAL;
This could lead to surprises in both drivers and device FW. Add the missing offset + length validation to fallback_set_params(), mirroring the ioctl.
Similarly - ethtool core in general, and ethtool_get_any_eeprom() in particular tries to zero-init all buffers passed to the drivers to avoid any extra work of zeroing things out. eeprom_fallback() uses a plain kmalloc(), change it to zalloc.
--- net/ethtool/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ethtool/eeprom.c +4 -1
@@ -43,6 +43,9 @@ static int fallback_set_params(struct eeprom_req_info *request,if (offset >= modinfo->eeprom_len)return -EINVAL ; +if (length > modinfo->eeprom_len - offset) +return -EINVAL ; + eeprom->cmd =ETHTOOL_GMODULEEEPROM ; eeprom->len = length; eeprom->offset = offset;
@@ -68,7 +71,7 @@ static int eeprom_fallback(struct eeprom_req_info *request,if (err <0 )return err; - data =kmalloc (eeprom.len,GFP_KERNEL ); + data =kzalloc (eeprom.len,GFP_KERNEL );if (!data)return -ENOMEM ; err =ethtool_get_module_eeprom_call (dev, &eeprom, data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 55/307 net: ethtool: Add new parameters and a function to support EPL
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danielle Ratson <[email protected]>
[ Upstream commit edc344568922eb9588e77ba49de1ef0cb9a2ff1c ]
In the CMIS specification for pluggable modules, LPL (Local Payload) and EPL (Extended Payload) are two types of data payloads used for managing various functions and features of the module.
EPL payloads are used for more complex and extensive management functions that require a larger amount of data, so writing firmware blocks using EPL is much more efficient.
Currently, only LPL payload is supported for writing firmware blocks to the module.
Add EPL related parameters to the function ethtool_cmis_cdb_compose_args() and add a specific function for calculating the maximum allowable length extension for EPL. Both will be used in the next patch to add support for writing firmware blocks using EPL.
Stable-dep-of: 12c2496a71f8 ("ethtool: cmis: validate start_cmd_payload_size from module")
--- net/ethtool/cmis.h | 12 +++++++----- net/ethtool/cmis_cdb.c | 32 +++++++++++++++++++++----------- net/ethtool/cmis_fw_update.c | 17 ++++++++++------- 3 files changed, 38 insertions(+), 23 deletions(-)
net/ethtool/cmis.h +7 -5
@@ -96,13 +96,15 @@ struct ethtool_cmis_cdb_rpl {u8 payload[ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH ]; }; -u32 ethtool_cmis_get_max_payload_size (u8 num_of_byte_octs); +u32 ethtool_cmis_get_max_lpl_size (u8 num_of_byte_octs); +u32 ethtool_cmis_get_max_epl_size (u8 num_of_byte_octs);void ethtool_cmis_cdb_compose_args (struct ethtool_cmis_cdb_cmd_args *args, -enum ethtool_cmis_cdb_cmd_id cmd,u8 *pl, -u8 lpl_len,u16 max_duration, -u8 read_write_len_ext,u16 msleep_pre_rpl, -u8 rpl_exp_len,u8 flags); +enum ethtool_cmis_cdb_cmd_id cmd,u8 *lpl, +u8 lpl_len,u8 *epl,u16 epl_len, +u16 max_duration,u8 read_write_len_ext, +u16 msleep_pre_rpl,u8 rpl_exp_len, +u8 flags);void ethtool_cmis_cdb_check_completion_flag (u8 cmis_rev,u8 *flags);
net/ethtool/cmis_cdb.c +21 -11
@@ -11,25 +11,34 @@* min(i, 15) byte octets where i specifies the allowable additional number of * byte octets in a READ or a WRITE. */ -u32 ethtool_cmis_get_max_payload_size (u8 num_of_byte_octs) +u32 ethtool_cmis_get_max_lpl_size (u8 num_of_byte_octs) {return 8 * (1 +min_t (u8, num_of_byte_octs,15 )); } +/* For accessing the EPL field on page 9Fh, the allowable length extension is +* min(i, 255) byte octets where i specifies the allowable additional number of +* byte octets in a READ or a WRITE. +*/ +u32 ethtool_cmis_get_max_epl_size (u8 num_of_byte_octs) +{ +return 8 * (1 +min_t (u8, num_of_byte_octs,255 )); +} +void ethtool_cmis_cdb_compose_args (struct ethtool_cmis_cdb_cmd_args *args, -enum ethtool_cmis_cdb_cmd_id cmd,u8 *pl, -u8 lpl_len,u16 max_duration, -u8 read_write_len_ext,u16 msleep_pre_rpl, -u8 rpl_exp_len,u8 flags) +enum ethtool_cmis_cdb_cmd_id cmd,u8 *lpl, +u8 lpl_len,u8 *epl,u16 epl_len, +u16 max_duration,u8 read_write_len_ext, +u16 msleep_pre_rpl,u8 rpl_exp_len,u8 flags) { args->req.id =cpu_to_be16 (cmd); args->req.lpl_len = lpl_len; -if (pl) -memcpy (args->req.payload, pl, args->req.lpl_len); +if (lpl) +memcpy (args->req.payload, lpl, args->req.lpl_len); args->max_duration = max_duration; args->read_write_len_ext = -ethtool_cmis_get_max_payload_size (read_write_len_ext); +ethtool_cmis_get_max_lpl_size (read_write_len_ext); args->msleep_pre_rpl = msleep_pre_rpl; args->rpl_exp_len = rpl_exp_len; args->flags = flags;
@@ -183,7 +192,7 @@ cmis_cdb_validate_password(struct ethtool_cmis_cdb *cdb, }ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_QUERY_STATUS , - (u8 *)&qs_pl,sizeof (qs_pl),0 , + (u8 *)&qs_pl,sizeof (qs_pl),NULL ,0 ,0 , cdb->read_write_len_ext,1000 ,sizeof (*rpl),CDB_F_COMPLETION_VALID |CDB_F_STATUS_VALID );
@@ -245,8 +254,9 @@ static int cmis_cdb_module_features_get(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_check_completion_flag (cdb->cmis_rev, &flags);ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_MODULE_FEATURES , -NULL ,0 ,0 , cdb->read_write_len_ext, -1000 ,sizeof (*rpl), flags); +NULL ,0 ,NULL ,0 ,0 , + cdb->read_write_len_ext,1000 , +sizeof (*rpl), flags); err =ethtool_cmis_cdb_execute_cmd (dev, &args);if (err <0 ) {
net/ethtool/cmis_fw_update.c +10 -7
@@ -54,7 +54,8 @@ cmis_fw_update_fw_mng_features_get(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_check_completion_flag (cdb->cmis_rev, &flags);ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_FW_MANAGMENT_FEATURES , -NULL ,0 , cdb->max_completion_time, +NULL ,0 ,NULL ,0 , + cdb->max_completion_time, cdb->read_write_len_ext,1000 ,sizeof (*rpl), flags);
@@ -122,7 +123,7 @@ cmis_fw_update_start_download(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_START_FW_DOWNLOAD , - (u8 *)&pl, lpl_len, + (u8 *)&pl, lpl_len,NULL ,0 , fw_mng->max_duration_start, cdb->read_write_len_ext,1000 ,0 ,CDB_F_COMPLETION_VALID |CDB_F_STATUS_VALID );
@@ -158,7 +159,7 @@ cmis_fw_update_write_image(struct ethtool_cmis_cdb *cdb,int err; max_lpl_len =min_t (u32, -ethtool_cmis_get_max_payload_size (cdb->read_write_len_ext), +ethtool_cmis_get_max_lpl_size (cdb->read_write_len_ext),ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH ); max_block_size = max_lpl_len - sizeof_field(struct cmis_cdb_write_fw_block_lpl_pl,
@@ -183,7 +184,7 @@ cmis_fw_update_write_image(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_WRITE_FW_BLOCK_LPL , - (u8 *)&pl, lpl_len, + (u8 *)&pl, lpl_len,NULL ,0 , fw_mng->max_duration_write, cdb->read_write_len_ext,1 ,0 ,CDB_F_COMPLETION_VALID |CDB_F_STATUS_VALID );
@@ -212,7 +213,8 @@ cmis_fw_update_complete_download(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_COMPLETE_FW_DOWNLOAD , -NULL ,0 , fw_mng->max_duration_complete, +NULL ,0 ,NULL ,0 , + fw_mng->max_duration_complete, cdb->read_write_len_ext,1000 ,0 ,CDB_F_COMPLETION_VALID |CDB_F_STATUS_VALID );
@@ -294,7 +296,7 @@ cmis_fw_update_run_image(struct ethtool_cmis_cdb *cdb, struct net_device *dev,int err;ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_RUN_FW_IMAGE , - (u8 *)&pl,sizeof (pl), + (u8 *)&pl,sizeof (pl),NULL ,0 , cdb->max_completion_time, cdb->read_write_len_ext,1000 ,0 ,CDB_F_MODULE_STATE_VALID );
@@ -326,7 +328,8 @@ cmis_fw_update_commit_image(struct ethtool_cmis_cdb *cdb,ethtool_cmis_cdb_compose_args (&args,ETHTOOL_CMIS_CDB_CMD_COMMIT_FW_IMAGE , -NULL ,0 , cdb->max_completion_time, +NULL ,0 ,NULL ,0 , + cdb->max_completion_time, cdb->read_write_len_ext,1000 ,0 ,CDB_F_COMPLETION_VALID |CDB_F_STATUS_VALID );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 74/315 ipv6: rpl: fix hdrlen overflow in ipv6_rpl_srh_decompress()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahul Chandelkar <[email protected]>
[ Upstream commit 9d5e7a46a9f6d8f503b41bfefef70659845f1679 ]
ipv6_rpl_srh_decompress() computes:
outhdr->hdrlen = (((n + 1) * sizeof(struct in6_addr)) >> 3);
hdrlen is __u8. For n >= 127 the result exceeds 255 and silently truncates. With n=127 (cmpri=15, cmpre=15, pad=0, hdrlen=16):
(128 * 16) >> 3 = 256, truncated to 0 as __u8
The caller in ipv6_rpl_srh_rcv() then places the compressed header at buf + ((ohdr->hdrlen + 1) << 3). With hdrlen=0 this is buf + 8, but the decompressed region occupies buf[0..2055] (8-byte header plus 128 full addresses). The compressed header overlaps the decompressed data, and ipv6_rpl_srh_compress() writes into this overlap, corrupting the routing header of the forwarded packet.
The existing guard at exthdrs.c:546 checks (n + 1) > 255, which prevents n+1 from overflowing unsigned char (the segments_left field), but does not prevent the computed hdrlen from overflowing __u8. n=127 passes because 128 <= 255, yet hdrlen=256 does not fit.
Tighten the bound to (n + 1) > 127. This caps n at 126, giving hdrlen = (127 * 16) >> 3 = 254, which fits in __u8. The compressed header then lands at buf + ((254 + 1) << 3) = buf + 2040, exactly past the decompressed region (buf[0..2039]). No overlap. 127 segments is well beyond any realistic RPL deployment.
--- net/ipv6/exthdrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/exthdrs.c +1 -1
@@ -544,7 +544,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)* unsigned char which is segments_left field. Should not be * higher than that. */ -if (r || (n +1 ) >255 ) { +if (r || (n +1 ) >127 ) {kfree_skb (skb);return -1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 56/307 net: ethtool: Add support for writing firmware blocks using EPL payload
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danielle Ratson <[email protected]>
[ Upstream commit 9a3b0d078bd825613c0821bf7bf5a2e1d8d60057 ]
In the CMIS specification for pluggable modules, LPL (Local Payload) and EPL (Extended Payload) are two types of data payloads used for managing various functions and features of the module.
EPL payloads are used for more complex and extensive management functions that require a larger amount of data, so writing firmware blocks using EPL is much more efficient.
Currently, only LPL payload is supported for writing firmware blocks to the module.
Add support for writing firmware block using EPL payload, both to support modules that supports only EPL write mechanism, and to optimize the flashing process of modules that support LPL and EPL.
Stable-dep-of: 12c2496a71f8 ("ethtool: cmis: validate start_cmd_payload_size from module")
--- net/ethtool/cmis.h | 4 ++ net/ethtool/cmis_cdb.c | 66 ++++++++++++++++++++++++-- net/ethtool/cmis_fw_update.c | 91 ++++++++++++++++++++++++++++++++---- 3 files changed, 148 insertions(+), 13 deletions(-)
net/ethtool/cmis.h +4 -0
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ #define ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH 120 +#define ETHTOOL_CMIS_CDB_EPL_MAX_PL_LENGTH 2048#define ETHTOOL_CMIS_CDB_CMD_PAGE 0x9F#define ETHTOOL_CMIS_CDB_PAGE_I2C_ADDR 0x50
@@ -23,6 +24,7 @@ enum ethtool_cmis_cdb_cmd_id {ETHTOOL_CMIS_CDB_CMD_FW_MANAGMENT_FEATURES =0x0041 ,ETHTOOL_CMIS_CDB_CMD_START_FW_DOWNLOAD =0x0101 ,ETHTOOL_CMIS_CDB_CMD_WRITE_FW_BLOCK_LPL =0x0103 , +ETHTOOL_CMIS_CDB_CMD_WRITE_FW_BLOCK_EPL =0x0104 ,ETHTOOL_CMIS_CDB_CMD_COMPLETE_FW_DOWNLOAD =0x0107 ,ETHTOOL_CMIS_CDB_CMD_RUN_FW_IMAGE =0x0109 , ETHTOOL_CMIS_CDB_CMD_COMMIT_FW_IMAGE = 0x010A,
@@ -38,6 +40,7 @@ enum ethtool_cmis_cdb_cmd_id {* @resv1: Added to match the CMIS standard request continuity. * @resv2: Added to match the CMIS standard request continuity. * @payload: Payload for the CDB commands. +* @epl: Extended payload for the CDB commands. */ struct ethtool_cmis_cdb_request {__be16 id;
@@ -49,6 +52,7 @@ struct ethtool_cmis_cdb_request {u8 resv2;u8 payload[ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH ]; ); +u8 *epl;/* Everything above this field checksummed. */ };#define CDB_F_COMPLETION_VALID BIT(0)
net/ethtool/cmis_cdb.c +62 -4
93 lines not on this page · raw message
net/ethtool/cmis_fw_update.c +82 -9
135 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 57/315 ksmbd: fix FSCTL permission bypass by adding a permission check for FSCTL_SET_SPARSE
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Shen <[email protected]>
[ Upstream commit cc57232cae23c0df91b4a59d0f519141ce9b5b02 ]
FSCTL_SET_SPARSE in fsctl_set_sparse() modifies the file's sparse attribute and saves it through xattr without any permission checks.
This exposes two issues:
1) A client on a read-only share can change the sparse attribute on files it opened, even though the share is read-only. Other FSCTL write operations already check test_tree_conn_flag(work->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE), but FSCTL_SET_SPARSE does not.
2) Even on writable shares, clients without FILE_WRITE_DATA or FILE_WRITE_ATTRIBUTES access should not modify the sparse attribute. Similar handle-level checks exist in other functions but are missing here.
Add both share-level writable check and per-handle access check. Use goto out on error to avoid leaking file references.
--- fs/smb/server/smb2pdu.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/smb/server/smb2pdu.c +11 -0
@@ -8203,9 +8203,20 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,int ret =0 ;__le32 old_fattr; +if (!test_tree_conn_flag (work->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) { +ksmbd_debug (SMB ,"User does not have write permission\n" ); +return -EACCES ; + } + fp =ksmbd_lookup_fd_fast (work, id);if (!fp)return -ENOENT ; + +if (!(fp->daccess & (FILE_WRITE_DATA_LE |FILE_WRITE_ATTRIBUTES_LE ))) { + ret = -EACCES ; + goto out; + } + idmap =file_mnt_idmap (fp->filp); old_fattr = fp->f_ci->m_fattr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 75/315 net/sched: Revert "net/sched: Restrict conditions for adding duplicating netems to qdisc tree"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit eda0b7f203bb166c98d1418b204135bd566ac83b ]
This reverts commit ec8e0e3d7adef940cdf9475e2352c0680189d14e.
The original patch rejects any tree containing two netems when either has duplication set, even when they sit on unrelated classes of the same classful parent. That broke configurations that have worked since netem was introduced.
The re-entrancy problem the original commit was trying to solve is handled by later patch using tc_depth flag.
Doing this revert will (re)expose the original bug with multiple netem duplication. When this patch is backported make sure and get the full series.
--- net/sched/sch_netem.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-)
net/sched/sch_netem.c +0 -40
@@ -1006,41 +1006,6 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla,return 0 ; } -static const struct Qdisc_class_ops netem_class_ops; - -static int check_netem_in_tree (struct Qdisc *sch,bool duplicates, -struct netlink_ext_ack *extack) -{ -struct Qdisc *root, *q; -unsigned int i; - - root =qdisc_root_sleeping (sch); - -if (sch != root && root->ops->cl_ops == &netem_class_ops) { -if (duplicates || - ((struct netem_sched_data *)qdisc_priv (root))->duplicate) - goto err; - } - -if (!qdisc_dev (root)) -return 0 ; - -hash_for_each (qdisc_dev (root)->qdisc_hash, i, q, hash) { -if (sch != q && q->ops->cl_ops == &netem_class_ops) { -if (duplicates || - ((struct netem_sched_data *)qdisc_priv (q))->duplicate) - goto err; - } - } - -return 0 ; - -err: -NL_SET_ERR_MSG (extack, -"netem: cannot mix duplicating netems with other netems in tree" ); -return -EINVAL ; -} -/* Parse netlink message to set options */ static int netem_change (struct Qdisc *sch,struct nlattr *opt,struct netlink_ext_ack *extack)
@@ -1117,11 +1082,6 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, q->gap = qopt->gap; q->counter =0 ; q->loss = qopt->loss; - - ret =check_netem_in_tree (sch, qopt->duplicate, extack); -if (ret) - goto unlock; - q->duplicate = qopt->duplicate;/* for compatibility with earlier versions.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 57/307 ethtool: cmis: validate start_cmd_payload_size from module
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 12c2496a71f82f63617971ca9b730dffa05cf58b ]
The CMIS firmware update code reads start_cmd_payload_size from the module's FW Management Features CDB reply and uses it directly as the byte count for memcpy. The destination buffer is 112 bytes (ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH - 8). So a malicious module (or corrupted response) can cause a OOB write later on in cmis_fw_update_start_download().
Let's error out. If modules that expect longer LPL writes actually exist we should revisit.
struct cmis_cdb_start_fw_download_pl's definition has to move, no change there.
--- net/ethtool/cmis_fw_update.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
net/ethtool/cmis_fw_update.c +22 -14
@@ -43,6 +43,20 @@ enum cmis_cdb_fw_write_mechanism { CMIS_CDB_FW_WRITE_MECHANISM_BOTH = 0x11, }; +/* See section 9.7.2 "CMD 0101h: Start Firmware Download" in CMIS standard +* revision 5.2. +* struct cmis_cdb_start_fw_download_pl is a structured layout of the +* flat array, ethtool_cmis_cdb_request::payload. +*/ +struct cmis_cdb_start_fw_download_pl { + __struct_group(cmis_cdb_start_fw_download_pl_h, head, /* no attrs */, + __be32 image_size; +__be32 resv1; + ); +u8 vendor_data[ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH - +sizeof (struct cmis_cdb_start_fw_download_pl_h )]; +}; + static int cmis_fw_update_fw_mng_features_get(struct ethtool_cmis_cdb *cdb, struct net_device *dev,
@@ -85,6 +99,14 @@ cmis_fw_update_fw_mng_features_get(struct ethtool_cmis_cdb *cdb,*/ cdb->read_write_len_ext = rpl->read_write_len_ext; fw_mng->start_cmd_payload_size = rpl->start_cmd_payload_size; +if (fw_mng->start_cmd_payload_size > + sizeof_field(struct cmis_cdb_start_fw_download_pl, vendor_data)) { +ethnl_module_fw_flash_ntf_err (dev, ntf_params, +"Start cmd payload size exceeds max LPL payload" , +NULL ); +return -EINVAL ; + } + fw_mng->write_mechanism = rpl->write_mechanism ==CMIS_CDB_FW_WRITE_MECHANISM_LPL ? CMIS_CDB_FW_WRITE_MECHANISM_LPL :
@@ -96,20 +118,6 @@ cmis_fw_update_fw_mng_features_get(struct ethtool_cmis_cdb *cdb,return 0 ; } -/* See section 9.7.2 "CMD 0101h: Start Firmware Download" in CMIS standard -* revision 5.2. -* struct cmis_cdb_start_fw_download_pl is a structured layout of the -* flat array, ethtool_cmis_cdb_request::payload. -*/ -struct cmis_cdb_start_fw_download_pl { - __struct_group(cmis_cdb_start_fw_download_pl_h, head, /* no attrs */, - __be32 image_size; -__be32 resv1; - ); -u8 vendor_data[ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH - -sizeof (struct cmis_cdb_start_fw_download_pl_h )]; -}; - static int cmis_fw_update_start_download(struct ethtool_cmis_cdb *cdb, struct ethtool_cmis_fw_update_params *fw_update,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 76/315 net: hibmcge: disable Relaxed Ordering to fix RX packet corruption
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jijie Shao <[email protected]>
[ Upstream commit 463a1271aa26eac992851b9d98cc75bc3cd4a1ed ]
When SMMU is disabled, the hibmcge driver may receive corrupted packets. The hardware writes packet data and descriptors to the same page, but with Relaxed Ordering enabled, PCI write transactions may not be strictly ordered. This can cause the driver to observe a valid descriptor before the corresponding packet data is fully written.
Fix this by clearing PCI_EXP_DEVCTL_RELAX_EN in the PCI bridge control register to ensure strict write ordering between packet data and descriptors.
--- drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +3 -0
@@ -420,6 +420,9 @@ static int hbg_pci_init(struct pci_dev *pdev)return -ENOMEM ;pci_set_master (pdev); +pcie_capability_clear_word (pdev,PCI_EXP_DEVCTL , +PCI_EXP_DEVCTL_RELAX_EN ); +pci_save_state (pdev);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 58/307 ethtool: cmis: validate fw->size against start_cmd_payload_size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit d5551f4c1800dc714cec86647bdd651ae0de923e ]
cmis_fw_update_start_download() copies start_cmd_payload_size bytes from the firmware blob into the CDB LPL vendor_data[] payload without validating that the FW has enough data.
Since the start_cmd_payload_size can only be ~120B an image too short is most likely corrupted, so reject it.
--- net/ethtool/cmis_fw_update.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ethtool/cmis_fw_update.c +8 -0
@@ -129,6 +129,14 @@ cmis_fw_update_start_download(struct ethtool_cmis_cdb *cdb,u8 lpl_len;int err; +if (fw_update->fw->size < vendor_data_size) { +ethnl_module_fw_flash_ntf_err (fw_update->dev, + &fw_update->ntf_params, +"Firmware image too small for module's start payload" , +NULL ); +return -EINVAL ; + } + pl.image_size =cpu_to_be32 (fw_update->fw->size);memcpy (pl.vendor_data, fw_update->fw->data, vendor_data_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 77/315 net/handshake: Use spin_lock_bh for hn_lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit cc993e0927ec8bd98ea33377ada03295fcda0f24 ]
nvmet_tcp_state_change(), a socket callback that runs in BH context, can reach handshake_req_cancel() via nvmet_tcp_schedule_release_queue() and tls_handshake_cancel(). handshake_req_cancel() acquires hn->hn_lock with plain spin_lock(). If a process-context thread on the same CPU holds hn->hn_lock when a softirq invokes the cancel path, the lock attempt deadlocks. This is the only caller that invokes tls_handshake_cancel() from BH context; every other consumer calls it from process context.
Deferring the cancel to process context in the NVMe target is not
straightforward: nvmet_tcp_schedule_release_queue() must call tls_handshake_cancel() atomically with its state transition to DISCONNECTING. If the cancel were deferred, the handshake completion callback could fire in the window before the cancel runs, observe the unexpected state, and return without dropping its kref on the queue. Reworking that interlock is considerably more invasive than hardening the handshake lock. Convert all hn->hn_lock acquisitions from spin_lock/spin_unlock to spin_lock_bh/spin_unlock_bh so the lock is never taken with softirqs enabled.
--- net/handshake/netlink.c | 4 ++-- net/handshake/request.c | 14 +++++++------- net/handshake/tlshd.c | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-)
net/handshake/netlink.c +2 -2
@@ -203,10 +203,10 @@ static void __net_exit handshake_net_exit(struct net *net)* accepted and are in progress will be destroyed when * the socket is closed. */ -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);set_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags);list_splice_init (&requests, &hn->hn_requests); -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);while (!list_empty (&requests)) { req = list_first_entry(&requests, struct handshake_req, hr_list);
net/handshake/request.c +7 -7
@@ -167,12 +167,12 @@ static bool remove_pending(struct handshake_net *hn, struct handshake_req *req) {bool ret = false; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);if (!list_empty (&req->hr_list)) {__remove_pending_locked (hn, req); ret = true; } -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);return ret; }
@@ -182,7 +182,7 @@ struct handshake_req *handshake_req_next(struct handshake_net *hn, int class)struct handshake_req *req, *pos; req =NULL ; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);list_for_each_entry (pos, &hn->hn_requests, hr_list) {if (pos->hr_proto->hp_handler_class != class)continue ;
@@ -190,7 +190,7 @@ struct handshake_req *handshake_req_next(struct handshake_net *hn, int class) req = pos;break ; } -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);return req; }
@@ -249,7 +249,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,if (READ_ONCE (hn->hn_pending) >= hn->hn_pending_max) goto out_err; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock); ret = -EOPNOTSUPP ;if (test_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags)) goto out_unlock;
@@ -258,7 +258,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, goto out_unlock;if (!__add_pending_locked (hn, req)) goto out_unlock; -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock); ret =handshake_genl_notify (net, req->hr_proto, flags);if (ret) {
@@ -274,7 +274,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,return 0 ; out_unlock: -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock); out_err:/* Restore original destructor so socket teardown still runs on failure */ req->hr_sk->sk_destruct = req->hr_odestruct;
net/handshake/tlshd.c +2 -0
@@ -425,6 +425,8 @@ EXPORT_SYMBOL(tls_server_hello_psk);* Request cancellation races with request completion. To determine * who won, callers examine the return value from this function. * +* Context: May be called from process or softirq context. +* * Return values: * %true - Uncompleted handshake request was canceled * %false - Handshake request already completed or not found
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 59/307 cxl/test: Update mock dev array before calling platform_device_add()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit d90f236f8b9e354848bd226f581db27755ab901d ]
CXL test environment hits the following error sometimes.
cxl_mem mem9: endpoint7 failed probe
All mock memdevs are platform firmware devices added by cxl_test module, and cxl_test module also provides a platform device driver for them to create a memdev device to CXL subsystem. cxl_test module uses cxl_rcd/mem_single/mem arrays to store different types of mock memdevs. CXL drivers calls registered mock functions for a mock memdev by checking if a given memdev is in these arrays.
When cxl_test module adds these mock memdevs, it always calls platform_device_add() before adding them to a suitable mock memdev array. However, there is a small window where CXL drivers calls mock function for a added memdev before it added to a mock memdev array. In above case, cxl endpoint driver considers a added memdev was not a mock memdev, then calling devm_cxl_endpoint_decoders_setup() for it rather than mock_endpoint_decoders_setup().
An appropriate solution is that adding a new mock device to a mock device array before calling platform_device_add() for it. It can guarantee the new mock device is visible to CXL subsystem.
This patch introduces a new helped called cxl_mock_platform_device_add() to handle the issue, and uses the function for all mock devices addition.
--- tools/testing/cxl/test/cxl.c | 105 ++++++++++++++--------------------- 1 file changed, 43 insertions(+), 62 deletions(-)
tools/testing/cxl/test/cxl.c +43 -62
@@ -1058,6 +1058,23 @@ static void mock_companion(struct acpi_device *adev, struct device *dev)#define SZ_64G (SZ_32G * 2)#endif +static int cxl_mock_platform_device_add (struct platform_device *pdev, +struct platform_device **ppdev) +{ +int rc; + +if (ppdev) + *ppdev = pdev; + rc =platform_device_add (pdev); +if (rc) { +platform_device_put (pdev); +if (ppdev) + *ppdev =NULL ; + } + +return rc; +} +static __init int cxl_rch_topo_init (void ) {int rc, i;
@@ -1072,13 +1089,10 @@ static __init int cxl_rch_topo_init(void) goto err_bridge;mock_companion (adev, &pdev->dev); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_rch[i]); +if (rc) goto err_bridge; - } - cxl_rch[i] = pdev; mock_pci_bus[idx].bridge = &pdev->dev; rc =sysfs_create_link (&pdev->dev.kobj, &pdev->dev.kobj,"firmware_node" );
@@ -1130,13 +1144,10 @@ static __init int cxl_single_topo_init(void) goto err_bridge;mock_companion (adev, &pdev->dev); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_hb_single[i]); +if (rc) goto err_bridge; - } - cxl_hb_single[i] = pdev; mock_pci_bus[i +NR_CXL_HOST_BRIDGES ].bridge = &pdev->dev; rc =sysfs_create_link (&pdev->dev.kobj, &pdev->dev.kobj,"physical_node" );
@@ -1155,12 +1166,9 @@ static __init int cxl_single_topo_init(void) goto err_port; pdev->dev.parent = &bridge->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_root_single[i]); +if (rc) goto err_port; - } - cxl_root_single[i] = pdev; }for (i =0 ; i <ARRAY_SIZE (cxl_swu_single); i++) {
@@ -1173,12 +1181,9 @@ static __init int cxl_single_topo_init(void) goto err_uport; pdev->dev.parent = &root_port->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_swu_single[i]); +if (rc) goto err_uport; - } - cxl_swu_single[i] = pdev; }for (i =0 ; i <ARRAY_SIZE (cxl_swd_single); i++) {
@@ -1192,12 +1197,9 @@ static __init int cxl_single_topo_init(void) goto err_dport; pdev->dev.parent = &uport->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_swd_single[i]); +if (rc) goto err_dport; - } - cxl_swd_single[i] = pdev; }return 0 ;
@@ -1270,12 +1272,9 @@ static int cxl_mem_init(void) pdev->dev.parent = &dport->dev;set_dev_node (&pdev->dev, i %2 ); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_mem[i]); +if (rc) goto err_mem; - } - cxl_mem[i] = pdev; }for (i =0 ; i <ARRAY_SIZE (cxl_mem_single); i++) {
@@ -1288,12 +1287,9 @@ static int cxl_mem_init(void) pdev->dev.parent = &dport->dev;set_dev_node (&pdev->dev, i %2 ); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_mem_single[i]); +if (rc) goto err_single; - } - cxl_mem_single[i] = pdev; }for (i =0 ; i <ARRAY_SIZE (cxl_rcd); i++) {
@@ -1307,12 +1303,9 @@ static int cxl_mem_init(void) pdev->dev.parent = &rch->dev;set_dev_node (&pdev->dev, i %2 ); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_rcd[i]); +if (rc) goto err_rcd; - } - cxl_rcd[i] = pdev; }return 0 ;
@@ -1373,13 +1366,10 @@ static __init int cxl_test_init(void) goto err_bridge;mock_companion (adev, &pdev->dev); - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_host_bridge[i]); +if (rc) goto err_bridge; - } - cxl_host_bridge[i] = pdev; mock_pci_bus[i].bridge = &pdev->dev; rc =sysfs_create_link (&pdev->dev.kobj, &pdev->dev.kobj,"physical_node" );
@@ -1397,12 +1387,9 @@ static __init int cxl_test_init(void) goto err_port; pdev->dev.parent = &bridge->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_root_port[i]); +if (rc) goto err_port; - } - cxl_root_port[i] = pdev; }BUILD_BUG_ON (ARRAY_SIZE (cxl_switch_uport) !=ARRAY_SIZE (cxl_root_port));
@@ -1415,12 +1402,9 @@ static __init int cxl_test_init(void) goto err_uport; pdev->dev.parent = &root_port->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_switch_uport[i]); +if (rc) goto err_uport; - } - cxl_switch_uport[i] = pdev; }for (i =0 ; i <ARRAY_SIZE (cxl_switch_dport); i++) {
@@ -1433,12 +1417,9 @@ static __init int cxl_test_init(void) goto err_dport; pdev->dev.parent = &uport->dev; - rc =platform_device_add (pdev); -if (rc) { -platform_device_put (pdev); + rc =cxl_mock_platform_device_add (pdev, &cxl_switch_dport[i]); +if (rc) goto err_dport; - } - cxl_switch_dport[i] = pdev; } rc =cxl_single_topo_init ();
@@ -1456,9 +1437,9 @@ static __init int cxl_test_init(void)mock_companion (&acpi0017_mock, &cxl_acpi->dev); acpi0017_mock.dev.bus = &platform_bus_type; - rc =platform_device_add (cxl_acpi); + rc =cxl_mock_platform_device_add (cxl_acpi,NULL );if (rc) - goto err_root; + goto err_rch; rc =cxl_mem_init ();if (rc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 78/315 nvme-tcp: store negative errno in queue->tls_err
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 9015985b5eb1a90eb86caf5bce1dfcf1aa38f8ad ]
nvme_tcp_tls_done() assigns queue->tls_err in three branches. The ENOKEY lookup failure and the EOPNOTSUPP initializer both store negative errnos. The third branch, reached when the handshake layer reports a non-zero status, stores -status.
The handshake layer delivers status to the consumer callback as a negative errno; the other in-tree consumers -- xs_tls_handshake_done() and the nvmet target callback -- treat their status argument that way. The extra negation in nvme_tcp_tls_done() flips the sign, leaving tls_err as a positive value (for instance, +EIO), which nvme_tcp_start_tls() then returns to its caller.
Drop the extra negation so queue->tls_err uniformly carries a negative errno on failure.
--- drivers/nvme/host/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/tcp.c +1 -1
@@ -1687,7 +1687,7 @@ static void nvme_tcp_tls_done(void *data, int status, key_serial_t pskid) qid, pskid, status);if (status) { - queue->tls_err = -status; + queue->tls_err = status; goto out_complete; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 39/307 net/smc: Do not re-initialize smc hashtables
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Winter <[email protected]>
[ Upstream commit 9e4389b0038781f19f97895186ed941ff8ac1678 ]
INIT_HLIST_HEAD(&smc_v*_hashinfo.ht) are called after smc_nl_init(), proto_register() and sock_register(). This can lead to smc_v*_hashinfo.ht being reset even though hash entries already exist and are being used, possibly resulting in a corrupted list.
Remove unnecessary and dangerous re-initialisation of smc_v*_hashinfo.ht in smc_init(); it is implicitly initialised to zero anyhow. Add HLIST_HEAD_INIT to the definitions for clarity.
--- net/smc/af_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/af_smc.c +2 -2
@@ -187,10 +187,12 @@ static bool smc_hs_congested(const struct sock *sk)struct smc_hashinfo smc_v4_hashinfo = { .lock =__RW_LOCK_UNLOCKED (smc_v4_hashinfo.lock), + .ht =HLIST_HEAD_INIT , };struct smc_hashinfo smc_v6_hashinfo = { .lock =__RW_LOCK_UNLOCKED (smc_v6_hashinfo.lock), + .ht =HLIST_HEAD_INIT , };int smc_hash_sk (struct sock *sk)
@@ -3594,8 +3596,6 @@ static int __init smc_init(void)pr_err ("%s: sock_register fails with %d\n" , __func__, rc); goto out_proto6; } -INIT_HLIST_HEAD (&smc_v4_hashinfo.ht); -INIT_HLIST_HEAD (&smc_v6_hashinfo.ht); rc =smc_ib_register_client ();if (rc) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 60/307 tunnels: load network headers after skb_cow() in iptunnel_pmtud_build_icmp[v6]()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit b4bc94353050b1fa7b702bd4c6600710dd926cff ]
Sashiko found that iptunnel_pmtud_build_icmp() and iptunnel_pmtud_build_icmpv6() were caching ip_hdr() and ipv6_hdr() before an skb_cow() call which can reallocate skb->head.
Fix this possible UAF by initializing the local variables after the skb_cow() call.
Remove skb_reset_network_header() calls which were not needed.
--- net/ipv4/ip_tunnel_core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/ipv4/ip_tunnel_core.c +4 -5
@@ -210,7 +210,7 @@ EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);*/ static int iptunnel_pmtud_build_icmp (struct sk_buff *skb,int mtu) { -const struct iphdr *iph =ip_hdr (skb); +const struct iphdr *iph;struct icmphdr *icmph;struct iphdr *niph;struct ethhdr eh;
@@ -224,7 +224,6 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu)skb_copy_bits (skb,skb_mac_offset (skb), &eh,ETH_HLEN );pskb_pull (skb,ETH_HLEN ); -skb_reset_network_header (skb); err =pskb_trim (skb,576 -sizeof (*niph) -sizeof (*icmph));if (err)
@@ -234,7 +233,7 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu) err =skb_cow (skb,sizeof (*niph) +sizeof (*icmph) +ETH_HLEN );if (err)return err; - + iph =ip_hdr (skb); icmph =skb_push (skb,sizeof (*icmph)); *icmph = (struct icmphdr ) { .type =ICMP_DEST_UNREACH ,
@@ -306,7 +305,7 @@ static int iptunnel_pmtud_check_icmp(struct sk_buff *skb, int mtu)*/ static int iptunnel_pmtud_build_icmpv6 (struct sk_buff *skb,int mtu) { -const struct ipv6hdr *ip6h =ipv6_hdr (skb); +const struct ipv6hdr *ip6h;struct icmp6hdr *icmp6h;struct ipv6hdr *nip6h;struct ethhdr eh;
@@ -321,7 +320,6 @@ static int iptunnel_pmtud_build_icmpv6(struct sk_buff *skb, int mtu)skb_copy_bits (skb,skb_mac_offset (skb), &eh,ETH_HLEN );pskb_pull (skb,ETH_HLEN ); -skb_reset_network_header (skb); err =pskb_trim (skb,IPV6_MIN_MTU -sizeof (*nip6h) -sizeof (*icmp6h));if (err)
@@ -332,6 +330,7 @@ static int iptunnel_pmtud_build_icmpv6(struct sk_buff *skb, int mtu)if (err)return err; + ip6h =ipv6_hdr (skb); icmp6h =skb_push (skb,sizeof (*icmp6h)); *icmp6h = (struct icmp6hdr ) { .icmp6_type =ICMPV6_PKT_TOOBIG ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 79/315 net/handshake: Pass negative errno through handshake_complete()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6b22d433aa13f68e3cd9534ca9a5f4277bfa01c2 ]
handshake_complete() declares status as unsigned int and tls_handshake_done() negates that value (-status) before handing it to the TLS consumer. Consumers match on negative errno constants -- xs_tls_handshake_done() has
switch (status) {
case 0:
case -EACCES:
case -ETIMEDOUT:
lower_transport->xprt_err = status;
break;
default:
lower_transport->xprt_err = -EACCES;
}so the API as designed expects callers to pass positive errno values that the tlshd shim then negates.
Three internal callers in handshake_nl_accept_doit(), the net-exit drain, and a kunit test follow kernel convention and pass negative errnos -- -EIO, -ETIMEDOUT, -ETIMEDOUT. The implicit conversion to unsigned int turns -ETIMEDOUT into 0xFFFFFF92; the subsequent -status in tls_handshake_done() wraps back to 110, the consumer's switch falls through, and the xprt reports -EACCES on what should be -ETIMEDOUT or -EIO.
Fix the API rather than the call sites. The natural kernel convention is negative errno in, negative errno out. Change handshake_complete() and hp_done to take int status, drop the negation in tls_handshake_done(), and negate once in handshake_nl_done_doit() where status arrives from the wire as an unsigned netlink attribute. The three internal callers were already correct under that convention and need no change.
At the same wire boundary, declare MAX_ERRNO as the netlink policy upper bound for HANDSHAKE_A_DONE_STATUS. Attribute validation rejects out-of-range values before handshake_nl_done_doit() runs, and negating a bounded u32 there stays within int range -- closing the UBSAN-visible signed- integer overflow that an unconstrained u32 would invoke.
--- Documentation/netlink/specs/handshake.yaml | 8 ++++++++ net/handshake/genl.c | 3 ++- net/handshake/genl.h | 1 + net/handshake/handshake-test.c | 2 +- net/handshake/handshake.h | 4 ++-- net/handshake/netlink.c | 2 +- net/handshake/request.c | 2 +- net/handshake/tlshd.c | 4 ++-- 8 files changed, 18 insertions(+), 8 deletions(-)
Documentation/netlink/specs/handshake.yaml +8 -0
@@ -12,6 +12,12 @@ protocol: genetlink doc: Netlink protocol to request a transport layer security handshake. definitions: + - + type: const + name: max-errno + value: 4095 + header: linux/err.h + scope: kernel - type: enum name: handler-class
@@ -80,6 +86,8 @@ attribute-sets: - name: status type: u32 + checks: + max: max-errno - name: sockfd type: s32
net/handshake/genl.c +2 -1
@@ -9,6 +9,7 @@#include "genl.h" #include <uapi/linux/handshake.h> +#include <linux/err.h> /* HANDSHAKE_CMD_ACCEPT - do */ static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_ACCEPT_HANDLER_CLASS +1 ] = {
@@ -17,7 +18,7 @@ static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_ACCEPT_HAN/* HANDSHAKE_CMD_DONE - do */ static const struct nla_policy handshake_done_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH +1 ] = { - [HANDSHAKE_A_DONE_STATUS ] = { .type =NLA_U32 , }, + [HANDSHAKE_A_DONE_STATUS ] =NLA_POLICY_MAX (NLA_U32 ,MAX_ERRNO ), [HANDSHAKE_A_DONE_SOCKFD ] = { .type =NLA_S32 , }, [HANDSHAKE_A_DONE_REMOTE_AUTH ] = { .type =NLA_U32 , }, };
net/handshake/genl.h +1 -0
@@ -10,6 +10,7 @@#include <net/genetlink.h> #include <uapi/linux/handshake.h> +#include <linux/err.h> int handshake_nl_accept_doit (struct sk_buff *skb,struct genl_info *info);int handshake_nl_done_doit (struct sk_buff *skb,struct genl_info *info);
net/handshake/handshake-test.c +1 -1
@@ -25,7 +25,7 @@ static int test_accept_func(struct handshake_req *req, struct genl_info *info,return 0 ; } -static void test_done_func (struct handshake_req *req,unsigned int status, +static void test_done_func (struct handshake_req *req,int status,struct genl_info *info) { }
net/handshake/handshake.h +2 -2
@@ -57,7 +57,7 @@ struct handshake_proto {int (*hp_accept)(struct handshake_req *req,struct genl_info *info,int fd);void (*hp_done)(struct handshake_req *req, -unsigned int status, +int status,struct genl_info *info);void (*hp_destroy)(struct handshake_req *req); };
@@ -86,7 +86,7 @@ struct handshake_req *handshake_req_hash_lookup(struct sock *sk);struct handshake_req *handshake_req_next (struct handshake_net *hn,int class);int handshake_req_submit (struct socket *sock,struct handshake_req *req,gfp_t flags); -void handshake_complete (struct handshake_req *req,unsigned int status, +void handshake_complete (struct handshake_req *req,int status,struct genl_info *info);bool handshake_req_cancel (struct sock *sk);
net/handshake/netlink.c +1 -1
@@ -161,7 +161,7 @@ int handshake_nl_done_doit(struct sk_buff *skb, struct genl_info *info) status = -EIO ;if (info->attrs[HANDSHAKE_A_DONE_STATUS ]) - status =nla_get_u32 (info->attrs[HANDSHAKE_A_DONE_STATUS ]); + status = -(int )nla_get_u32 (info->attrs[HANDSHAKE_A_DONE_STATUS ]);handshake_complete (req, status, info);sockfd_put (sock);
net/handshake/request.c +1 -1
@@ -284,7 +284,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, }EXPORT_SYMBOL (handshake_req_submit); -void handshake_complete (struct handshake_req *req,unsigned int status, +void handshake_complete (struct handshake_req *req,int status,struct genl_info *info) {struct sock *sk = req->hr_sk;
net/handshake/tlshd.c +2 -2
@@ -93,7 +93,7 @@ static void tls_handshake_remote_peerids(struct tls_handshake_req *treq,* */ static void tls_handshake_done (struct handshake_req *req, -unsigned int status,struct genl_info *info) +int status,struct genl_info *info) {struct tls_handshake_req *treq =handshake_req_private (req);
@@ -104,7 +104,7 @@ static void tls_handshake_done(struct handshake_req *req,if (!status)set_bit (HANDSHAKE_F_REQ_SESSION , &req->hr_flags); - treq->th_consumer_done (treq->th_consumer_data, -status, + treq->th_consumer_done (treq->th_consumer_data, status, treq->th_peerid[0 ]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 61/307 vxlan: do not reuse cached ip_hdr() value after skb_tunnel_check_pmtu()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 7d9ef0cb271555d8cf39fefe6c981e1493b25ecf ]
skb_tunnel_check_pmtu() can change skb->head.
Reusing old_iph afer skb_tunnel_check_pmtu() can cause an UAF.
Use instead ip_hdr(skb) as done in drivers/net/bareudp.c and drivers/net/geneve.c.
Found by Sashiko.
--- drivers/net/vxlan/vxlan_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/vxlan/vxlan_core.c +2 -2
@@ -2541,7 +2541,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, goto out_unlock; } - tos =ip_tunnel_ecn_encap (tos, old_iph, skb); + tos =ip_tunnel_ecn_encap (tos,ip_hdr (skb), skb); ttl = ttl ? :ip4_dst_hoplimit (&rt->dst); err =vxlan_build_skb (skb, ndst,sizeof (struct iphdr ), vni, md, flags, udp_sum);
@@ -2601,7 +2601,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, goto out_unlock; } - tos =ip_tunnel_ecn_encap (tos, old_iph, skb); + tos =ip_tunnel_ecn_encap (tos,ip_hdr (skb), skb); ttl = ttl ? :ip6_dst_hoplimit (ndst);skb_scrub_packet (skb, xnet); err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 80/315 Bluetooth: l2cap: clear chan->ident on ECRED reconfiguration success
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenghang Xiao <[email protected]>
[ Upstream commit 00e1950716c6ed67d74777b2db286b0fa23b4be9 ]
l2cap_ecred_reconf_rsp() returns early on success without clearing chan->ident. Every other L2CAP response handler (l2cap_ecred_conn_rsp, l2cap_le_connect_rsp, l2cap_config_rsp) clears chan->ident after a successful transaction to prevent the channel from matching subsequent responses with the recycled ident value.
A remote attacker that completed a reconfiguration as the peer can replay a failure response with the stale ident, causing the kernel to match and destroy the already-established channel via l2cap_chan_del(chan, ECONNRESET).
Clear chan->ident for all matching channels on success, and harden the failure path by using l2cap_chan_hold_unless_zero() consistent with other L2CAP handlers (l2cap_le_command_rej, __l2cap_get_chan_by_ident).
--- net/bluetooth/l2cap_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +8 -2
@@ -5466,14 +5466,20 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,BT_DBG ("result 0x%4.4x" , result); -if (!result) +if (!result) { +list_for_each_entry (chan, &conn->chan_l, list) { +if (chan->ident == cmd->ident) + chan->ident =0 ; + }return 0 ; + }list_for_each_entry_safe (chan, tmp, &conn->chan_l, list) {if (chan->ident != cmd->ident)continue ; -l2cap_chan_hold (chan); +if (!l2cap_chan_hold_unless_zero (chan)) +continue ;l2cap_chan_lock (chan);l2cap_chan_del (chan,ECONNRESET );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 62/307 tunnels: do not assume transport header in iptunnel_pmtud_check_icmp()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 509323077ef79a26ba0c60bb556e45c12c398b2d ]
In some cases, iptunnel_pmtud_check_icmp() can be called while skb transport header is not set.
This triggers an out-of-bound access, because
(typeof(skb->transport_header))~0U is 65535.
Access the icmp header based on IPv4 network header, after making sure icmp->type is present in skb linear part.
Note that iptunnel_pmtud_check_icmpv6()) is fine.
--- net/ipv4/ip_tunnel_core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
net/ipv4/ip_tunnel_core.c +10 -3
@@ -278,7 +278,6 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu)*/ static int iptunnel_pmtud_check_icmp (struct sk_buff *skb,int mtu) { -const struct icmphdr *icmph =icmp_hdr (skb);const struct iphdr *iph =ip_hdr (skb);if (mtu <576 || iph->frag_off !=htons (IP_DF ))
@@ -289,9 +288,17 @@ static int iptunnel_pmtud_check_icmp(struct sk_buff *skb, int mtu) ipv4_is_lbcast(iph->saddr) || ipv4_is_multicast(iph->saddr))return 0 ; -if (iph->protocol ==IPPROTO_ICMP &&icmp_is_err (icmph->type)) -return 0 ; +if (iph->protocol ==IPPROTO_ICMP ) { +const struct icmphdr *icmph; +if (!pskb_network_may_pull (skb, iph->ihl *4 + + offsetofend(struct icmphdr, type))) +return 0 ; + iph =ip_hdr (skb); + icmph = (void *)iph + iph->ihl *4 ; +if (icmp_is_err (icmph->type)) +return 0 ; + }return iptunnel_pmtud_build_icmp (skb, mtu); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 81/315 Bluetooth: L2CAP: Fix possible crash on l2cap_ecred_conn_rsp
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 41c2713b204e6cb6a94587bc6bf6935107df5479 ]
If dcid is received for an already-assigned destination CID the spec requires that both channels to be discarded, but calling l2cap_chan_del may invalidate the tmp cursor created by list_for_each_entry_safe and in fact it is the wrong procedure as the chan->dcid may be assigned previously it really needs to be disconnected.
Calling l2cap_chan_clone directly may still lead to l2cap_chan_del so instead schedule l2cap_chan_timeout with delay 0 to close the channel asynchronously.
--- net/bluetooth/l2cap_core.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
net/bluetooth/l2cap_core.c +22 -5
@@ -5268,6 +5268,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, cmd_len -=sizeof (*rsp);list_for_each_entry_safe (chan, tmp, &conn->chan_l, list) { +struct l2cap_chan *orig;u16 dcid; if (chan->ident != cmd->ident ||
@@ -5289,8 +5290,10 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,BT_DBG ("dcid[%d] 0x%4.4x" , i, dcid); + orig =__l2cap_get_chan_by_dcid (conn, dcid); +/* Check if dcid is already in use */ -if (dcid &&__l2cap_get_chan_by_dcid (conn, dcid)) { +if (dcid && orig) {/* If a device receives a * L2CAP_CREDIT_BASED_CONNECTION_RSP packet with an * already-assigned Destination CID, then both the
@@ -5299,10 +5302,24 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,*/ l2cap_chan_del (chan,ECONNREFUSED );l2cap_chan_unlock (chan); - chan =__l2cap_get_chan_by_dcid (conn, dcid); -l2cap_chan_lock (chan); -l2cap_chan_del (chan,ECONNRESET ); -l2cap_chan_unlock (chan); + +/* Check that the dcid channel mode is +* L2CAP_MODE_EXT_FLOWCTL since this procedure is only +* valid for that mode and shouldn't disconnect a dcid +* in other modes. +*/ +if (orig->mode ==L2CAP_MODE_EXT_FLOWCTL ) { +l2cap_chan_lock (orig); +/* Disconnect the original channel as it may be +* considered connected since dcid has already +* been assigned; don't call l2cap_chan_close +* directly since that could lead to +* l2cap_chan_del and then removing the channel +* from the list while we're iterating over it. +*/ +__set_chan_timer (orig,0 ); +l2cap_chan_unlock (orig); + }continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 58/315 ASoC: codecs: simple-mux: Fix enum control bounds check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit f63ad68e18d774a5d15cd7e405ead63f6b322679 ]
simple_mux_control_put() rejects values greater than e->items, but enum control values are zero based. For the two-entry mux used by this driver, valid values are 0 and 1, so value 2 must be rejected as well.
Accepting e->items can store an invalid mux state, pass it to the GPIO setter, and pass it on to the DAPM mux update path where it is used as an index into the enum text array.
Use the same >= e->items check used by the ASoC enum helpers.
--- sound/soc/codecs/simple-mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/simple-mux.c +1 -1
@@ -51,7 +51,7 @@ static int simple_mux_control_put(struct snd_kcontrol *kcontrol,struct snd_soc_component *c =snd_soc_dapm_to_component (dapm);struct simple_mux *priv =snd_soc_component_get_drvdata (c); -if (ucontrol->value.enumerated.item[0 ] > e->items) +if (ucontrol->value.enumerated.item[0 ] >= e->items)return -EINVAL ;if (priv->mux == ucontrol->value.enumerated.item[0 ])
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 54/315 tunnels: load network headers after skb_cow() in iptunnel_pmtud_build_icmp[v6]()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit b4bc94353050b1fa7b702bd4c6600710dd926cff ]
Sashiko found that iptunnel_pmtud_build_icmp() and iptunnel_pmtud_build_icmpv6() were caching ip_hdr() and ipv6_hdr() before an skb_cow() call which can reallocate skb->head.
Fix this possible UAF by initializing the local variables after the skb_cow() call.
Remove skb_reset_network_header() calls which were not needed.
--- net/ipv4/ip_tunnel_core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/ipv4/ip_tunnel_core.c +4 -5
@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);*/ static int iptunnel_pmtud_build_icmp (struct sk_buff *skb,int mtu) { -const struct iphdr *iph =ip_hdr (skb); +const struct iphdr *iph;struct icmphdr *icmph;struct iphdr *niph;struct ethhdr eh;
@@ -226,7 +226,6 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu)skb_copy_bits (skb,skb_mac_offset (skb), &eh,ETH_HLEN );pskb_pull (skb,ETH_HLEN ); -skb_reset_network_header (skb); err =pskb_trim (skb,576 -sizeof (*niph) -sizeof (*icmph));if (err)
@@ -236,7 +235,7 @@ static int iptunnel_pmtud_build_icmp(struct sk_buff *skb, int mtu) err =skb_cow (skb,sizeof (*niph) +sizeof (*icmph) +ETH_HLEN );if (err)return err; - + iph =ip_hdr (skb); icmph =skb_push (skb,sizeof (*icmph)); *icmph = (struct icmphdr ) { .type =ICMP_DEST_UNREACH ,
@@ -308,7 +307,7 @@ static int iptunnel_pmtud_check_icmp(struct sk_buff *skb, int mtu)*/ static int iptunnel_pmtud_build_icmpv6 (struct sk_buff *skb,int mtu) { -const struct ipv6hdr *ip6h =ipv6_hdr (skb); +const struct ipv6hdr *ip6h;struct icmp6hdr *icmp6h;struct ipv6hdr *nip6h;struct ethhdr eh;
@@ -323,7 +322,6 @@ static int iptunnel_pmtud_build_icmpv6(struct sk_buff *skb, int mtu)skb_copy_bits (skb,skb_mac_offset (skb), &eh,ETH_HLEN );pskb_pull (skb,ETH_HLEN ); -skb_reset_network_header (skb); err =pskb_trim (skb,IPV6_MIN_MTU -sizeof (*nip6h) -sizeof (*icmp6h));if (err)
@@ -334,6 +332,7 @@ static int iptunnel_pmtud_build_icmpv6(struct sk_buff *skb, int mtu)if (err)return err; + ip6h =ipv6_hdr (skb); icmp6h =skb_push (skb,sizeof (*icmp6h)); *icmp6h = (struct icmp6hdr ) { .icmp6_type =ICMPV6_PKT_TOOBIG ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 64/307 Bluetooth: 6lowpan: check skb_clone() return value in send_mcast_pkt()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
[ Upstream commit 3c40d381ce04f9575a5d8b542898183c3b4b38dc ]
The skb_clone() function can return NULL if memory allocation fails. send_mcast_pkt() calls skb_clone() without checking the return value, which can lead to a NULL pointer dereference in send_pkt() when it dereferences skb->data.
Add a NULL check after skb_clone() and skip the peer if the clone fails.
--- net/bluetooth/6lowpan.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/6lowpan.c +2 -0
@@ -485,6 +485,8 @@ static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev)int ret; local_skb =skb_clone (skb,GFP_ATOMIC ); +if (!local_skb) +continue ; BT_DBG("xmit %s to %pMR type %u IP %pI6c chan %p", netdev->name,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 83/315 Bluetooth: hci_sync: Reset device counters in hci_dev_close_sync()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
[ Upstream commit cdf88b35e06f1b385f7f6228060ae541d44fbb72 ]
Before resetting or closing the device, protocol counters should also be zeroed.
--- net/bluetooth/hci_sync.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/hci_sync.c +4 -0
@@ -5338,6 +5338,10 @@ int hci_dev_close_sync(struct hci_dev *hdev)/* Reset device */ skb_queue_purge (&hdev->cmd_q);atomic_set (&hdev->cmd_cnt,1 ); + hdev->acl_cnt =0 ; + hdev->sco_cnt =0 ; + hdev->le_cnt =0 ; + hdev->iso_cnt =0 ;if (hci_test_quirk (hdev,HCI_QUIRK_RESET_ON_CLOSE ) && !auto_off && !hci_dev_test_flag (hdev,HCI_UNCONFIGURED )) {set_bit (HCI_INIT , &hdev->flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 69/307 ethtool: strset: fix header attribute index in ethnl_req_get_phydev()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit a8d8bef6b45bf7cc0b1f6110c5cd8d0160a9bad7 ]
strset_prepare_data() passes ETHTOOL_A_HEADER_FLAGS (3) as the header attribute to ethnl_req_get_phydev(). This is incorrect, in the main attr space 3 is ETHTOOL_A_STRSET_COUNTS_ONLY, not the request header attr. The correct constant is ETHTOOL_A_STRSET_HEADER (1).
ethnl_req_get_phydev() only uses this value for the extack, so this is not a "functionally visible"(?) bug.
--- net/ethtool/strset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/strset.c +1 -1
@@ -299,7 +299,7 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,return 0 ; } - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_HEADER_FLAGS , + phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_STRSET_HEADER , info->extack);/* phydev can be NULL, check for errors only */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 84/315 gpio: adnp: fix flow control regression caused by scoped_guard()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit a5c627d90809b793fc053849b3a00609db305776 ]
scoped_guard() is implemented as a for loop. Using it to protect code using the continue statement changes the flow as we now only break out of the hidden loop inside scoped_guard(), not the original for loop. Use a regular code block instead.
--- drivers/gpio/gpio-adnp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-adnp.c +3 -1
@@ -237,7 +237,9 @@ static irqreturn_t adnp_irq(int irq, void *data)unsigned long pending;int err; - scoped_guard(mutex, &adnp->i2c_lock) { + { +guard (mutex)(&adnp->i2c_lock); + err =adnp_read (adnp,GPIO_PLR (adnp) + i, &level);if (err <0 )continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 70/307 ethtool: eeprom: add missing ethnl_ops_begin() / _complete() during fallback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 2376586f85f972fefe701f095bb37dcfe7405d21 ]
All ethtool driver op calls should be sandwiched between ethnl_ops_begin() / ethnl_ops_complete(). In Netlink eeprom code, if the paged access failed we fall back to old API, but we first call _complete() and the fallback never does its own ethnl_ops_begin(). Move the fallback into the _begin() / _complete() section.
--- net/ethtool/eeprom.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/ethtool/eeprom.c +2 -3
@@ -140,12 +140,11 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,return 0 ; err_ops: +if (ret == -EOPNOTSUPP ) + ret =eeprom_fallback (request, reply);ethnl_ops_complete (dev); err_free:kfree (page_data.data); - -if (ret == -EOPNOTSUPP ) -return eeprom_fallback (request, reply);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 85/315 gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8a122b5e72cc0043705f0d524bcd15f0c0b3ec15 ]
If *ppos is non-zero (user-space write split over multiple calls to write()) then simple_write_to_buffer() won't initialize the start of the buffer. Really, non-zero values for *ppos aren't going to work at all. Check for that and return -EINVAL at the start of the function.
--- drivers/gpio/gpio-virtuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-virtuser.c +2 -2
@@ -399,7 +399,7 @@ static ssize_t gpio_virtuser_direction_do_write(struct file *file,char buf[32 ], *trimmed;int ret, dir, val =0 ; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret =simple_write_to_buffer (buf,sizeof (buf) -1 , ppos, user_buf, count);
@@ -626,7 +626,7 @@ static ssize_t gpio_virtuser_consumer_write(struct file *file,char buf[GPIO_VIRTUSER_NAME_BUF_LEN +2 ];int ret; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret = simple_write_to_buffer(buf, GPIO_VIRTUSER_NAME_BUF_LEN, ppos,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 71/307 ethtool: eeprom: add more safeties to EEPROM Netlink fallback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 67cfdd9210b99f260b3e0afeb9525e0acc7be31e ]
The Netlink fallback path for reading module EEPROM (fallback_set_params()) validates that offset < eeprom_len, but does not check that offset + length stays within eeprom_len. The ioctl equivalent (ethtool_get_any_eeprom() in ioctl.c) has always enforced both bounds:
if (eeprom.offset + eeprom.len > total_len)
return -EINVAL;
This could lead to surprises in both drivers and device FW. Add the missing offset + length validation to fallback_set_params(), mirroring the ioctl.
Similarly - ethtool core in general, and ethtool_get_any_eeprom() in particular tries to zero-init all buffers passed to the drivers to avoid any extra work of zeroing things out. eeprom_fallback() uses a plain kmalloc(), change it to zalloc.
--- net/ethtool/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ethtool/eeprom.c +4 -1
@@ -43,6 +43,9 @@ static int fallback_set_params(struct eeprom_req_info *request,if (offset >= modinfo->eeprom_len)return -EINVAL ; +if (length > modinfo->eeprom_len - offset) +return -EINVAL ; + eeprom->cmd =ETHTOOL_GMODULEEEPROM ; eeprom->len = length; eeprom->offset = offset;
@@ -68,7 +71,7 @@ static int eeprom_fallback(struct eeprom_req_info *request,if (err <0 )return err; - data =kmalloc (eeprom.len,GFP_KERNEL ); + data =kzalloc (eeprom.len,GFP_KERNEL );if (!data)return -ENOMEM ; err =ethtool_get_module_eeprom_call (dev, &eeprom, data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 65/307 bonding: refuse to enslave CAN devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
[ Upstream commit 8ba68464e4787b6a7ec938826e16124df20fd23d ]
syzbot reported a kernel paging request crash in can_rx_unregister() inside net/can/af_can.c. The crash occurs because a virtual CAN device (vxcan) is being enslaved to a bonding master.
During the enslavement process, the bonding driver mutates and modifies the network device states to fit an Ethernet-like aggregation model. However, CAN devices operate on a completely different Layer 2 architecture, relying on the CAN mid-layer private data structure (can_ml_priv) instead of standard Ethernet structures. Since bonding does not initialize or maintain these CAN structures, subsequent operations on the half-enslaved interface (such as closing associated sockets via isotp_release) lead to a null-pointer dereference when accessing the CAN receiver lists.
Bonding CAN interfaces is architecturally invalid as CAN lacks MAC addresses, ARP capabilities, and standard Ethernet link-layer mechanisms. While generic loopback devices are blocked globally in net/core/dev.c, virtual CAN devices bypass this check because they do not carry the IFF_LOOPBACK flag, despite acting as local software-loopbacks.
Fix this by explicitly blocking network devices of type ARPHRD_CAN from being enslaved at the very beginning of bond_enslave(). This prevents illegal state mutations, eliminates the resulting KASAN crashes, and avoids potential memory leaks from incomplete socket cleanups.
As the CAN support has been added a long time after bonding the Fixes-tag points to the introduction of ARPHRD_CAN that would have needed a specific handling in bonding_main.c.
--- drivers/net/bonding/bond_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/bonding/bond_main.c +6 -0
@@ -1927,6 +1927,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,int link_reporting;int res =0 , i; +if (slave_dev->type ==ARPHRD_CAN ) { +BOND_NL_ERR (bond_dev, extack, +"CAN devices cannot be enslaved" ); +return -EPERM ; + } +if (slave_dev->flags &IFF_MASTER && !netif_is_bond_master (slave_dev)) { BOND_NL_ERR(bond_dev, extack,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 86/315 gpio: rockchip: convert bank->clk to devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit 3e46c18d5d87f063a93ae0fe7662fbf6660459d5 ]
The bank->clk was previously obtained via of_clk_get() and manually prepared/enabled. However, it was missing a corresponding clk_put() in both the error paths and the remove function, leading to a reference leak.
Convert the allocation to devm_clk_get_enabled(), which also properly propagates failures from clk_prepare_enable() that were previously ignored.
The GPIO bank device uses the same OF node as the previous of_clk_get() call, so devm_clk_get_enabled(dev, NULL) correctly resolves the same clock provider entry.
Fix the reference leak and simplify the code by removing the manual clk_disable_unprepare() calls in the probe error paths and in the remove function.
--- drivers/gpio/gpio-rockchip.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-rockchip.c +1 -5
@@ -656,11 +656,10 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)if (!bank->irq)return -EINVAL ; - bank->clk =of_clk_get (bank->of_node,0 ); + bank->clk =devm_clk_get_enabled (bank->dev,NULL );if (IS_ERR (bank->clk))return PTR_ERR (bank->clk); -clk_prepare_enable (bank->clk); id =readl (bank->reg_base + gpio_regs_v2.version_id);switch (id) {
@@ -672,7 +671,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) bank->db_clk =of_clk_get (bank->of_node,1 );if (IS_ERR (bank->db_clk)) {dev_err (bank->dev,"cannot find debounce clk\n" ); -clk_disable_unprepare (bank->clk);return -EINVAL ; }break ;
@@ -751,7 +749,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev) ret =rockchip_gpiolib_register (bank);if (ret) { -clk_disable_unprepare (bank->clk);mutex_unlock (&bank->deferred_lock);return ret; }
@@ -792,7 +789,6 @@ static void rockchip_gpio_remove(struct platform_device *pdev) {struct rockchip_pin_bank *bank =platform_get_drvdata (pdev); -clk_disable_unprepare (bank->clk);gpiochip_remove (&bank->gpio_chip); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 72/307 ipv6: rpl: fix hdrlen overflow in ipv6_rpl_srh_decompress()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahul Chandelkar <[email protected]>
[ Upstream commit 9d5e7a46a9f6d8f503b41bfefef70659845f1679 ]
ipv6_rpl_srh_decompress() computes:
outhdr->hdrlen = (((n + 1) * sizeof(struct in6_addr)) >> 3);
hdrlen is __u8. For n >= 127 the result exceeds 255 and silently truncates. With n=127 (cmpri=15, cmpre=15, pad=0, hdrlen=16):
(128 * 16) >> 3 = 256, truncated to 0 as __u8
The caller in ipv6_rpl_srh_rcv() then places the compressed header at buf + ((ohdr->hdrlen + 1) << 3). With hdrlen=0 this is buf + 8, but the decompressed region occupies buf[0..2055] (8-byte header plus 128 full addresses). The compressed header overlaps the decompressed data, and ipv6_rpl_srh_compress() writes into this overlap, corrupting the routing header of the forwarded packet.
The existing guard at exthdrs.c:546 checks (n + 1) > 255, which prevents n+1 from overflowing unsigned char (the segments_left field), but does not prevent the computed hdrlen from overflowing __u8. n=127 passes because 128 <= 255, yet hdrlen=256 does not fit.
Tighten the bound to (n + 1) > 127. This caps n at 126, giving hdrlen = (127 * 16) >> 3 = 254, which fits in __u8. The compressed header then lands at buf + ((254 + 1) << 3) = buf + 2040, exactly past the decompressed region (buf[0..2039]). No overlap. 127 segments is well beyond any realistic RPL deployment.
--- net/ipv6/exthdrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/exthdrs.c +1 -1
@@ -546,7 +546,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)* unsigned char which is segments_left field. Should not be * higher than that. */ -if (r || (n +1 ) >255 ) { +if (r || (n +1 ) >127 ) {kfree_skb (skb);return -1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 87/315 gpio: rockchip: teardown bugs and resource leaks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit 9500077678230e36d22bf16d2b9539c13e59a801 ]
Address several teardown issues and resource leaks in the driver's remove path and error handling:
1. Debounce clock reference leak: The debounce clock (bank->db_clk) is obtained using of_clk_get() which increments the clock's reference count, but clk_put() is never called. Register a devm action to cleanly release it on unbind. Note that of_clk_get(..., 1) remains necessary over devm_clk_get() because the DT binding does not define clock-names, precluding name-based lookup.
2. Unregistered chained IRQ handler: The chained IRQ handler is not disconnected in remove(). If a stray interrupt fires after the driver is removed, the kernel attempts to execute a stale handler, leading to a panic. Fix this by clearing the handler in remove().
3. IRQ domain leak: The linear IRQ domain and its generic chips are allocated manually during probe but never removed. Remove the IRQ domain during driver teardown to free the associated generic chips and mappings.
--- drivers/gpio/gpio-rockchip.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpio/gpio-rockchip.c +16 -1
@@ -638,10 +638,17 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)return ret; } +static void rockchip_clk_put (void *data) +{ +struct clk *clk = data; + +clk_put (clk); +} +static int rockchip_get_bank_data (struct rockchip_pin_bank *bank) {struct resource res; -int id =0 ; +int id =0 , ret;if (of_address_to_resource (bank->of_node,0 , &res)) {dev_err (bank->dev,"cannot find IO resource for bank\n" );
@@ -673,6 +680,11 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)dev_err (bank->dev,"cannot find debounce clk\n" );return -EINVAL ; } + + ret =devm_add_action_or_reset (bank->dev, rockchip_clk_put, + bank->db_clk); +if (ret) +return ret;break ;case GPIO_TYPE_V1 : bank->gpio_regs = &gpio_regs_v1;
@@ -789,6 +801,9 @@ static void rockchip_gpio_remove(struct platform_device *pdev) {struct rockchip_pin_bank *bank =platform_get_drvdata (pdev); +irq_set_chained_handler_and_data (bank->irq,NULL ,NULL ); +if (bank->domain) +irq_domain_remove (bank->domain);gpiochip_remove (&bank->gpio_chip); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 88/315 net: mana: Add NULL guards in teardown path to prevent panic on attach failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dipayaan Roy <[email protected]>
[ Upstream commit 17bfe0a8c014ee1d542ad352cd6a0a505361664a ]
When queue allocation fails partway through, the error cleanup frees and NULLs apc->tx_qp and apc->rxqs. Multiple teardown paths such as mana_remove(), mana_change_mtu() recovery, and internal error handling in mana_alloc_queues() can subsequently call into functions that dereference these pointers without NULL checks:
- mana_chn_setxdp() dereferences apc->rxqs[0], causing a NULL pointer dereference panic (CR2: 0000000000000000 at mana_chn_setxdp+0x26).
- mana_destroy_vport() iterates apc->rxqs without a NULL check.
- mana_fence_rqs() iterates apc->rxqs without a NULL check.
- mana_dealloc_queues() iterates apc->tx_qp without a NULL check.
Add NULL guards for apc->rxqs in mana_fence_rqs(), mana_destroy_vport(), and before the mana_chn_setxdp() call. Add a NULL guard for apc->tx_qp in mana_dealloc_queues() to skip TX queue draining when TX queues were never allocated or already freed.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +41 -29
@@ -1720,6 +1720,9 @@ static void mana_fence_rqs(struct mana_port_context *apc)struct mana_rxq *rxq;int err; +if (!apc->rxqs) +return ; +for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { rxq = apc->rxqs[rxq_idx]; err =mana_fence_rq (apc, rxq);
@@ -2830,13 +2833,16 @@ static void mana_destroy_vport(struct mana_port_context *apc)struct mana_rxq *rxq;u32 rxq_idx; -for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { - rxq = apc->rxqs[rxq_idx]; -if (!rxq) -continue ; +if (apc->rxqs) { -mana_destroy_rxq (apc, rxq, true); - apc->rxqs[rxq_idx] =NULL ; +for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { + rxq = apc->rxqs[rxq_idx]; +if (!rxq) +continue ; + +mana_destroy_rxq (apc, rxq, true); + apc->rxqs[rxq_idx] =NULL ; + } }mana_destroy_txq (apc);
@@ -3241,7 +3247,8 @@ static int mana_dealloc_queues(struct net_device *ndev)if (apc->port_is_up)return -EINVAL ; -mana_chn_setxdp (apc,NULL ); +if (apc->rxqs) +mana_chn_setxdp (apc,NULL );if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode)mana_pf_deregister_filter (apc);
@@ -3259,33 +3266,38 @@ static int mana_dealloc_queues(struct net_device *ndev)* number of queues. */ -for (i =0 ; i < apc->num_queues; i++) { - txq = &apc->tx_qp[i].txq; - tsleep =1000 ; -while (atomic_read (&txq->pending_sends) >0 && -time_before (jiffies, timeout)) { -usleep_range (tsleep, tsleep +1000 ); - tsleep <<=1 ; - } -if (atomic_read (&txq->pending_sends)) { - err =pcie_flr (to_pci_dev (gd->gdma_context->dev)); -if (err) { -netdev_err (ndev,"flr failed %d with %d pkts pending in txq %u\n" , - err,atomic_read (&txq->pending_sends), - txq->gdma_txq_id); +if (apc->tx_qp) { +for (i =0 ; i < apc->num_queues; i++) { + txq = &apc->tx_qp[i].txq; + tsleep =1000 ; +while (atomic_read (&txq->pending_sends) >0 && +time_before (jiffies, timeout)) { +usleep_range (tsleep, tsleep +1000 ); + tsleep <<=1 ; + } +if (atomic_read (&txq->pending_sends)) { + err = +pcie_flr (to_pci_dev (gd->gdma_context->dev)); +if (err) { +netdev_err (ndev,"flr failed %d with %d pkts pending in txq %u\n" , + err, +atomic_read (&txq->pending_sends), + txq->gdma_txq_id); + } +break ; } -break ; } - } -for (i =0 ; i < apc->num_queues; i++) { - txq = &apc->tx_qp[i].txq; -while ((skb =skb_dequeue (&txq->pending_skbs))) { -mana_unmap_skb (skb, apc); -dev_kfree_skb_any (skb); +for (i =0 ; i < apc->num_queues; i++) { + txq = &apc->tx_qp[i].txq; +while ((skb =skb_dequeue (&txq->pending_skbs))) { +mana_unmap_skb (skb, apc); +dev_kfree_skb_any (skb); + } +atomic_set (&txq->pending_sends,0 ); } -atomic_set (&txq->pending_sends,0 ); } +/* We're 100% sure the queues can no longer be woken up, because * we're sure now mana_poll_tx_cq() can't be running. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 74/307 net/sched: fix packet loop on netem when duplicate is on
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 9552b11e3edabc97cfcd9f29103d5afbce7ae183 ]
When netem duplicates a packet it re-enqueues the copy at the root qdisc. If another netem sits in the tree the copy can be duplicated again, recursing until the stack or memory is exhausted.
The original duplication guard temporarily zeroed q->duplicate around the re-enqueue, but that does not cover all cases because it is per-qdisc state shared across all concurrent enqueue paths and is not safe without additional locking.
Use the skb tc_depth field introduced in an earlier patch:
- increment it on the duplicate before re-enqueue
- skip duplication for any skb whose tc_depth is already non-zero.
This marks the packet itself rather than mutating qdisc state, therefore it is safe regardless of tree topology or concurrency.
--- net/sched/sch_netem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/sched/sch_netem.c +3 -4
@@ -459,7 +459,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, skb->prev =NULL ;/* Random duplication */ -if (q->duplicate && q->duplicate >=get_crandom (&q->dup_cor, &q->prng)) +if (q->duplicate && skb->tc_depth ==0 && + q->duplicate >=get_crandom (&q->dup_cor, &q->prng)) ++count;/* Drop packet? */
@@ -538,11 +539,9 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,*/ if (skb2) {struct Qdisc *rootq =qdisc_root_bh (sch); -u32 dupsave = q->duplicate;/* prevent duplicating a dup... */ - q->duplicate =0 ; + skb2->tc_depth++;/* prevent duplicating a dup... */ rootq->enqueue (skb2, rootq, to_free); - q->duplicate = dupsave; skb2 =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 89/315 net: mana: Skip redundant detach on already-detached port
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dipayaan Roy <[email protected]>
[ Upstream commit 5b05aa36ee24297d7296ca58dfd8c448d0e4cda3 ]
When mana_per_port_queue_reset_work_handler() runs after a previous detach succeeded but attach failed, the port is left in a detached state with apc->tx_qp and apc->rxqs already freed. Calling mana_detach() again unconditionally leads to NULL pointer dereferences during queue teardown.
Add an early exit in mana_detach() when the port is already in detached state (!netif_device_present) for non-close callers, making it safe to call idempotently. This allows the queue reset handler and other recovery paths to simply retry mana_attach() without redundant teardown.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/microsoft/mana/mana_en.c +6 -0
@@ -3322,6 +3322,12 @@ int mana_detach(struct net_device *ndev, bool from_close)ASSERT_RTNL (); +/* If already detached (indicates detach succeeded but attach failed +* previously). Now skip mana detach and just retry mana_attach. +*/ +if (!from_close && !netif_device_present (ndev)) +return 0 ; + apc->port_st_save = apc->port_is_up; apc->port_is_up = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 75/307 net/sched: act_mirred: Move the recursion counter struct netdev_xmit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 7fe70c06a182a140be9996b02256d907e114479a ]
mirred_nest_level is a per-CPU variable and relies on disabled BH for its locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this data structure requires explicit locking.
Move mirred_nest_level to struct netdev_xmit as u8, provide wrappers.
Stable-dep-of: e80ad525fc7e ("net/sched: act_mirred: Fix return code in early mirred redirect error paths")
--- include/linux/netdevice_xmit.h | 3 +++ net/sched/act_mirred.c | 28 +++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-)
include/linux/netdevice_xmit.h +3 -0
@@ -8,6 +8,9 @@ struct netdev_xmit {#ifdef CONFIG_NET_EGRESS u8 skip_txqueue;#endif +#if IS_ENABLED (CONFIG_NET_ACT_MIRRED ) +u8 sched_mirred_nest; +#endif };#endif
net/sched/act_mirred.c +25 -3
@@ -30,7 +30,29 @@ static LIST_HEAD(mirred_list);static DEFINE_SPINLOCK (mirred_list_lock);#define MIRRED_NEST_LIMIT 4 -static DEFINE_PER_CPU(unsigned int, mirred_nest_level); + +#ifndef CONFIG_PREEMPT_RT +static u8 tcf_mirred_nest_level_inc_return (void ) +{ +return __this_cpu_inc_return (softnet_data.xmit.sched_mirred_nest); +} + +static void tcf_mirred_nest_level_dec (void ) +{ +__this_cpu_dec (softnet_data.xmit.sched_mirred_nest); +} + +#else +static u8 tcf_mirred_nest_level_inc_return (void ) +{ +return current->net_xmit.sched_mirred_nest++; +} + +static void tcf_mirred_nest_level_dec (void ) +{ + current->net_xmit.sched_mirred_nest--; +} +#endif static bool tcf_mirred_is_act_redirect (int action) {
@@ -423,7 +445,7 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,int m_eaction;u32 blockid; - nest_level =__this_cpu_inc_return (mirred_nest_level); + nest_level =tcf_mirred_nest_level_inc_return ();if (unlikely (nest_level >MIRRED_NEST_LIMIT )) {net_warn_ratelimited ("Packet exceeded mirred recursion limit on dev %s\n" ,netdev_name (skb->dev));
@@ -454,7 +476,7 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, retval); dec_nest_level: -__this_cpu_dec (mirred_nest_level); +tcf_mirred_nest_level_dec ();return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 90/315 sctp: fix race between sctp_wait_for_connect and peeloff
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenghang Xiao <[email protected]>
[ Upstream commit f14fe6395a8b3d961a61e138ad7b36ba3626dd4e ]
sctp_wait_for_connect() drops and re-acquires the socket lock while waiting for the association to reach ESTABLISHED state. During this window, another thread can peeloff the association to a new socket via getsockopt(SCTP_SOCKOPT_PEELOFF), changing asoc->base.sk. After re-acquiring the old socket lock, sctp_wait_for_connect() returns success without noticing the migration — the caller then accesses the association under the wrong lock in sctp_datamsg_from_user().
Add the same sk != asoc->base.sk check that sctp_wait_for_sndbuf() already has, returning an error if the association was migrated while we slept.
--- net/sctp/socket.c | 2 ++ 1 file changed, 2 insertions(+)
net/sctp/socket.c +2 -0
@@ -9350,6 +9350,8 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)release_sock (sk); current_timeo =schedule_timeout (current_timeo);lock_sock (sk); +if (sk != asoc->base.sk) + goto do_error; *timeo_p = current_timeo; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 76/307 net/sched: act_mirred: add loop detection
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit fe946a751d9b52b7c45ca34899723b314b79b249 ]
Commit 0f022d32c3ec ("net/sched: Fix mirred deadlock on device recursion") added code in the fast path, even when act_mirred is not used.
Prepare its revert by implementing loop detection in act_mirred.
Adds an array of device pointers in struct netdev_xmit.
tcf_mirred_is_act_redirect() can detect if the array already contains the target device.
Stable-dep-of: e80ad525fc7e ("net/sched: act_mirred: Fix return code in early mirred redirect error paths")
--- include/linux/netdevice_xmit.h | 9 ++++- net/sched/act_mirred.c | 62 +++++++++++++--------------------- 2 files changed, 31 insertions(+), 40 deletions(-)
include/linux/netdevice_xmit.h +8 -1
@@ -2,6 +2,12 @@ #ifndef _LINUX_NETDEVICE_XMIT_H #define _LINUX_NETDEVICE_XMIT_H +#if IS_ENABLED(CONFIG_NET_ACT_MIRRED) +#define MIRRED_NEST_LIMIT 4 +#endif + +struct net_device; + struct netdev_xmit { u16 recursion; u8 more;
@@ -9,7 +15,8 @@ struct netdev_xmit {u8 skip_txqueue;#endif #if IS_ENABLED (CONFIG_NET_ACT_MIRRED ) -u8 sched_mirred_nest; +u8 sched_mirred_nest; +struct net_device *sched_mirred_dev[MIRRED_NEST_LIMIT ];#endif };
net/sched/act_mirred.c +23 -39
98 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 91/315 vsock/virtio: bind uarg before filling zerocopy skb
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingguo Tan <[email protected]>
[ Upstream commit 1e584c304cfb94a759417130b1fc6d30b30c4cce ]
virtio_transport_send_pkt_info() allocates or reuses the zerocopy uarg before entering the send loop, but virtio_transport_alloc_skb() still fills the skb before it inherits that uarg. When fixed-buffer vectored zerocopy hits MAX_SKB_FRAGS, io_sg_from_iter() may partially attach managed frags and return -EMSGSIZE. The rollback path call kfree_skb() to free an skb that carries SKBFL_MANAGED_FRAG_REFS but no uarg, so skb_release_data() falls through to ordinary frag unref.
Pass the uarg into virtio_transport_alloc_skb() and bind it immediately before virtio_transport_fill_skb(). This keeps control or no-payload skbs untouched while ensuring success and rollback share one lifetime rule.
--- net/vmw_vsock/virtio_transport_common.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/vmw_vsock/virtio_transport_common.c +9 -3
@@ -207,6 +207,7 @@ static u16 virtio_transport_get_type(struct sock *sk) static struct sk_buff *virtio_transport_alloc_skb(struct virtio_vsock_pkt_info *info, size_t payload_len, bool zcopy, + struct ubuf_info *uarg, u32 src_cid, u32 src_port, u32 dst_cid,
@@ -247,6 +248,12 @@ static struct sk_buff *virtio_transport_alloc_skb(struct virtio_vsock_pkt_info *if (info->msg && payload_len >0 ) {int err; +/* Bind the zerocopy lifetime before filling frags so error +* rollback frees managed fixed-buffer pages through +* the uarg-aware path. +*/ +skb_zcopy_set (skb, uarg,NULL ); + err =virtio_transport_fill_skb (skb, info, payload_len, zcopy);if (err) goto out;
@@ -366,6 +373,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, skb_len =min (max_skb_len, rest_len); skb =virtio_transport_alloc_skb (info, skb_len, can_zcopy, + uarg, src_cid, src_port, dst_cid, dst_port);if (!skb) {
@@ -373,8 +381,6 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,break ; } -skb_zcopy_set (skb, uarg,NULL ); -virtio_transport_inc_tx_pkt (vvs, skb); ret = t_ops->send_pkt (skb);
@@ -1161,7 +1167,7 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t,if (!t)return -ENOTCONN ; - reply = virtio_transport_alloc_skb(&info, 0, false, + reply = virtio_transport_alloc_skb(&info, 0, false, NULL, le64_to_cpu(hdr->dst_cid), le32_to_cpu(hdr->dst_port), le64_to_cpu(hdr->src_cid),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 77/307 net: Introduce skb tc depth field to track packet loops
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 98b34f3e8c3492cfc89ff943c9d92b4d52863d1d ]
Add a 2-bit per-skb tc depth field to track packet loops across the stack.
The previous per-CPU loop counters like MIRRED_NEST_LIMIT assume a single call stack and lose state in two cases:
1) When a packet is queued and reprocessed later (e.g., egress->ingress via backlog), the per-cpu state is gone by the time it is dequeued.
2) With XPS/RPS a packet may arrive on one CPU and be processed on another.
A per-skb field solves both by travelling with the packet itself.
The field fits in existing padding, using 2 bits that were previously a hole:
pahole before(-) and after (+) diff looks like:
__u8 slow_gro:1; /* 132: 3 1 */ __u8 csum_not_inet:1; /* 132: 4 1 */ __u8 unreadable:1; /* 132: 5 1 */ + __u8 tc_depth:2; /* 132: 6 1 */
- /* XXX 2 bits hole, try to pack */
/* XXX 1 byte hole, try to pack */
__u16 tc_index; /* 134 2 */
There used to be a ttl field which was removed as part of tc_verd in commit aec745e2c520 ("net-tc: remove unused tc_verd fields"). It was already unused by that time, due to remove earlier in commit c19ae86a510c ("tc: remove unused redirect ttl").
The first user of this field is netem, which increments tc_depth on duplicated packets before re-enqueueing them at the root qdisc. On re-entry, netem skips duplication for any skb with tc_depth already set, bounding recursion to a single level regardless of tree topology.
The other user is mirred which increments it on each pass and limits to depth to MIRRED_DEFER_LIMIT (3).
The new field was called ttl in earlier versions of this patch but renamed to tc_depth to avoid confusion with IP ttl.
Note (looking at you Sashiko! Dont ignore me and continue bringing this up):
1. Since both mirred and netem utilize the same 2-bit tc_depth field it is possible when netem and mirred are used together that netem qdisc to skip the duplication step. This is a known trade-off, as a 2-bit field cannot independently track both features' recursion depths and it is not considered sane to have a setup that addresses both features on at the same time.
2. skb_scrub_packet does not clear tc_depth. This means a packet's loop history is preserved even across namespaces. While this might be restrictive for some topologies, it is also design intent to provide robustness against loops across namespaces.
Stable-dep-of: e80ad525fc7e ("net/sched: act_mirred: Fix return code in early mirred redirect error paths")
--- include/linux/skbuff.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/skbuff.h +2 -0
@@ -802,6 +802,7 @@ enum skb_tstamp_type {* @_sk_redir: socket redirection information for skmsg * @_nfct: Associated connection, if any (with nfctinfo bits) * @skb_iif: ifindex of device we arrived on +* @tc_depth: counter for packet duplication * @tc_index: Traffic control index * @hash: the packet hash * @queue_mapping: Queue mapping for multiqueue devices
@@ -1011,6 +1012,7 @@ struct sk_buff { __u8 csum_not_inet:1;#endif __u8 unreadable:1; + __u8 tc_depth:2;#if defined(CONFIG_NET_SCHED ) || defined(CONFIG_NET_XGRESS )__u16 tc_index;/* traffic control index */ #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 92/315 ipv6: fix possible infinite loop in rt6_fill_node()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 9f72412bcf60144f252b0d6205106abf14344abc ]
Sashiko reported this issue [1]. Apply the same fix as
commit f8d8ce1b515a ("ipv6: fix possible infinite loop in fib6_info_uses_dev()").
Writers holding tb6_lock can list_del_rcu(&rt->fib6_siblings) without waiting for RCU readers; rt->fib6_siblings.next then still points into the old ring and this softirq-side walker never reaches &rt->fib6_siblings, causing a CPU stall. fib6_del_route() always WRITE_ONCE()s rt->fib6_nsiblings to 0 before list_del_rcu(), so an inside-loop check is a reliable detach signal.
[1] https://sashiko.dev/#/patchset/20260526020227.4857-1-jiayuan.chen%40linux.dev
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/route.c +2 -0
@@ -5892,6 +5892,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, goto nla_put_failure; } +if (!READ_ONCE (rt->fib6_nsiblings)) +break ; }rcu_read_unlock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 78/307 net/sched: Fix ethx:ingress -> ethy:egress -> ethx:ingress mirred loop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit db875221ab08d213a83bf30196ae8b64d55a3403 ]
When mirred redirects to ingress (from either ingress or egress) the loop state from sched_mirred_dev array dev is lost because of 1) the packet deferral into the backlog and 2) the fact the sched_mirred_dev array is cleared. In such cases, if there was a loop we won't discover it.
Here's a simple test to reproduce:
ip a add dev port0 10.10.10.11/24
tc qdisc add dev port0 clsact
tc filter add dev port0 egress protocol ip \
prio 10 matchall action mirred ingress redirect dev port1
tc qdisc add dev port1 clsact
tc filter add dev port1 ingress protocol ip \
prio 10 matchall action mirred egress redirect dev port0
ping -c 1 -W0.01 10.10.10.10
Stable-dep-of: e80ad525fc7e ("net/sched: act_mirred: Fix return code in early mirred redirect error paths")
--- net/sched/act_mirred.c | 47 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-)
net/sched/act_mirred.c +30 -17
@@ -26,6 +26,10 @@#include <net/tc_act/tc_mirred.h> #include <net/tc_wrapper.h> +#define MIRRED_DEFER_LIMIT 3 +_Static_assert (MIRRED_DEFER_LIMIT <=3 , +"MIRRED_DEFER_LIMIT exceeds tc_depth bitfield width" ); +static LIST_HEAD (mirred_list);static DEFINE_SPINLOCK (mirred_list_lock);
@@ -234,12 +238,15 @@ tcf_mirred_forward(bool at_ingress, bool want_ingress, struct sk_buff *skb) {int err; -if (!want_ingress) +if (!want_ingress) { err =tcf_dev_queue_xmit (skb, dev_queue_xmit); -else if (!at_ingress) - err =netif_rx (skb); -else - err =netif_receive_skb (skb); + }else { + skb->tc_depth++; +if (!at_ingress) + err =netif_rx (skb); +else + err =netif_receive_skb (skb); + }return err; }
@@ -417,6 +424,7 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,struct netdev_xmit *xmit;bool m_mac_header_xmit;struct net_device *dev; +bool want_ingress;int i, m_eaction;u32 blockid;
@@ -425,7 +433,8 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,#else xmit =this_cpu_ptr (&softnet_data.xmit);#endif -if (unlikely (xmit->sched_mirred_nest >=MIRRED_NEST_LIMIT )) { +if (unlikely (xmit->sched_mirred_nest >=MIRRED_NEST_LIMIT || + skb->tc_depth >=MIRRED_DEFER_LIMIT )) {net_warn_ratelimited ("Packet exceeded mirred recursion limit on dev %s\n" ,netdev_name (skb->dev));return TC_ACT_SHOT ;
@@ -444,23 +453,27 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,tcf_action_inc_overlimit_qstats (&m->common);return retval; } -for (i =0 ; i < xmit->sched_mirred_nest; i++) { -if (xmit->sched_mirred_dev[i] != dev) -continue ; -pr_notice_once ("tc mirred: loop on device %s\n" , -netdev_name (dev)); -tcf_action_inc_overlimit_qstats (&m->common); -return retval; - } - xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = dev; + m_eaction =READ_ONCE (m->tcfm_eaction); + want_ingress =tcf_mirred_act_wants_ingress (m_eaction); +if (!want_ingress) { +for (i =0 ; i < xmit->sched_mirred_nest; i++) { +if (xmit->sched_mirred_dev[i] != dev) +continue ; +pr_notice_once ("tc mirred: loop on device %s\n" , +netdev_name (dev)); +tcf_action_inc_overlimit_qstats (&m->common); +return retval; + } + xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = dev; + } m_mac_header_xmit =READ_ONCE (m->tcfm_mac_header_xmit); - m_eaction =READ_ONCE (m->tcfm_eaction); retval =tcf_mirred_to_dev (skb, m, dev, m_mac_header_xmit, m_eaction, retval); - xmit->sched_mirred_nest--; +if (!want_ingress) + xmit->sched_mirred_nest--;return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 66/307 ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 7281b096b072f6c6e30420e3467d738f2e4c4b57 ]
ethnl_update_profile() walks the ETHTOOL_A_PROFILE_IRQ_MODERATION nest list with an index 'i' and writes new_profile[i++] without bounding i. The destination is kmemdup()'d at NET_DIM_PARAMS_NUM_PROFILES entries (5), but the Netlink nest count is entirely user-controlled. Netlink policies do not have support for constraining the number of nested entries (or number of multi-attr entries).
--- net/ethtool/coalesce.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ethtool/coalesce.c +6 -0
@@ -463,6 +463,12 @@ static int ethnl_update_profile(struct net_device *dev,nla_for_each_nested_type (nest,ETHTOOL_A_PROFILE_IRQ_MODERATION , nests, rem) { +if (i >=NET_DIM_PARAMS_NUM_PROFILES ) { +NL_SET_BAD_ATTR (extack, nest); + ret = -E2BIG ; + goto err_out; + } + ret =nla_parse_nested (tb, len_irq_moder -1 , nest, coalesce_irq_moderation_policy, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 93/315 ipv6: fix possible infinite loop in fib6_select_path()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 9c7da87c2dc860bb17ca1ece942495d28b1ce3b9 ]
Found while auditing the same pattern Sashiko reported in rt6_fill_node() [1]. Apply the same fix as
commit f8d8ce1b515a ("ipv6: fix possible infinite loop in fib6_info_uses_dev()").
Writers holding tb6_lock can list_del_rcu(&first->fib6_siblings) without waiting for RCU readers; first->fib6_siblings.next then still points into the old ring and this softirq-side walker never reaches &first->fib6_siblings as its terminator. fib6_purge_rt() always WRITE_ONCE()s first->fib6_nsiblings to 0 before list_del_rcu(), so an inside-loop check is a reliable detach signal.
[1] https://sashiko.dev/#/patchset/20260526020227.4857-1-jiayuan.chen%40linux.dev
--- net/ipv6/route.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/route.c +3 -0
@@ -481,6 +481,9 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,const struct fib6_nh *nh = sibling->fib6_nh;int nh_upper_bound; +if (!READ_ONCE (first->fib6_nsiblings)) +break ; + nh_upper_bound =atomic_read (&nh->fib_nh_upper_bound);if (hash > nh_upper_bound)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 79/307 net/sched: act_mirred: Fix return code in early mirred redirect error paths
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit e80ad525fc7e8c933ad78478c5dda286cfd55c60 ]
Since retval is set as TC_ACT_STOLEN in the mirred redirect case, returning retval in cases where redirect failed will make the callers not register the skb as being dropped.
Fix this by returning TC_ACT_SHOT instead in such scenarios.
--- net/sched/act_mirred.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/sched/act_mirred.c +13 -5
@@ -363,7 +363,8 @@ static int tcf_blockcast_redir(struct sk_buff *skb, struct tcf_mirred *m,dev_is_mac_header_xmit (dev_prev), m_eaction, retval); -return retval; +/* If the packet wasn't redirected, we have to register as a drop */ +return TC_ACT_SHOT ; } static int tcf_blockcast_mirror(struct sk_buff *skb, struct tcf_mirred *m,
@@ -403,7 +404,7 @@ static int tcf_blockcast(struct sk_buff *skb, struct tcf_mirred *m, block =tcf_block_lookup (dev_net (skb->dev), blockid);if (!block ||xa_empty (&block->ports)) {tcf_action_inc_overlimit_qstats (&m->common); -return retval; +return is_redirect ?TC_ACT_SHOT : retval; }if (is_redirect)
@@ -421,8 +422,8 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, {struct tcf_mirred *m =to_mirred (a);int retval =READ_ONCE (m->tcf_action); +bool m_mac_header_xmit, is_redirect;struct netdev_xmit *xmit; -bool m_mac_header_xmit;struct net_device *dev;bool want_ingress;int i, m_eaction;
@@ -447,11 +448,13 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,if (blockid)return tcf_blockcast (skb, m, blockid, res, retval); + is_redirect =tcf_mirred_is_act_redirect (m_eaction); + dev =rcu_dereference_bh (m->tcfm_dev);if (unlikely (!dev)) {pr_notice_once ("tc mirred: target device is gone\n" );tcf_action_inc_overlimit_qstats (&m->common); -return retval; + goto err_out; } m_eaction =READ_ONCE (m->tcfm_eaction);
@@ -463,7 +466,7 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,pr_notice_once ("tc mirred: loop on device %s\n" ,netdev_name (dev));tcf_action_inc_overlimit_qstats (&m->common); -return retval; + goto err_out; } xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = dev; }
@@ -476,6 +479,11 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, xmit->sched_mirred_nest--;return retval; + +err_out: +if (is_redirect) + retval =TC_ACT_SHOT ; +return retval; } static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 94/315 net: skbuff: fix pskb_carve leaking zcopy pages
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit ff6e798c2eac3ebd0501ad7e796f583fab928de8 ]
When SKBFL_MANAGED_FRAG_REFS is set, frag pages are not refcounted but their lifetime is controlled by the attached ubuf_info. To make a copy of the skb_shared_info, we either should clear the flag and reference the frags, or keep the flag and have frags unreferenced.
pskb_carve_inside_header() and pskb_carve_inside_nonlinear() don't follow the rule and thus can leak page references. Let's clear SKBFL_MANAGED_FRAG_REFS from the original skb to fix it. It's the simplest way to address it, but there are more performant ways to do that if it ever becomes a problem.
--- net/core/skbuff.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/core/skbuff.c +10 -0
@@ -6772,6 +6772,11 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off,skb_copy_from_linear_data_offset (skb, off, data, new_hlen); skb->len -= off; +/* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it +* while refcounting frags below. +*/ +skb_zcopy_downgrade_managed (skb); + memcpy((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info,
@@ -6883,6 +6888,11 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,return -ENOMEM ; size =SKB_WITH_OVERHEAD (size); +/* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it +* while refcounting frags below. +*/ +skb_zcopy_downgrade_managed (skb); +memcpy ((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0]));if (skb_orphan_frags (skb, gfp_mask)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 80/307 net/handshake: Use spin_lock_bh for hn_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit cc993e0927ec8bd98ea33377ada03295fcda0f24 ]
nvmet_tcp_state_change(), a socket callback that runs in BH context, can reach handshake_req_cancel() via nvmet_tcp_schedule_release_queue() and tls_handshake_cancel(). handshake_req_cancel() acquires hn->hn_lock with plain spin_lock(). If a process-context thread on the same CPU holds hn->hn_lock when a softirq invokes the cancel path, the lock attempt deadlocks. This is the only caller that invokes tls_handshake_cancel() from BH context; every other consumer calls it from process context.
Deferring the cancel to process context in the NVMe target is not
straightforward: nvmet_tcp_schedule_release_queue() must call tls_handshake_cancel() atomically with its state transition to DISCONNECTING. If the cancel were deferred, the handshake completion callback could fire in the window before the cancel runs, observe the unexpected state, and return without dropping its kref on the queue. Reworking that interlock is considerably more invasive than hardening the handshake lock. Convert all hn->hn_lock acquisitions from spin_lock/spin_unlock to spin_lock_bh/spin_unlock_bh so the lock is never taken with softirqs enabled.
--- net/handshake/netlink.c | 4 ++-- net/handshake/request.c | 14 +++++++------- net/handshake/tlshd.c | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-)
net/handshake/netlink.c +2 -2
@@ -203,10 +203,10 @@ static void __net_exit handshake_net_exit(struct net *net)* accepted and are in progress will be destroyed when * the socket is closed. */ -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);set_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags);list_splice_init (&requests, &hn->hn_requests); -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);while (!list_empty (&requests)) { req = list_first_entry(&requests, struct handshake_req, hr_list);
net/handshake/request.c +7 -7
@@ -168,12 +168,12 @@ static bool remove_pending(struct handshake_net *hn, struct handshake_req *req) {bool ret = false; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);if (!list_empty (&req->hr_list)) {__remove_pending_locked (hn, req); ret = true; } -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);return ret; }
@@ -183,7 +183,7 @@ struct handshake_req *handshake_req_next(struct handshake_net *hn, int class)struct handshake_req *req, *pos; req =NULL ; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock);list_for_each_entry (pos, &hn->hn_requests, hr_list) {if (pos->hr_proto->hp_handler_class != class)continue ;
@@ -191,7 +191,7 @@ struct handshake_req *handshake_req_next(struct handshake_net *hn, int class) req = pos;break ; } -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock);return req; }
@@ -250,7 +250,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,if (READ_ONCE (hn->hn_pending) >= hn->hn_pending_max) goto out_err; -spin_lock (&hn->hn_lock); +spin_lock_bh (&hn->hn_lock); ret = -EOPNOTSUPP ;if (test_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags)) goto out_unlock;
@@ -259,7 +259,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, goto out_unlock;if (!__add_pending_locked (hn, req)) goto out_unlock; -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock); ret =handshake_genl_notify (net, req->hr_proto, flags);if (ret) {
@@ -275,7 +275,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,return 0 ; out_unlock: -spin_unlock (&hn->hn_lock); +spin_unlock_bh (&hn->hn_lock); out_err:/* Restore original destructor so socket teardown still runs on failure */ req->hr_sk->sk_destruct = req->hr_odestruct;
net/handshake/tlshd.c +2 -0
@@ -419,6 +419,8 @@ EXPORT_SYMBOL(tls_server_hello_psk);* Request cancellation races with request completion. To determine * who won, callers examine the return value from this function. * +* Context: May be called from process or softirq context. +* * Return values: * %true - Uncompleted handshake request was canceled * %false - Handshake request already completed or not found
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 95/315 media: rc: fix race between unregister and urb/irq callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit dccc0c3ddf8f16071736f98a7d6dd46a2d43e037 ]
Some rc device drivers have a race condition between rc_unregister_device() and irq or urb callbacks. This is because rc_unregister_device() does two things, it marks the device as unregistered so no new commands can be issued and then it calls rc_free_device(). This means the driver has no chance to cancel any pending urb callbacks or interrupts after the device has been marked as unregistered. Those callbacks may access struct rc_dev or its members (e.g. struct ir_raw_event_ctrl), which have been freed by rc_free_device().
This change removes the implicit call to rc_free_device() from rc_unregister_device(). This means that device drivers can call rc_unregister_device() in their remove or disconnect function, then cancel all the urbs and interrupts before explicitly calling rc_free_device().
Note this is an alternative fix for an issue found by Haotian Zhang, see the Closes: tags.
Stable-dep-of: 646ebdd31058 ("media: rc: ttusbir: fix inverted error logic")
--- drivers/gpu/drm/bridge/sil-sii8620.c | 1 + drivers/hid/hid-picolcd_cir.c | 1 + drivers/media/cec/core/cec-core.c | 2 +- drivers/media/common/siano/smsir.c | 1 + drivers/media/i2c/ir-kbd-i2c.c | 2 ++ drivers/media/pci/bt8xx/bttv-input.c | 3 ++- drivers/media/pci/cx23885/cx23885-input.c | 1 + drivers/media/pci/cx88/cx88-input.c | 3 ++- drivers/media/pci/dm1105/dm1105.c | 1 + drivers/media/pci/mantis/mantis_input.c | 1 + drivers/media/pci/saa7134/saa7134-input.c | 1 + drivers/media/pci/smipcie/smipcie-ir.c | 1 + drivers/media/pci/ttpci/budget-ci.c | 1 + drivers/media/rc/ati_remote.c | 6 +++--- drivers/media/rc/ene_ir.c | 2 +- drivers/media/rc/fintek-cir.c | 3 ++- drivers/media/rc/igorplugusb.c | 1 + drivers/media/rc/iguanair.c | 1 + drivers/media/rc/img-ir/img-ir-hw.c | 3 ++- drivers/media/rc/img-ir/img-ir-raw.c | 3 ++- drivers/media/rc/imon.c | 3 ++- drivers/media/rc/ir-hix5hd2.c | 2 +- drivers/media/rc/ir_toy.c | 1 + drivers/media/rc/ite-cir.c | 2 +- drivers/media/rc/mceusb.c | 1 + drivers/media/rc/rc-ir-raw.c | 5 ----- drivers/media/rc/rc-loopback.c | 1 + drivers/media/rc/rc-main.c | 6 +----- drivers/media/rc/redrat3.c | 4 +++- drivers/media/rc/st_rc.c | 2 +- drivers/media/rc/streamzap.c | 7 ++++--- drivers/media/rc/sunxi-cir.c | 1 + drivers/media/rc/ttusbir.c | 2 +- drivers/media/rc/winbond-cir.c | 2 +- drivers/media/rc/xbox_remote.c | 5 +++-- drivers/media/usb/au0828/au0828-input.c | 1 + drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 1 + drivers/media/usb/dvb-usb/dvb-usb-remote.c | 6 ++++-- drivers/media/usb/em28xx/em28xx-input.c | 1 + drivers/staging/media/av7110/av7110_ir.c | 1 + include/media/rc-core.h | 2 -- 41 files changed, 58 insertions(+), 36 deletions(-)
drivers/gpu/drm/bridge/sil-sii8620.c +1 -0
@@ -2221,6 +2221,7 @@ static void sii8620_detach(struct drm_bridge *bridge)return ;rc_unregister_device (ctx->rc_dev); +rc_free_device (ctx->rc_dev); } static int sii8620_is_packing_required(struct sii8620 *ctx,
drivers/hid/hid-picolcd_cir.c +1 -0
@@ -134,5 +134,6 @@ void picolcd_exit_cir(struct picolcd_data *data) data->rc_dev =NULL ;rc_unregister_device (rdev); +rc_free_device (rdev); }
drivers/media/cec/core/cec-core.c +1 -1
@@ -338,8 +338,8 @@ int cec_register_adapter(struct cec_adapter *adap, res =cec_devnode_register (&adap->devnode, adap->owner);if (res) {#ifdef CONFIG_MEDIA_CEC_RC -/* Note: rc_unregister also calls rc_free */ rc_unregister_device (adap->rc); +rc_free_device (adap->rc); adap->rc =NULL ;#endif return res;
drivers/media/common/siano/smsir.c +1 -0
@@ -92,6 +92,7 @@ int sms_ir_init(struct smscore_device_t *coredev)void sms_ir_exit (struct smscore_device_t *coredev) {rc_unregister_device (coredev->ir.dev); +rc_free_device (coredev->ir.dev);pr_debug ("\n" ); }
drivers/media/i2c/ir-kbd-i2c.c +2 -0
@@ -355,6 +355,7 @@ static void ir_work(struct work_struct *work)mutex_unlock (&ir->lock);if (rc == -ENODEV ) {rc_unregister_device (ir->rc); +rc_free_device (ir->rc); ir->rc =NULL ;return ; }
@@ -972,6 +973,7 @@ static void ir_remove(struct i2c_client *client)i2c_unregister_device (ir->tx_c);rc_unregister_device (ir->rc); +rc_free_device (ir->rc); }static const struct i2c_device_id ir_kbd_id[] = {
drivers/media/pci/bt8xx/bttv-input.c +2 -1
@@ -572,8 +572,9 @@ void bttv_input_fini(struct bttv *btv)if (btv->remote ==NULL )return ; -bttv_ir_stop (btv);rc_unregister_device (btv->remote->dev); +bttv_ir_stop (btv); +rc_free_device (btv->remote->dev);kfree (btv->remote); btv->remote =NULL ; }
drivers/media/pci/cx23885/cx23885-input.c +1 -0
@@ -402,6 +402,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)if (dev->kernel_ir ==NULL )return ;rc_unregister_device (dev->kernel_ir->rc); +rc_free_device (dev->kernel_ir->rc);kfree (dev->kernel_ir->phys);kfree (dev->kernel_ir->name);kfree (dev->kernel_ir);
drivers/media/pci/cx88/cx88-input.c +2 -1
@@ -509,8 +509,9 @@ int cx88_ir_fini(struct cx88_core *core)if (!ir)return 0 ; -cx88_ir_stop (core);rc_unregister_device (ir->dev); +cx88_ir_stop (core); +rc_free_device (ir->dev);kfree (ir);/* done */
drivers/media/pci/dm1105/dm1105.c +1 -0
@@ -763,6 +763,7 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)static void dm1105_ir_exit (struct dm1105_dev *dm1105) {rc_unregister_device (dm1105->ir.dev); +rc_free_device (dm1105->ir.dev); }static int dm1105_hw_init (struct dm1105_dev *dev)
drivers/media/pci/mantis/mantis_input.c +1 -0
@@ -72,5 +72,6 @@ EXPORT_SYMBOL_GPL(mantis_input_init);void mantis_input_exit (struct mantis_pci *mantis) {rc_unregister_device (mantis->rc); +rc_free_device (mantis->rc); }EXPORT_SYMBOL_GPL (mantis_input_exit);
drivers/media/pci/saa7134/saa7134-input.c +1 -0
@@ -834,6 +834,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)return ;rc_unregister_device (dev->remote->dev); +rc_free_device (dev->remote->dev);kfree (dev->remote); dev->remote =NULL ; }
drivers/media/pci/smipcie/smipcie-ir.c +1 -0
@@ -181,5 +181,6 @@ void smi_ir_exit(struct smi_dev *dev)rc_unregister_device (rc_dev);smi_ir_stop (ir); +rc_free_device (rc_dev); ir->rc_dev =NULL ; }
drivers/media/pci/ttpci/budget-ci.c +1 -0
@@ -249,6 +249,7 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)cancel_work_sync (&budget_ci->ir.msp430_irq_bh_work);rc_unregister_device (budget_ci->ir.dev); +rc_free_device (budget_ci->ir.dev); }static int ciintf_read_attribute_mem (struct dvb_ca_en50221 *ca,int slot,int address)
drivers/media/rc/ati_remote.c +3 -3
@@ -921,7 +921,6 @@ static int ati_remote_probe(struct usb_interface *interface,input_free_device (input_dev); exit_unregister_device:rc_unregister_device (rc_dev); - rc_dev =NULL ; exit_kill_urbs:usb_kill_urb (ati_remote->irq_urb);usb_kill_urb (ati_remote->out_urb);
@@ -941,18 +940,19 @@ static void ati_remote_disconnect(struct usb_interface *interface)struct ati_remote *ati_remote; ati_remote =usb_get_intfdata (interface); -usb_set_intfdata (interface,NULL );if (!ati_remote) {dev_warn (&interface->dev,"%s - null device?\n" , __func__);return ; } +rc_unregister_device (ati_remote->rdev); +usb_set_intfdata (interface,NULL );usb_kill_urb (ati_remote->irq_urb);usb_kill_urb (ati_remote->out_urb);if (ati_remote->idev)input_unregister_device (ati_remote->idev); -rc_unregister_device (ati_remote->rdev);ati_remote_free_buffers (ati_remote); +rc_free_device (ati_remote->rdev);kfree (ati_remote); }
drivers/media/rc/ene_ir.c +1 -1
@@ -1090,7 +1090,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)release_region (dev->hw_io,ENE_IO_SIZE ); exit_unregister_device:rc_unregister_device (rdev); - rdev =NULL ; exit_free_dev_rdev:rc_free_device (rdev);kfree (dev);
@@ -1110,6 +1109,7 @@ static void ene_remove(struct pnp_dev *pnp_dev)ene_rx_restore_hw_buffer (dev);spin_unlock_irqrestore (&dev->hw_lock, flags); +rc_free_device (dev->rdev);free_irq (dev->irq, dev);release_region (dev->hw_io,ENE_IO_SIZE );kfree (dev);
drivers/media/rc/fintek-cir.c +2 -1
@@ -568,6 +568,7 @@ static void fintek_remove(struct pnp_dev *pdev)struct fintek_dev *fintek =pnp_get_drvdata (pdev);unsigned long flags; +rc_unregister_device (fintek->rdev);spin_lock_irqsave (&fintek->fintek_lock, flags);/* disable CIR */ fintek_disable_cir (fintek);
@@ -580,7 +581,7 @@ static void fintek_remove(struct pnp_dev *pdev)free_irq (fintek->cir_irq, fintek);release_region (fintek->cir_addr, fintek->cir_port_len); -rc_unregister_device (fintek->rdev); +rc_free_device (fintek->rdev);kfree (fintek); }
drivers/media/rc/igorplugusb.c +1 -0
@@ -247,6 +247,7 @@ static void igorplugusb_disconnect(struct usb_interface *intf)usb_set_intfdata (intf,NULL );usb_unpoison_urb (ir->urb);usb_free_urb (ir->urb); +rc_free_device (ir->rc);kfree (ir->buf_in);kfree (ir->request); }
drivers/media/rc/iguanair.c +1 -0
@@ -500,6 +500,7 @@ static void iguanair_disconnect(struct usb_interface *intf)usb_set_intfdata (intf,NULL );usb_kill_urb (ir->urb_in);usb_kill_urb (ir->urb_out); +rc_free_device (ir->rc);usb_free_urb (ir->urb_in);usb_free_urb (ir->urb_out);usb_free_coherent (ir->udev,MAX_IN_PACKET , ir->buf_in, ir->dma_in);
drivers/media/rc/img-ir/img-ir-hw.c +2 -1
@@ -1118,9 +1118,10 @@ void img_ir_remove_hw(struct img_ir_priv *priv)struct rc_dev *rdev = hw->rdev;if (!rdev)return ; +rc_unregister_device (rdev);img_ir_set_decoder (priv,NULL ,0 ); hw->rdev =NULL ; -rc_unregister_device (rdev); +rc_free_device (rdev);#ifdef CONFIG_COMMON_CLK if (!IS_ERR (priv->clk))clk_notifier_unregister (priv->clk, &hw->clk_nb);
drivers/media/rc/img-ir/img-ir-raw.c +2 -1
@@ -136,6 +136,7 @@ void img_ir_remove_raw(struct img_ir_priv *priv)if (!rdev)return ; +rc_unregister_device (rdev);/* switch off and disable raw (edge) interrupts */ spin_lock_irq (&priv->lock); raw->rdev =NULL ;
@@ -145,7 +146,7 @@ void img_ir_remove_raw(struct img_ir_priv *priv)img_ir_write (priv,IMG_IR_IRQ_CLEAR ,IMG_IR_IRQ_EDGE );spin_unlock_irq (&priv->lock); -rc_unregister_device (rdev); +rc_free_device (rdev);timer_delete_sync (&raw->timer); }
drivers/media/rc/imon.c +2 -1
@@ -2541,9 +2541,10 @@ static void imon_disconnect(struct usb_interface *interface)if (ifnum ==0 ) { ictx->dev_present_intf0 = false; +rc_unregister_device (ictx->rdev);usb_kill_urb (ictx->rx_urb_intf0);input_unregister_device (ictx->idev); -rc_unregister_device (ictx->rdev); +rc_free_device (ictx->rdev);if (ictx->display_supported) {if (ictx->display_type ==IMON_DISPLAY_TYPE_LCD )usb_deregister_dev (interface, &imon_lcd_class);
drivers/media/rc/ir-hix5hd2.c +1 -1
@@ -331,7 +331,6 @@ static int hix5hd2_ir_probe(struct platform_device *pdev) regerr:rc_unregister_device (rdev); - rdev =NULL ; clkerr:clk_disable_unprepare (priv->clock); err:
@@ -346,6 +345,7 @@ static void hix5hd2_ir_remove(struct platform_device *pdev)clk_disable_unprepare (priv->clock);rc_unregister_device (priv->rdev); +rc_free_device (priv->rdev); }#ifdef CONFIG_PM_SLEEP
drivers/media/rc/ir_toy.c +1 -0
@@ -536,6 +536,7 @@ static void irtoy_disconnect(struct usb_interface *intf)usb_free_urb (ir->urb_out);usb_kill_urb (ir->urb_in);usb_free_urb (ir->urb_in); +rc_free_device (ir->rc);kfree (ir->in);kfree (ir->out);kfree (ir);
drivers/media/rc/ite-cir.c +1 -1
@@ -1414,7 +1414,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_idrelease_region (itdev->cir_addr, itdev->params->io_region_size); exit_unregister_device:rc_unregister_device (rdev); - rdev =NULL ; exit_free_dev_rdev:rc_free_device (rdev);kfree (itdev);
@@ -1439,6 +1438,7 @@ static void ite_remove(struct pnp_dev *pdev)release_region (dev->cir_addr, dev->params->io_region_size);rc_unregister_device (dev->rdev); +rc_free_device (dev->rdev);kfree (dev); }
drivers/media/rc/mceusb.c +1 -0
@@ -1850,6 +1850,7 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)usb_free_urb (ir->urb_in);usb_free_coherent (dev, ir->len_in, ir->buf_in, ir->dma_in);usb_put_dev (dev); +rc_free_device (ir->rc);kfree (ir); }
drivers/media/rc/rc-ir-raw.c +0 -5
@@ -648,9 +648,6 @@ int ir_raw_event_register(struct rc_dev *dev)void ir_raw_event_free (struct rc_dev *dev) { -if (!dev) -return ; -kfree (dev->raw); dev->raw =NULL ; }
@@ -674,8 +671,6 @@ void ir_raw_event_unregister(struct rc_dev *dev)lirc_bpf_free (dev); -ir_raw_event_free (dev); -/* * A user can be calling bpf(BPF_PROG_{QUERY|ATTACH|DETACH}), so * ensure that the raw member is null on unlock; this is how
drivers/media/rc/rc-loopback.c +1 -0
@@ -263,6 +263,7 @@ static int __init loop_init(void) static void __exit loop_exit(void) {rc_unregister_device (loopdev.dev); +rc_free_device (loopdev.dev); }module_init (loop_init);
drivers/media/rc/rc-main.c +1 -5
@@ -1611,6 +1611,7 @@ static void rc_dev_release(struct device *device) {struct rc_dev *dev =to_rc_dev (device); +ir_raw_event_free (dev);kfree (dev); }
@@ -1773,7 +1774,6 @@ struct rc_dev *devm_rc_allocate_device(struct device *dev, } rc->dev.parent = dev; - rc->managed_alloc = true; *dr = rc;devres_add (dev, dr);
@@ -2042,11 +2042,7 @@ void rc_unregister_device(struct rc_dev *dev)device_del (&dev->dev);ida_free (&rc_ida, dev->minor); - -if (!dev->managed_alloc) -rc_free_device (dev); } -EXPORT_SYMBOL_GPL (rc_unregister_device);/*
drivers/media/rc/redrat3.c +3 -1
@@ -1133,11 +1133,13 @@ static void redrat3_dev_disconnect(struct usb_interface *intf) {struct usb_device *udev =interface_to_usbdev (intf);struct redrat3_dev *rr3 =usb_get_intfdata (intf); +struct rc_dev *rc = rr3->rc;usb_set_intfdata (intf,NULL ); -rc_unregister_device (rr3->rc); +rc_unregister_device (rc);led_classdev_unregister (&rr3->led);redrat3_delete (rr3, udev); +rc_free_device (rc); }static int redrat3_dev_suspend (struct usb_interface *intf,pm_message_t message)
drivers/media/rc/st_rc.c +1 -1
@@ -203,6 +203,7 @@ static void st_rc_remove(struct platform_device *pdev)device_init_wakeup (&pdev->dev, false);clk_disable_unprepare (rc_dev->sys_clock);rc_unregister_device (rc_dev->rdev); +rc_free_device (rc_dev->rdev); }static int st_rc_open (struct rc_dev *rdev)
@@ -334,7 +335,6 @@ static int st_rc_probe(struct platform_device *pdev)return ret; rcerr:rc_unregister_device (rdev); - rdev =NULL ; clkerr:clk_disable_unprepare (rc_dev->sys_clock); err:
drivers/media/rc/streamzap.c +4 -3
@@ -392,15 +392,16 @@ static void streamzap_disconnect(struct usb_interface *interface)struct streamzap_ir *sz =usb_get_intfdata (interface);struct usb_device *usbdev =interface_to_usbdev (interface); -usb_set_intfdata (interface,NULL ); -if (!sz)return ; -usb_kill_urb (sz->urb_in);rc_unregister_device (sz->rdev); +usb_set_intfdata (interface,NULL ); + +usb_kill_urb (sz->urb_in);usb_free_urb (sz->urb_in);usb_free_coherent (usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); +rc_free_device (sz->rdev);kfree (sz); }
drivers/media/rc/sunxi-cir.c +1 -0
@@ -371,6 +371,7 @@ static void sunxi_ir_remove(struct platform_device *pdev)struct sunxi_ir *ir =platform_get_drvdata (pdev);rc_unregister_device (ir->rc); +rc_free_device (ir->rc);sunxi_ir_hw_exit (&pdev->dev); }
drivers/media/rc/ttusbir.c +1 -1
@@ -336,7 +336,6 @@ static int ttusbir_probe(struct usb_interface *intf,return 0 ; out3:rc_unregister_device (rc); - rc =NULL ; out2:led_classdev_unregister (&tt->led); out:
@@ -378,6 +377,7 @@ static void ttusbir_disconnect(struct usb_interface *intf)usb_kill_urb (tt->bulk_urb);usb_free_urb (tt->bulk_urb);kfree (tt->bulk_buffer); +rc_free_device (tt->rc);usb_set_intfdata (intf,NULL );kfree (tt); }
drivers/media/rc/winbond-cir.c +1 -1
@@ -1132,7 +1132,6 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)release_region (data->wbase,WAKEUP_IOMEM_LEN ); exit_unregister_device:rc_unregister_device (data->dev); - data->dev =NULL ; exit_free_rc:rc_free_device (data->dev); exit_unregister_led:
@@ -1163,6 +1162,7 @@ wbcir_remove(struct pnp_dev *device)wbcir_set_bits (data->wbase +WBCIR_REG_WCEIR_EV_EN ,0x00 ,0x07 );rc_unregister_device (data->dev); +rc_free_device (data->dev);led_classdev_unregister (&data->led);
drivers/media/rc/xbox_remote.c +3 -2
@@ -283,14 +283,15 @@ static void xbox_remote_disconnect(struct usb_interface *interface)struct xbox_remote *xbox_remote; xbox_remote =usb_get_intfdata (interface); -usb_set_intfdata (interface,NULL );if (!xbox_remote) {dev_warn (&interface->dev,"%s - null device?\n" , __func__);return ; } -usb_kill_urb (xbox_remote->irq_urb);rc_unregister_device (xbox_remote->rdev); +usb_set_intfdata (interface,NULL ); +usb_kill_urb (xbox_remote->irq_urb); +rc_free_device (xbox_remote->rdev);usb_free_urb (xbox_remote->irq_urb);kfree (xbox_remote->inbuf);kfree (xbox_remote);
drivers/media/usb/au0828/au0828-input.c +1 -0
@@ -357,6 +357,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)return ;rc_unregister_device (ir->rc); +rc_free_device (ir->rc);/* done */ kfree (ir);
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +1 -0
@@ -187,6 +187,7 @@ static int dvb_usbv2_remote_exit(struct dvb_usb_device *d)if (d->rc_dev) {cancel_delayed_work_sync (&d->rc_query_work);rc_unregister_device (d->rc_dev); +rc_free_device (d->rc_dev); d->rc_dev =NULL ; }
drivers/media/usb/dvb-usb/dvb-usb-remote.c +4 -2
@@ -347,10 +347,12 @@ int dvb_usb_remote_exit(struct dvb_usb_device *d) {if (d->state &DVB_USB_STATE_REMOTE ) {cancel_delayed_work_sync (&d->rc_query_work); -if (d->props.rc.mode ==DVB_RC_LEGACY ) +if (d->props.rc.mode ==DVB_RC_LEGACY ) {input_unregister_device (d->input_dev); -else + }else {rc_unregister_device (d->rc_dev); +rc_free_device (d->rc_dev); + } } d->state &= ~DVB_USB_STATE_REMOTE ;return 0 ;
drivers/media/usb/em28xx/em28xx-input.c +1 -0
@@ -853,6 +853,7 @@ static int em28xx_ir_fini(struct em28xx *dev) goto ref_put;rc_unregister_device (ir->rc); +rc_free_device (ir->rc);kfree (ir->i2c_client);
drivers/staging/media/av7110/av7110_ir.c +1 -0
@@ -151,6 +151,7 @@ int av7110_ir_init(struct av7110 *av7110)void av7110_ir_exit (struct av7110 *av7110) {rc_unregister_device (av7110->ir.rcdev); +rc_free_device (av7110->ir.rcdev); }//MODULE_AUTHOR("Holger Waechtler <[email protected]>, Oliver Endriss <[email protected]>");
include/media/rc-core.h +0 -2
@@ -81,7 +81,6 @@ struct lirc_fh {/** * struct rc_dev - represents a remote control device * @dev: driver model's view of this device -* @managed_alloc: devm_rc_allocate_device was used to create rc_dev * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @idle: used to keep track of RX state
@@ -156,7 +155,6 @@ struct lirc_fh {*/ struct rc_dev {struct device dev; -bool managed_alloc;bool registered;bool idle;bool encode_wakeup;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 81/307 nvme-tcp: store negative errno in queue->tls_err
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 9015985b5eb1a90eb86caf5bce1dfcf1aa38f8ad ]
nvme_tcp_tls_done() assigns queue->tls_err in three branches. The ENOKEY lookup failure and the EOPNOTSUPP initializer both store negative errnos. The third branch, reached when the handshake layer reports a non-zero status, stores -status.
The handshake layer delivers status to the consumer callback as a negative errno; the other in-tree consumers -- xs_tls_handshake_done() and the nvmet target callback -- treat their status argument that way. The extra negation in nvme_tcp_tls_done() flips the sign, leaving tls_err as a positive value (for instance, +EIO), which nvme_tcp_start_tls() then returns to its caller.
Drop the extra negation so queue->tls_err uniformly carries a negative errno on failure.
--- drivers/nvme/host/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/tcp.c +1 -1
@@ -1719,7 +1719,7 @@ static void nvme_tcp_tls_done(void *data, int status, key_serial_t pskid) qid, pskid, status);if (status) { - queue->tls_err = -status; + queue->tls_err = status; goto out_complete; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 96/315 media: rc: ttusbir: fix inverted error logic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 646ebdd3105809d84ed04aa9e92e47e89cc44502 ]
We have to report ENOMEM if no buffer is allocated. Typo dropped a "!". Restore it.
--- drivers/media/rc/ttusbir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ttusbir.c +1 -1
@@ -191,7 +191,7 @@ static int ttusbir_probe(struct usb_interface *intf, tt =kzalloc (sizeof (*tt),GFP_KERNEL ); buffer =kzalloc (5 ,GFP_KERNEL ); rc =rc_allocate_device (RC_DRIVER_IR_RAW ); -if (!tt || !rc || buffer) { +if (!tt || !rc || !buffer) { ret = -ENOMEM ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 82/307 net/handshake: Pass negative errno through handshake_complete()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 6b22d433aa13f68e3cd9534ca9a5f4277bfa01c2 ]
handshake_complete() declares status as unsigned int and tls_handshake_done() negates that value (-status) before handing it to the TLS consumer. Consumers match on negative errno constants -- xs_tls_handshake_done() has
switch (status) {
case 0:
case -EACCES:
case -ETIMEDOUT:
lower_transport->xprt_err = status;
break;
default:
lower_transport->xprt_err = -EACCES;
}so the API as designed expects callers to pass positive errno values that the tlshd shim then negates.
Three internal callers in handshake_nl_accept_doit(), the net-exit drain, and a kunit test follow kernel convention and pass negative errnos -- -EIO, -ETIMEDOUT, -ETIMEDOUT. The implicit conversion to unsigned int turns -ETIMEDOUT into 0xFFFFFF92; the subsequent -status in tls_handshake_done() wraps back to 110, the consumer's switch falls through, and the xprt reports -EACCES on what should be -ETIMEDOUT or -EIO.
Fix the API rather than the call sites. The natural kernel convention is negative errno in, negative errno out. Change handshake_complete() and hp_done to take int status, drop the negation in tls_handshake_done(), and negate once in handshake_nl_done_doit() where status arrives from the wire as an unsigned netlink attribute. The three internal callers were already correct under that convention and need no change.
At the same wire boundary, declare MAX_ERRNO as the netlink policy upper bound for HANDSHAKE_A_DONE_STATUS. Attribute validation rejects out-of-range values before handshake_nl_done_doit() runs, and negating a bounded u32 there stays within int range -- closing the UBSAN-visible signed- integer overflow that an unconstrained u32 would invoke.
--- Documentation/netlink/specs/handshake.yaml | 8 ++++++++ net/handshake/genl.c | 3 ++- net/handshake/genl.h | 1 + net/handshake/handshake-test.c | 2 +- net/handshake/handshake.h | 4 ++-- net/handshake/netlink.c | 2 +- net/handshake/request.c | 2 +- net/handshake/tlshd.c | 4 ++-- 8 files changed, 18 insertions(+), 8 deletions(-)
Documentation/netlink/specs/handshake.yaml +8 -0
@@ -12,6 +12,12 @@ protocol: genetlink doc: Netlink protocol to request a transport layer security handshake. definitions: + - + type: const + name: max-errno + value: 4095 + header: linux/err.h + scope: kernel - type: enum name: handler-class
@@ -77,6 +83,8 @@ attribute-sets: - name: status type: u32 + checks: + max: max-errno - name: sockfd type: s32
net/handshake/genl.c +2 -1
@@ -9,6 +9,7 @@#include "genl.h" #include <uapi/linux/handshake.h> +#include <linux/err.h> /* HANDSHAKE_CMD_ACCEPT - do */ static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_ACCEPT_HANDLER_CLASS +1 ] = {
@@ -17,7 +18,7 @@ static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_ACCEPT_HAN/* HANDSHAKE_CMD_DONE - do */ static const struct nla_policy handshake_done_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH +1 ] = { - [HANDSHAKE_A_DONE_STATUS ] = { .type =NLA_U32 , }, + [HANDSHAKE_A_DONE_STATUS ] =NLA_POLICY_MAX (NLA_U32 ,MAX_ERRNO ), [HANDSHAKE_A_DONE_SOCKFD ] = { .type =NLA_S32 , }, [HANDSHAKE_A_DONE_REMOTE_AUTH ] = { .type =NLA_U32 , }, };
net/handshake/genl.h +1 -0
@@ -10,6 +10,7 @@#include <net/genetlink.h> #include <uapi/linux/handshake.h> +#include <linux/err.h> int handshake_nl_accept_doit (struct sk_buff *skb,struct genl_info *info);int handshake_nl_done_doit (struct sk_buff *skb,struct genl_info *info);
net/handshake/handshake-test.c +1 -1
@@ -25,7 +25,7 @@ static int test_accept_func(struct handshake_req *req, struct genl_info *info,return 0 ; } -static void test_done_func (struct handshake_req *req,unsigned int status, +static void test_done_func (struct handshake_req *req,int status,struct genl_info *info) { }
net/handshake/handshake.h +2 -2
@@ -57,7 +57,7 @@ struct handshake_proto {int (*hp_accept)(struct handshake_req *req,struct genl_info *info,int fd);void (*hp_done)(struct handshake_req *req, -unsigned int status, +int status,struct genl_info *info);void (*hp_destroy)(struct handshake_req *req); };
@@ -86,7 +86,7 @@ struct handshake_req *handshake_req_hash_lookup(struct sock *sk);struct handshake_req *handshake_req_next (struct handshake_net *hn,int class);int handshake_req_submit (struct socket *sock,struct handshake_req *req,gfp_t flags); -void handshake_complete (struct handshake_req *req,unsigned int status, +void handshake_complete (struct handshake_req *req,int status,struct genl_info *info);bool handshake_req_cancel (struct sock *sk);
net/handshake/netlink.c +1 -1
@@ -161,7 +161,7 @@ int handshake_nl_done_doit(struct sk_buff *skb, struct genl_info *info) status = -EIO ;if (info->attrs[HANDSHAKE_A_DONE_STATUS ]) - status =nla_get_u32 (info->attrs[HANDSHAKE_A_DONE_STATUS ]); + status = -(int )nla_get_u32 (info->attrs[HANDSHAKE_A_DONE_STATUS ]);handshake_complete (req, status, info);sockfd_put (sock);
net/handshake/request.c +1 -1
@@ -285,7 +285,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, }EXPORT_SYMBOL (handshake_req_submit); -void handshake_complete (struct handshake_req *req,unsigned int status, +void handshake_complete (struct handshake_req *req,int status,struct genl_info *info) {struct sock *sk = req->hr_sk;
net/handshake/tlshd.c +2 -2
@@ -93,7 +93,7 @@ static void tls_handshake_remote_peerids(struct tls_handshake_req *treq,* */ static void tls_handshake_done (struct handshake_req *req, -unsigned int status,struct genl_info *info) +int status,struct genl_info *info) {struct tls_handshake_req *treq =handshake_req_private (req);
@@ -104,7 +104,7 @@ static void tls_handshake_done(struct handshake_req *req,if (!status)set_bit (HANDSHAKE_F_REQ_SESSION , &req->hr_flags); - treq->th_consumer_done (treq->th_consumer_data, -status, + treq->th_consumer_done (treq->th_consumer_data, status, treq->th_peerid[0 ]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 97/315 smb: client: validate the whole DACL before rewriting it in cifsacl
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 0a8cf165566ba55a39fd0f4de172119dd646d39a ]
build_sec_desc() and id_mode_to_cifs_acl() derive a DACL pointer from a server-supplied dacloffset and then use the incoming ACL to rebuild the chmod/chown security descriptor.
The original fix only checked that the struct smb_acl header fits before reading dacl_ptr->size or dacl_ptr->num_aces. That avoids the immediate header-field OOB read, but the rewrite helpers still walk ACEs based on pdacl->num_aces with no structural validation of the incoming DACL body.
A malicious server can return a truncated DACL that still contains a header, claims one or more ACEs, and then drive replace_sids_and_copy_aces() or set_chmod_dacl() past the validated extent while they compare or copy attacker-controlled ACEs.
Factor the DACL structural checks into validate_dacl(), extend them to validate each ACE against the DACL bounds, and use the shared validator before the chmod/chown rebuild paths. parse_dacl() reuses the same validator so the read-side parser and write-side rewrite paths agree on what constitutes a well-formed incoming DACL.
--- fs/smb/client/cifsacl.c | 116 +++++++++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 31 deletions(-)
fs/smb/client/cifsacl.c +85 -31
@@ -757,6 +757,77 @@ static void dump_ace(struct smb_ace *pace, char *end_of_acl) }#endif +static int validate_dacl (struct smb_acl *pdacl,char *end_of_acl) +{ +int i, ace_hdr_size, ace_size, min_ace_size; +u16 dacl_size, num_aces; +char *acl_base, *end_of_dacl; +struct smb_ace *pace; + +if (!pdacl) +return 0 ; + +if (end_of_acl < (char *)pdacl +sizeof (struct smb_acl )) { +cifs_dbg (VFS ,"ACL too small to parse DACL\n" ); +return -EINVAL ; + } + + dacl_size =le16_to_cpu (pdacl->size); +if (dacl_size <sizeof (struct smb_acl ) || + end_of_acl < (char *)pdacl + dacl_size) { +cifs_dbg (VFS ,"ACL too small to parse DACL\n" ); +return -EINVAL ; + } + + num_aces =le16_to_cpu (pdacl->num_aces); +if (!num_aces) +return 0 ; + + ace_hdr_size = offsetof(struct smb_ace , sid) + + offsetof(struct smb_sid , sub_auth); + min_ace_size = ace_hdr_size +sizeof (__le32); +if (num_aces > (dacl_size -sizeof (struct smb_acl )) / min_ace_size) { +cifs_dbg (VFS ,"ACL too small to parse DACL\n" ); +return -EINVAL ; + } + + end_of_dacl = (char *)pdacl + dacl_size; + acl_base = (char *)pdacl; + ace_size =sizeof (struct smb_acl ); + +for (i =0 ; i < num_aces; ++i) { +if (end_of_dacl - acl_base < ace_size) { +cifs_dbg (VFS ,"ACL too small to parse ACE\n" ); +return -EINVAL ; + } + + pace = (struct smb_ace *)(acl_base + ace_size); + acl_base = (char *)pace; + +if (end_of_dacl - acl_base < ace_hdr_size || + pace->sid.num_subauth ==0 || + pace->sid.num_subauth >SID_MAX_SUB_AUTHORITIES ) { +cifs_dbg (VFS ,"ACL too small to parse ACE\n" ); +return -EINVAL ; + } + + ace_size = ace_hdr_size +sizeof (__le32) * pace->sid.num_subauth; +if (end_of_dacl - acl_base < ace_size || +le16_to_cpu (pace->size) < ace_size) { +cifs_dbg (VFS ,"ACL too small to parse ACE\n" ); +return -EINVAL ; + } + + ace_size =le16_to_cpu (pace->size); +if (end_of_dacl - acl_base < ace_size) { +cifs_dbg (VFS ,"ACL too small to parse ACE\n" ); +return -EINVAL ; + } + } + +return 0 ; +} +static void parse_dacl (struct smb_acl *pdacl,char *end_of_acl,struct smb_sid *pownersid,struct smb_sid *pgrpsid,struct cifs_fattr *fattr,bool mode_from_special_sid)
@@ -764,7 +835,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,int i;u16 num_aces =0 ;int acl_size; -char *acl_base; +char *acl_base, *end_of_dacl;struct smb_ace **ppace;/* BB need to add parm so we can store the SID BB */
@@ -776,12 +847,8 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,return ; } -/* validate that we do not go past end of acl */ -if (end_of_acl < (char *)pdacl +sizeof (struct smb_acl ) || - end_of_acl < (char *)pdacl +le16_to_cpu (pdacl->size)) { -cifs_dbg (VFS ,"ACL too small to parse DACL\n" ); +if (validate_dacl (pdacl, end_of_acl))return ; - } cifs_dbg(NOISY, "DACL revision %d size %d num aces %d\n", le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size),
@@ -792,6 +859,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,user/group/other have no permissions */ fattr->cf_mode &= ~(0777 ); + end_of_dacl = (char *)pdacl +le16_to_cpu (pdacl->size); acl_base = (char *)pdacl; acl_size =sizeof (struct smb_acl );
@@ -799,36 +867,16 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,if (num_aces >0 ) {umode_t denied_mode =0 ; -if (num_aces > (le16_to_cpu (pdacl->size) -sizeof (struct smb_acl )) / - (offsetof(struct smb_ace , sid) + - offsetof(struct smb_sid , sub_auth) +sizeof (__le16))) -return ; - ppace =kmalloc_array (num_aces,sizeof (struct smb_ace *),GFP_KERNEL );if (!ppace)return ;for (i =0 ; i < num_aces; ++i) { -if (end_of_acl - acl_base < acl_size) -break ; - ppace[i] = (struct smb_ace *) (acl_base + acl_size); - acl_base = (char *)ppace[i]; - acl_size = offsetof(struct smb_ace , sid) + - offsetof(struct smb_sid , sub_auth); - -if (end_of_acl - acl_base < acl_size || - ppace[i]->sid.num_subauth ==0 || - ppace[i]->sid.num_subauth >SID_MAX_SUB_AUTHORITIES || - (end_of_acl - acl_base < - acl_size +sizeof (__le32) * ppace[i]->sid.num_subauth) || - (le16_to_cpu (ppace[i]->size) < - acl_size +sizeof (__le32) * ppace[i]->sid.num_subauth)) -break ;#ifdef CONFIG_CIFS_DEBUG2 -dump_ace (ppace[i], end_of_acl); +dump_ace (ppace[i], end_of_dacl);#endif if (mode_from_special_sid && ppace[i]->sid.num_subauth >= 3 &&
@@ -871,6 +919,7 @@ static void parse_dacl(struct smb_acl *pdacl, char *end_of_acl,(void *)ppace[i], sizeof(struct smb_ace)); */ + acl_base = (char *)ppace[i]; acl_size =le16_to_cpu (ppace[i]->size); }
@@ -1316,10 +1365,9 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd, } dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset); -if (end_of_acl < (char *)dacl_ptr +le16_to_cpu (dacl_ptr->size)) { -cifs_dbg (VFS ,"Server returned illegal ACL size\n" ); -return -EINVAL ; - } + rc =validate_dacl (dacl_ptr, end_of_acl); +if (rc) +return rc; } owner_sid_ptr = (struct smb_sid *)((char *)pntsd +
@@ -1698,6 +1746,12 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, } dacl_ptr = (struct smb_acl *)((char *)pntsd + dacloffset); + rc =validate_dacl (dacl_ptr, (char *)pntsd + secdesclen); +if (rc) { +kfree (pntsd); +cifs_put_tlink (tlink); +return rc; + }if (mode_from_sid) nsecdesclen +=le16_to_cpu (dacl_ptr->num_aces) *sizeof (struct smb_ace );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 83/307 remove pointless includes of <linux/fdtable.h>
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit be5498cac2ddb112c5bd7433d5e834a1a2493427 ]
some of those used to be needed, some had been cargo-culted for no reason...
Stable-dep-of: ea5fe6a73ca5 ("net/handshake: Drain pending requests at net namespace exit")
--- fs/fcntl.c | 1 - fs/file_table.c | 1 - fs/notify/fanotify/fanotify.c | 1 - fs/notify/fanotify/fanotify_user.c | 1 - fs/overlayfs/copy_up.c | 1 - fs/proc/base.c | 1 - io_uring/io_uring.c | 1 - kernel/bpf/bpf_inode_storage.c | 1 - kernel/bpf/bpf_task_storage.c | 1 - kernel/bpf/token.c | 1 - kernel/exit.c | 1 - kernel/module/dups.c | 1 - kernel/module/kmod.c | 1 - kernel/umh.c | 1 - net/handshake/request.c | 1 - security/apparmor/domain.c | 1 - 16 files changed, 16 deletions(-)
fs/fcntl.c +0 -1
@@ -12,7 +12,6 @@#include <linux/fs.h> #include <linux/filelock.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/capability.h> #include <linux/dnotify.h> #include <linux/slab.h>
fs/file_table.c +0 -1
@@ -9,7 +9,6 @@#include <linux/string.h> #include <linux/slab.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h>
fs/notify/fanotify/fanotify.c +0 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/fanotify.h> -#include <linux/fdtable.h> #include <linux/fsnotify_backend.h> #include <linux/init.h> #include <linux/jiffies.h>
fs/notify/fanotify/fanotify_user.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/fanotify.h> #include <linux/fcntl.h> -#include <linux/fdtable.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/anon_inodes.h>
fs/overlayfs/copy_up.c +0 -1
@@ -16,7 +16,6 @@#include <linux/sched/signal.h> #include <linux/cred.h> #include <linux/namei.h> -#include <linux/fdtable.h> #include <linux/ratelimit.h> #include <linux/exportfs.h> #include "overlayfs.h"
fs/proc/base.c +0 -1
@@ -58,7 +58,6 @@#include <linux/init.h> #include <linux/capability.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/generic-radix-tree.h> #include <linux/string.h> #include <linux/seq_file.h>
io_uring/io_uring.c +0 -1
@@ -51,7 +51,6 @@#include <linux/sched/signal.h> #include <linux/fs.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/mm.h> #include <linux/mman.h> #include <linux/percpu.h>
kernel/bpf/bpf_inode_storage.c +0 -1
@@ -16,7 +16,6 @@#include <uapi/linux/btf.h> #include <linux/bpf_lsm.h> #include <linux/btf_ids.h> -#include <linux/fdtable.h> #include <linux/rcupdate_trace.h> DEFINE_BPF_STORAGE_CACHE (inode_cache);
kernel/bpf/bpf_task_storage.c +0 -1
@@ -16,7 +16,6 @@#include <linux/filter.h> #include <uapi/linux/btf.h> #include <linux/btf_ids.h> -#include <linux/fdtable.h> #include <linux/rcupdate_trace.h> DEFINE_BPF_STORAGE_CACHE (task_cache);
kernel/bpf/token.c +0 -1
@@ -1,6 +1,5 @@#include <linux/bpf.h> #include <linux/vmalloc.h> -#include <linux/fdtable.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/kernel.h>
kernel/exit.c +0 -1
@@ -25,7 +25,6 @@#include <linux/acct.h> #include <linux/tsacct_kern.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/freezer.h> #include <linux/binfmts.h> #include <linux/nsproxy.h>
kernel/module/dups.c +0 -1
@@ -18,7 +18,6 @@#include <linux/completion.h> #include <linux/cred.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/workqueue.h> #include <linux/security.h> #include <linux/mount.h>
kernel/module/kmod.c +0 -1
@@ -15,7 +15,6 @@#include <linux/completion.h> #include <linux/cred.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/workqueue.h> #include <linux/security.h> #include <linux/mount.h>
kernel/umh.c +0 -1
@@ -13,7 +13,6 @@#include <linux/completion.h> #include <linux/cred.h> #include <linux/file.h> -#include <linux/fdtable.h> #include <linux/fs_struct.h> #include <linux/workqueue.h> #include <linux/security.h>
net/handshake/request.c +0 -1
@@ -13,7 +13,6 @@#include <linux/module.h> #include <linux/skbuff.h> #include <linux/inet.h> -#include <linux/fdtable.h> #include <linux/rhashtable.h> #include <net/sock.h>
security/apparmor/domain.c +0 -1
@@ -9,7 +9,6 @@*/ #include <linux/errno.h> -#include <linux/fdtable.h> #include <linux/fs.h> #include <linux/file.h> #include <linux/mount.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 98/315 Revert "x86/fpu: Refine and simplify the magic number check during signal return"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrei Vagin <[email protected]>
[ Upstream commit 44eeff9bc467bc7d1fec34fc3f6001f385fe462c ]
This reverts
dc8aa31a7ac2 ("x86/fpu: Refine and simplify the magic number check during signal return").
The aforementioned commit broke applications that construct signal frames in userspace (such as CRIU and gVisor) if the frame's xstate size is smaller than the kernel's fpstate->user_size.
Furthermore, this introduces a critical issue for checkpoint/restore tools like CRIU. If a process is checkpointed while inside a signal handler, its stack contains a signal frame formatted according to the source host's xstate capabilities.
If that process is later restored on a destination host with larger xstate capabilities (e.g., a newer CPU with more features enabled, resulting in a larger fpstate->user_size), the kernel will look for FP_XSTATE_MAGIC2 at the destination host's larger user_size offset instead of the offset encoded in the frame's fx_sw->xstate_size.
This causes the magic2 check to fail, forcing sigreturn to silently fall back to "FX-only" mode. Upon return from the signal handler, the process's extended state is reset to initial values instead of being restored, leading to silent data corruption.
The aforementioned commit cited
d877550eaf2d ("x86/fpu: Stop relying on userspace for info to fault in xsave buffer")
as justification to stop relying on userspace for the magic number check.
However, these two changes are fundamentally different. The last one only changed how much memory the kernel ensures is paged-in before running XRSTOR to prevent an infinite loop. It did not change the signal frame format or how the layout is validated.
Reverting this change restores the use of fx_sw->xstate_size for locating magic2 and restores the necessary sanity checks, ensuring that the signal frame remains self-describing and portable.
[ bp: Massage commit message. ]
--- arch/x86/kernel/fpu/signal.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kernel/fpu/signal.c +8 -3
@@ -27,14 +27,19 @@static inline bool check_xstate_in_sigframe (struct fxregs_state __user *fxbuf,struct _fpx_sw_bytes *fx_sw) { +int min_xstate_size =sizeof (struct fxregs_state ) + +sizeof (struct xstate_header );void __user *fpstate = fxbuf;unsigned int magic2;if (__copy_from_user (fx_sw, &fxbuf->sw_reserved[0 ],sizeof (*fx_sw)))return false; -/* Check for the first magic field */ -if (fx_sw->magic1 !=FP_XSTATE_MAGIC1 ) +/* Check for the first magic field and other error scenarios. */ +if (fx_sw->magic1 !=FP_XSTATE_MAGIC1 || + fx_sw->xstate_size < min_xstate_size || + fx_sw->xstate_size >x86_task_fpu (current)->fpstate->user_size || + fx_sw->xstate_size > fx_sw->extended_size) goto setfx;/*
@@ -43,7 +48,7 @@ static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,* fpstate layout with out copying the extended state information * in the memory layout. */ -if (__get_user (magic2, (__u32 __user *)(fpstate +x86_task_fpu (current)->fpstate->user_size))) +if (__get_user (magic2, (__u32 __user *)(fpstate + fx_sw->xstate_size)))return false;if (likely (magic2 ==FP_XSTATE_MAGIC2 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 84/307 net/handshake: Take a long-lived file reference at submit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 09dba37eee70d0596e26645015f1aa95a9848e9d ]
handshake_nl_accept_doit() needs the file pointer backing req->hr_sk->sk_socket to survive the window between handshake_req_next() and the subsequent FD_PREPARE() and get_file(). The submit-side sock_hold() does not provide that. sk_refcnt keeps struct sock alive, but struct socket is owned by sock->file: when the consumer fputs the last file reference, sock_release() tears the socket down regardless of any sock_hold.
Add an hr_file pointer to struct handshake_req and acquire an explicit reference on sock->file during handshake_req_submit(). handshake_complete() and handshake_req_cancel() release the reference on the completion-bit-winning path.
The submit error path must also release the file reference, but after rhashtable insertion a concurrent handshake_req_cancel() can discover the request and race the error path. Gate the error-path cleanup -- sk_destruct restoration, fput, and request destruction -- with test_and_set_bit(HANDSHAKE_F_REQ_COMPLETED), the same serialization handshake_complete() and handshake_req_cancel() already use. When cancel has already claimed ownership, the submit error path returns without touching the request; socket teardown handles final destruction.
The accept-side dereferences are not yet retargeted; that change comes in the next patch.
Stable-dep-of: ea5fe6a73ca5 ("net/handshake: Drain pending requests at net namespace exit")
--- net/handshake/handshake.h | 2 ++ net/handshake/netlink.c | 6 ------ net/handshake/request.c | 42 ++++++++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 13 deletions(-)
net/handshake/handshake.h +2 -0
@@ -24,6 +24,7 @@ enum hn_flags_bits { HANDSHAKE_F_NET_DRAINING, }; +struct file ;struct handshake_proto ;/* One handshake request */
@@ -32,6 +33,7 @@ struct handshake_req {struct rhash_head hr_rhash;unsigned long hr_flags;const struct handshake_proto *hr_proto; +struct file *hr_file;struct sock *hr_sk;void (*hr_odestruct)(struct sock *sk);
net/handshake/netlink.c +0 -6
@@ -211,12 +211,6 @@ static void __net_exit handshake_net_exit(struct net *net)while (!list_empty (&requests)) { req = list_first_entry(&requests, struct handshake_req, hr_list);list_del (&req->hr_list); - -/* -* Requests on this list have not yet been -* accepted, so they do not have an fd to put. -*/ -handshake_complete (req, -ETIMEDOUT ,NULL ); } }
net/handshake/request.c +35 -7
90 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 99/315 s390/cio: Restore GFP_DMA for CHSC allocation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
[ Upstream commit ea34567db0a6b3a7ce78ba421592344315c8f90e ]
Re-add GFP_DMA when allocating memory for CHSC control blocks. On some supported machines, CHSC cannot access memory outside the DMA zone, causing CHSC command failures.
--- drivers/s390/cio/chsc.c | 4 ++-- drivers/s390/cio/chsc_sch.c | 20 ++++++++++---------- drivers/s390/cio/scm.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/s390/cio/chsc.c +2 -2
@@ -1143,8 +1143,8 @@ int __init chsc_init(void) {int ret; - sei_page = (void *)get_zeroed_page (GFP_KERNEL ); - chsc_page = (void *)get_zeroed_page (GFP_KERNEL ); + sei_page = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA ); + chsc_page = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sei_page || !chsc_page) { ret = -ENOMEM ; goto out_err;
drivers/s390/cio/chsc_sch.c +10 -10
@@ -293,7 +293,7 @@ static int chsc_ioctl_start(void __user *user_area)if (!css_general_characteristics.dynio)/* It makes no sense to try. */ return -EOPNOTSUPP ; - chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + chsc_area = (void *)get_zeroed_page (GFP_DMA |GFP_KERNEL );if (!chsc_area)return -ENOMEM ; request =kzalloc (sizeof (*request),GFP_KERNEL );
@@ -341,7 +341,7 @@ static int chsc_ioctl_on_close_set(void __user *user_area) ret = -ENOMEM ; goto out_unlock; } - on_close_chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + on_close_chsc_area = (void *)get_zeroed_page (GFP_DMA |GFP_KERNEL );if (!on_close_chsc_area) { ret = -ENOMEM ; goto out_free_request;
@@ -393,7 +393,7 @@ static int chsc_ioctl_start_sync(void __user *user_area)struct chsc_sync_area *chsc_area;int ret, ccode; - chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + chsc_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!chsc_area)return -ENOMEM ;if (copy_from_user (chsc_area, user_area,PAGE_SIZE )) {
@@ -439,7 +439,7 @@ static int chsc_ioctl_info_channel_path(void __user *user_cd)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *scpcd_area; - scpcd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scpcd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scpcd_area)return -ENOMEM ; cd =kzalloc (sizeof (*cd),GFP_KERNEL );
@@ -501,7 +501,7 @@ static int chsc_ioctl_info_cu(void __user *user_cd)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *scucd_area; - scucd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scucd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scucd_area)return -ENOMEM ; cd =kzalloc (sizeof (*cd),GFP_KERNEL );
@@ -564,7 +564,7 @@ static int chsc_ioctl_info_sch_cu(void __user *user_cud)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *sscud_area; - sscud_area = (void *)get_zeroed_page (GFP_KERNEL ); + sscud_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sscud_area)return -ENOMEM ; cud =kzalloc (sizeof (*cud),GFP_KERNEL );
@@ -626,7 +626,7 @@ static int chsc_ioctl_conf_info(void __user *user_ci)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *sci_area; - sci_area = (void *)get_zeroed_page (GFP_KERNEL ); + sci_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sci_area)return -ENOMEM ; ci =kzalloc (sizeof (*ci),GFP_KERNEL );
@@ -697,7 +697,7 @@ static int chsc_ioctl_conf_comp_list(void __user *user_ccl)u32 res; } __attribute__ ((packed)) *cssids_parm; - sccl_area = (void *)get_zeroed_page (GFP_KERNEL ); + sccl_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sccl_area)return -ENOMEM ; ccl =kzalloc (sizeof (*ccl),GFP_KERNEL );
@@ -757,7 +757,7 @@ static int chsc_ioctl_chpd(void __user *user_chpd)int ret; chpd =kzalloc (sizeof (*chpd),GFP_KERNEL ); - scpd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scpd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scpd_area || !chpd) { ret = -ENOMEM ; goto out_free;
@@ -797,7 +797,7 @@ static int chsc_ioctl_dcal(void __user *user_dcal)u8 data[PAGE_SIZE -36 ]; } __attribute__ ((packed)) *sdcal_area; - sdcal_area = (void *)get_zeroed_page (GFP_KERNEL ); + sdcal_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sdcal_area)return -ENOMEM ; dcal =kzalloc (sizeof (*dcal),GFP_KERNEL );
drivers/s390/cio/scm.c +1 -1
@@ -229,7 +229,7 @@ int scm_update_information(void)size_t num;int ret; - scm_info = (void *)__get_free_page (GFP_KERNEL ); + scm_info = (void *)__get_free_page (GFP_KERNEL |GFP_DMA );if (!scm_info)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 67/307 ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 596c51ed9e125b12c4d85b4530dfd4c7847634b7 ]
linkstate_prepare_data() calls ethnl_req_get_phydev() before ethnl_ops_begin(), but routes its error path through "goto out" which calls ethnl_ops_complete().
--- net/ethtool/linkstate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/ethtool/linkstate.c +2 -4
@@ -105,10 +105,8 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_LINKSTATE_HEADER , info->extack); -if (IS_ERR (phydev)) { - ret =PTR_ERR (phydev); - goto out; - } +if (IS_ERR (phydev)) +return PTR_ERR (phydev); ret =ethnl_ops_begin (dev);if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 85/307 net/handshake: Drain pending requests at net namespace exit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit ea5fe6a73ca57e5150b8a38b341aef2636eb72f0 ]
The arguments to list_splice_init() in handshake_net_exit() are reversed. The call moves the local empty "requests" list onto hn->hn_requests, leaving the local list empty, so the subsequent drain loop runs zero iterations. Pending handshake requests that had not yet been accepted are not torn down when the net namespace is destroyed; each one keeps a reference on a socket file and on the handshake_req allocation.
Pass the source and destination in the documented order (list_splice_init(list, head) moves list onto head) so the pending list is transferred to the local scratch list and drained through handshake_complete().
Fixing the splice direction exposes a list-corruption race. After the splice each req->hr_list still has non-empty link pointers, threading the stack-local scratch list rather than hn_requests. A concurrent handshake_req_cancel() -- for example, from sunrpc's TLS timeout on a kernel socket whose netns reference was not taken -- finds the request through the rhashtable, calls remove_pending(), and sees !list_empty(&req->hr_list). __remove_pending_locked() then list_del_init()s an entry off the scratch list while the drain iterates, corrupting it. The same call arriving after the drain loop has run list_del() on an entry hits LIST_POISON instead.
Have remove_pending() check HANDSHAKE_F_NET_DRAINING under hn_lock and report not-found when drain is in progress. The drain has already taken ownership; handshake_complete()'s existing test_and_set on HANDSHAKE_F_REQ_COMPLETED still arbitrates between drain and cancel for who calls the consumer's hp_done. Use list_del_init() rather than list_del() in the drain so req->hr_list does not carry LIST_POISON after drain releases the entry.
The DRAINING guard in remove_pending() makes cancel return false, but cancel still falls through to test_and_set_bit on HANDSHAKE_F_REQ_COMPLETED and drops the request's hr_file reference. Without another pin, if that is the last reference, sk_destruct frees the request while it is still linked on the drain loop's local list. Pin each request's hr_file under hn_lock before releasing the list, and drop that drain pin after the loop finishes with the request.
--- net/handshake/netlink.c | 10 ++++++++-- net/handshake/request.c | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-)
net/handshake/netlink.c +8 -2
@@ -205,13 +205,19 @@ static void __net_exit handshake_net_exit(struct net *net)*/ spin_lock_bh (&hn->hn_lock);set_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags); -list_splice_init (&requests, &hn->hn_requests); +list_splice_init (&hn->hn_requests, &requests); +list_for_each_entry (req, &requests, hr_list) +get_file (req->hr_file);spin_unlock_bh (&hn->hn_lock);while (!list_empty (&requests)) { +struct file *file; + req = list_first_entry(&requests, struct handshake_req, hr_list); -list_del (&req->hr_list); + file = req->hr_file; +list_del_init (&req->hr_list);handshake_complete (req, -ETIMEDOUT ,NULL ); +fput (file); } }
net/handshake/request.c +4 -1
@@ -163,13 +163,16 @@ static void __remove_pending_locked(struct handshake_net *hn,* otherwise %false. * * If @req was on a pending list, it has not yet been accepted. +* Returns %false when the net namespace is draining; the drain +* loop has taken ownership of the pending list. */ static bool remove_pending (struct handshake_net *hn,struct handshake_req *req) {bool ret = false;spin_lock_bh (&hn->hn_lock); -if (!list_empty (&req->hr_list)) { +if (!test_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags) && + !list_empty (&req->hr_list)) {__remove_pending_locked (hn, req); ret = true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 100/315 drm/i915/psr: Add defininitions for INTEL_WA_REGISTER_CAPS DPCD register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <[email protected]>
commit fbceb39b536e40c2f7cc47ab42037bb7c2b7ced9 upstream.
EDP specification says:
"If either VSC SDP is unable to be transmitted 100 ns before the SU region, the Source device may optionally transmit the VSC SDP during the prior video scan line’s HBlank period There is a Intel specific drm dp register currently containing bits related how TCON can support PSR2 with SDP on prior line."
Unfortunately many panels are having problems in implementing this. So there is a custom Intel specific DPCD register (INTEL_WA_REGISTER_CAPS) to figure out if this is properly implemented on a panel or if panel doesn't require that 100 ns delay before the SU region. Here are the definitions in this custom DPCD address:
0 = Panel doesn't support SDP on prior line
1 = Panel supports SDP on prior line
2 = Panel doesn't have 100ns requirement
3 = Reserved
Add definitions for this new register and it's values into new header intel_dpcd.h.
v2: add INTEL_DPCD_ prefix to definitions
Bspec: 74741
--- drivers/gpu/drm/i915/display/intel_dpcd.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 drivers/gpu/drm/i915/display/intel_dpcd.h
drivers/gpu/drm/i915/display/intel_dpcd.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2026 Intel Corporation +*/ + +#ifndef __INTEL_DPCD_H__ +#define __INTEL_DPCD_H__ + +#define INTEL_DPCD_INTEL_WA_REGISTER_CAPS 0x3f0 +# define INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_EARLYSCANLINE_SDP_SUPPORT_MASK REG_GENMASK(1, 0) +# define INTEL_DPCD_INTEL_WA_REGISTER_CAPS_FALL_BACK_TO_PSR1 0 +# define INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_WITH_EARLY_SCANLINE 1 +# define INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_WITHOUT_EARLY_SCANLINE 2 + +#endif /* __INTEL_DPCD_H__ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 86/307 Bluetooth: l2cap: clear chan->ident on ECRED reconfiguration success
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenghang Xiao <[email protected]>
[ Upstream commit 00e1950716c6ed67d74777b2db286b0fa23b4be9 ]
l2cap_ecred_reconf_rsp() returns early on success without clearing chan->ident. Every other L2CAP response handler (l2cap_ecred_conn_rsp, l2cap_le_connect_rsp, l2cap_config_rsp) clears chan->ident after a successful transaction to prevent the channel from matching subsequent responses with the recycled ident value.
A remote attacker that completed a reconfiguration as the peer can replay a failure response with the stale ident, causing the kernel to match and destroy the already-established channel via l2cap_chan_del(chan, ECONNRESET).
Clear chan->ident for all matching channels on success, and harden the failure path by using l2cap_chan_hold_unless_zero() consistent with other L2CAP handlers (l2cap_le_command_rej, __l2cap_get_chan_by_ident).
--- net/bluetooth/l2cap_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +8 -2
@@ -5392,14 +5392,20 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,BT_DBG ("result 0x%4.4x" , result); -if (!result) +if (!result) { +list_for_each_entry (chan, &conn->chan_l, list) { +if (chan->ident == cmd->ident) + chan->ident =0 ; + }return 0 ; + }list_for_each_entry_safe (chan, tmp, &conn->chan_l, list) {if (chan->ident != cmd->ident)continue ; -l2cap_chan_hold (chan); +if (!l2cap_chan_hold_unless_zero (chan)) +continue ;l2cap_chan_lock (chan);l2cap_chan_del (chan,ECONNRESET );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 101/315 drm/i915/psr: Read Intel DPCD workaround register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <[email protected]>
commit f30bece421a4ae34359254e1dc2a187a42b6af9b upstream.
Read Intel DPCD workaround register and store it into intel_connector->dp.psr_caps. psr_caps was chosen as currently it contains only PSR workaround for PSR2 SDP on prior scanline implementation.
--- drivers/gpu/drm/i915/display/intel_display_types.h | 1 + drivers/gpu/drm/i915/display/intel_psr.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/gpu/drm/i915/display/intel_display_types.h +1 -0
@@ -1710,6 +1710,7 @@ struct intel_dp {u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE ];u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT ][DP_LTTPR_PHY_CAP_SIZE ];u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE ]; +u8 intel_wa_dpcd;/* source rates */ int num_source_rates;const int *source_rates;
drivers/gpu/drm/i915/display/intel_psr.c +7 -0
@@ -41,6 +41,7 @@#include "intel_display_types.h" #include "intel_dmc.h" #include "intel_dp.h" +#include "intel_dpcd.h" #include "intel_dp_aux.h" #include "intel_dsb.h" #include "intel_frontbuffer.h"
@@ -679,6 +680,12 @@ static void _psr_init_dpcd(struct intel_dp *intel_dp)drm_dbg_kms (display->drm,"PSR2 %ssupported\n" , intel_dp->psr.sink_psr2_support ?"" :"not " ); } + +if (intel_dp->psr.sink_psr2_support) +drm_dp_dpcd_read (&intel_dp->aux, +INTEL_DPCD_INTEL_WA_REGISTER_CAPS , + &intel_dp->intel_wa_dpcd, +sizeof (intel_dp->intel_wa_dpcd)); }void intel_psr_init_dpcd (struct intel_dp *intel_dp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 102/315 drm/i915/psr: Apply Intel DPCD workaround when SDP on prior line used
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <[email protected]>
commit 4703049f768fc1c1caac754134118bee1a3af189 upstream.
There is Intel specific workaround DPCD address containing workaround for case where SDP is on prior line. Apply this workaround according to values in the offset.
--- drivers/gpu/drm/i915/display/intel_psr.c | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_psr.c +27 -1
@@ -29,6 +29,7 @@#include <drm/drm_vblank.h> #include "i915_reg.h" +#include "i915_utils.h" #include "intel_alpm.h" #include "intel_atomic.h" #include "intel_crtc.h"
@@ -1315,6 +1316,30 @@ static bool psr2_granularity_check(struct intel_dp *intel_dp,return true; } +static bool apply_scanline_indication_wa (struct intel_dp *intel_dp, +struct intel_crtc_state *crtc_state) +{ +u8 early_scanline_support = intel_dp->intel_wa_dpcd & +INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_EARLYSCANLINE_SDP_SUPPORT_MASK ; + +if (intel_dp->edp_dpcd[0 ] >=DP_EDP_15 ) +return true; + +switch (early_scanline_support) { +case INTEL_DPCD_INTEL_WA_REGISTER_CAPS_FALL_BACK_TO_PSR1 : + crtc_state->req_psr2_sdp_prior_scanline = false; +return false; +case INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_WITH_EARLY_SCANLINE : +return true; +case INTEL_DPCD_INTEL_WA_REGISTER_CAPS_PSR2_WITHOUT_EARLY_SCANLINE : + crtc_state->req_psr2_sdp_prior_scanline = false; +return true; +default : +MISSING_CASE (early_scanline_support); +return false; + } +} +static bool _compute_psr2_sdp_prior_scanline_indication (struct intel_dp *intel_dp,struct intel_crtc_state *crtc_state) {
@@ -1336,7 +1361,8 @@ static bool _compute_psr2_sdp_prior_scanline_indication(struct intel_dp *intel_dreturn false; crtc_state->req_psr2_sdp_prior_scanline = true; -return true; + +return apply_scanline_indication_wa (intel_dp, crtc_state); } static int intel_psr_entry_setup_frames(struct intel_dp *intel_dp,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 88/307 Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
[ Upstream commit 525daaea459fc215f432de1b8debbd9144bf97b0 ]
Since hci_dev_close_sync() can now be called during the reset path, we should also set HCI_CMD_DRAIN_WORKQUEUE. This avoids queuing timeouts while the hdev workqueue is being drained.
--- net/bluetooth/hci_sync.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/hci_sync.c +8 -0
@@ -5223,6 +5223,12 @@ int hci_dev_close_sync(struct hci_dev *hdev)bt_dev_dbg (hdev,"" ); +/* Set HCI_DRAIN_WORKQUEUE flag to prevent queuing work during +* reset/close. See hci_cmd_work() and handle_cmd_cnt_and_timer(). +*/ +hci_dev_set_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE ); +synchronize_rcu (); +if (hci_dev_test_flag (hdev,HCI_UNREGISTER )) {disable_delayed_work (&hdev->power_off);disable_delayed_work (&hdev->ncmd_timer);
@@ -5246,6 +5252,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)if (!test_and_clear_bit (HCI_UP , &hdev->flags)) {cancel_delayed_work_sync (&hdev->cmd_timer); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );return err; }
@@ -5345,6 +5352,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)/* Clear flags */ hdev->flags &=BIT (HCI_RAW );hci_dev_clear_volatile_flags (hdev); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );memset (hdev->eir,0 ,sizeof (hdev->eir));memset (hdev->dev_class,0 ,sizeof (hdev->dev_class));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 103/315 phy: mscc: Use PHY_ID_MATCH_EXACT for VSC8584, VSC8582, VSC8575, VSC856X
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horatiu Vultur <[email protected]>
[ Upstream commit 1bc80d673087e5704adbb3ee8e4b785c14899cce ]
As the PHYs VSC8584, VSC8582, VSC8575 and VSC856X exists only as rev B, we can use PHY_ID_MATCH_EXACT to match exactly on revision B of the PHY. Because of this change then there is not need the check if it is a different revision than rev B in the function vsc8584_probe() as we already know that this will never happen.
These changes are a preparation for the next patch because in that patch we will make the PHYs VSC8574 and VSC8572 to use vsc8584_probe() and these PHYs have multiple revision.
--- drivers/net/phy/mscc/mscc.h | 8 ++++---- drivers/net/phy/mscc/mscc_main.c | 23 ++++------------------- 2 files changed, 8 insertions(+), 23 deletions(-)
drivers/net/phy/mscc/mscc.h +4 -4
@@ -289,12 +289,12 @@ enum rgmii_clock_delay {#define PHY_ID_VSC8540 0x00070760#define PHY_ID_VSC8541 0x00070770#define PHY_ID_VSC8552 0x000704e0 -#define PHY_ID_VSC856X 0x000707e0 +#define PHY_ID_VSC856X 0x000707e1#define PHY_ID_VSC8572 0x000704d0#define PHY_ID_VSC8574 0x000704a0 -#define PHY_ID_VSC8575 0x000707d0 -#define PHY_ID_VSC8582 0x000707b0 -#define PHY_ID_VSC8584 0x000707c0 +#define PHY_ID_VSC8575 0x000707d1 +#define PHY_ID_VSC8582 0x000707b1 +#define PHY_ID_VSC8584 0x000707c1#define PHY_VENDOR_MSCC 0x00070400#define MSCC_VDDMAC_1500 1500
drivers/net/phy/mscc/mscc_main.c +4 -19
@@ -1724,12 +1724,6 @@ static int vsc8584_config_init(struct phy_device *phydev)* in this pre-init function. */ if (phy_package_init_once (phydev)) { -/* The following switch statement assumes that the lowest -* nibble of the phy_id_mask is always 0. This works because -* the lowest nibble of the PHY_ID's below are also 0. -*/ -WARN_ON (phydev->drv->phy_id_mask &0xf ); -switch (phydev->phy_id & phydev->drv->phy_id_mask) {case PHY_ID_VSC8504 :case PHY_ID_VSC8552 :
@@ -2290,11 +2284,6 @@ static int vsc8584_probe(struct phy_device *phydev) VSC8531_DUPLEX_COLLISION};int ret; -if ((phydev->phy_id &MSCC_DEV_REV_MASK ) !=VSC8584_REVB ) { -dev_err (&phydev->mdio.dev,"Only VSC8584 revB is supported.\n" ); -return -ENOTSUPP ; - } - vsc8531 =devm_kzalloc (&phydev->mdio.dev,sizeof (*vsc8531),GFP_KERNEL );if (!vsc8531)return -ENOMEM ;
@@ -2587,9 +2576,8 @@ static struct phy_driver vsc85xx_driver[] = { .config_inband = vsc85xx_config_inband, }, { - .phy_id = PHY_ID_VSC856X, + PHY_ID_MATCH_EXACT(PHY_ID_VSC856X), .name = "Microsemi GE VSC856X SyncE", - .phy_id_mask = 0xfffffff0,/* PHY_GBIT_FEATURES */ .soft_reset = &genphy_soft_reset, .config_init = &vsc8584_config_init,
@@ -2667,9 +2655,8 @@ static struct phy_driver vsc85xx_driver[] = { .config_inband = vsc85xx_config_inband, }, { - .phy_id = PHY_ID_VSC8575, + PHY_ID_MATCH_EXACT(PHY_ID_VSC8575), .name = "Microsemi GE VSC8575 SyncE", - .phy_id_mask = 0xfffffff0,/* PHY_GBIT_FEATURES */ .soft_reset = &genphy_soft_reset, .config_init = &vsc8584_config_init,
@@ -2693,9 +2680,8 @@ static struct phy_driver vsc85xx_driver[] = { .config_inband = vsc85xx_config_inband, }, { - .phy_id = PHY_ID_VSC8582, + PHY_ID_MATCH_EXACT(PHY_ID_VSC8582), .name = "Microsemi GE VSC8582 SyncE", - .phy_id_mask = 0xfffffff0,/* PHY_GBIT_FEATURES */ .soft_reset = &genphy_soft_reset, .config_init = &vsc8584_config_init,
@@ -2719,9 +2705,8 @@ static struct phy_driver vsc85xx_driver[] = { .config_inband = vsc85xx_config_inband, }, { - .phy_id = PHY_ID_VSC8584, + PHY_ID_MATCH_EXACT(PHY_ID_VSC8584), .name = "Microsemi GE VSC8584 SyncE", - .phy_id_mask = 0xfffffff0,/* PHY_GBIT_FEATURES */ .soft_reset = &genphy_soft_reset, .config_init = &vsc8584_config_init,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 89/307 gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8a122b5e72cc0043705f0d524bcd15f0c0b3ec15 ]
If *ppos is non-zero (user-space write split over multiple calls to write()) then simple_write_to_buffer() won't initialize the start of the buffer. Really, non-zero values for *ppos aren't going to work at all. Check for that and return -EINVAL at the start of the function.
--- drivers/gpio/gpio-virtuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-virtuser.c +2 -2
@@ -400,7 +400,7 @@ static ssize_t gpio_virtuser_direction_do_write(struct file *file,char buf[32 ], *trimmed;int ret, dir, val =0 ; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret =simple_write_to_buffer (buf,sizeof (buf) -1 , ppos, user_buf, count);
@@ -627,7 +627,7 @@ static ssize_t gpio_virtuser_consumer_write(struct file *file,char buf[GPIO_VIRTUSER_NAME_BUF_LEN +2 ];int ret; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret = simple_write_to_buffer(buf, GPIO_VIRTUSER_NAME_BUF_LEN, ppos,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 104/315 iio: imu: st_lsm6dsx: fix stack leak in tagged FIFO buffer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit c9d8e9adaa63150ef7e833480b799d0bab83a276 upstream.
The tagged FIFO path declares iio_buff on the stack with __aligned(8) but no initializer, but there is a hole in the structure, which will then leak to userspace as ST_LSM6DSX_SAMPLE_SIZE bytes (6) will be copied, but the space between that and the timestamp are not initialized.
Commit c14edb4d0bdc ("iio:imu:st_lsm6dsx Fix alignment and data leak issues") moved the untagged FIFO path to a kzalloc'd buffer in hw->scan, but for the tagged path it only added the alignment qualifier and not the initializer :(
Fix this by just zero-initializing the structure on the stack.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +1 -1
@@ -608,7 +608,7 @@ int st_lsm6dsx_read_tagged_fifo(struct s* must be passed a buffer that is aligned to 8 bytes so * as to allow insertion of a naturally aligned timestamp. */ -u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE ]__aligned(8) ; +u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE ]__aligned(8) = { };u8 tag;bool reset_ts = false;int i, err, read_len;
Greg Kroah-Hartman
maintainerPATCH 90/307 gpio: rockchip: convert bank->clk to devm_clk_get_enabled()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit 3e46c18d5d87f063a93ae0fe7662fbf6660459d5 ]
The bank->clk was previously obtained via of_clk_get() and manually prepared/enabled. However, it was missing a corresponding clk_put() in both the error paths and the remove function, leading to a reference leak.
Convert the allocation to devm_clk_get_enabled(), which also properly propagates failures from clk_prepare_enable() that were previously ignored.
The GPIO bank device uses the same OF node as the previous of_clk_get() call, so devm_clk_get_enabled(dev, NULL) correctly resolves the same clock provider entry.
Fix the reference leak and simplify the code by removing the manual clk_disable_unprepare() calls in the probe error paths and in the remove function.
--- drivers/gpio/gpio-rockchip.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-rockchip.c +1 -5
@@ -647,11 +647,10 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)if (!bank->irq)return -EINVAL ; - bank->clk =of_clk_get (bank->of_node,0 ); + bank->clk =devm_clk_get_enabled (bank->dev,NULL );if (IS_ERR (bank->clk))return PTR_ERR (bank->clk); -clk_prepare_enable (bank->clk); id =readl (bank->reg_base + gpio_regs_v2.version_id);/* If not gpio v2, that is default to v1. */
@@ -661,7 +660,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) bank->db_clk =of_clk_get (bank->of_node,1 );if (IS_ERR (bank->db_clk)) {dev_err (bank->dev,"cannot find debounce clk\n" ); -clk_disable_unprepare (bank->clk);return -EINVAL ; } }else {
@@ -735,7 +733,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev) ret =rockchip_gpiolib_register (bank);if (ret) { -clk_disable_unprepare (bank->clk);mutex_unlock (&bank->deferred_lock);return ret; }
@@ -776,7 +773,6 @@ static void rockchip_gpio_remove(struct platform_device *pdev) {struct rockchip_pin_bank *bank =platform_get_drvdata (pdev); -clk_disable_unprepare (bank->clk);gpiochip_remove (&bank->gpio_chip); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 105/315 iio: imu: adis16550: fix stack leak in trigger handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 474f8928d50b09f7dcf507049f08732640b88b49 upstream.
adis16550_trigger_handler() declares the scan data array on the stack without initializing it. The memcpy() at the bottom fills only the first 28 bytes (TEMP + 6 channels of GYRO/ACCEL data), and iio_push_to_buffers_with_timestamp() writes the s64 timestamp at the 8-byte-aligned offset 32. Bytes 28-31 remain uninitialized stack data which leaks to userspace on ever trigger.
Fix this all by just zero-initializing the structure on the stack.
--- drivers/iio/imu/adis16550.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis16550.c +1 -1
@@ -836,7 +836,7 @@ static irqreturn_t adis16550_trigger_hanu16 dummy;bool valid;struct iio_poll_func *pf = p; -__be32 data[ADIS16550_MAX_SCAN_DATA ]__aligned(8) ; +__be32 data[ADIS16550_MAX_SCAN_DATA ]__aligned(8) = { };struct iio_dev *indio_dev = pf->indio_dev;struct adis16550 *st =iio_priv (indio_dev);struct adis *adis =iio_device_get_drvdata (indio_dev);
Greg Kroah-Hartman
maintainerPATCH 91/307 net: mana: Add NULL guards in teardown path to prevent panic on attach failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dipayaan Roy <[email protected]>
[ Upstream commit 17bfe0a8c014ee1d542ad352cd6a0a505361664a ]
When queue allocation fails partway through, the error cleanup frees and NULLs apc->tx_qp and apc->rxqs. Multiple teardown paths such as mana_remove(), mana_change_mtu() recovery, and internal error handling in mana_alloc_queues() can subsequently call into functions that dereference these pointers without NULL checks:
- mana_chn_setxdp() dereferences apc->rxqs[0], causing a NULL pointer dereference panic (CR2: 0000000000000000 at mana_chn_setxdp+0x26).
- mana_destroy_vport() iterates apc->rxqs without a NULL check.
- mana_fence_rqs() iterates apc->rxqs without a NULL check.
- mana_dealloc_queues() iterates apc->tx_qp without a NULL check.
Add NULL guards for apc->rxqs in mana_fence_rqs(), mana_destroy_vport(), and before the mana_chn_setxdp() call. Add a NULL guard for apc->tx_qp in mana_dealloc_queues() to skip TX queue draining when TX queues were never allocated or already freed.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +41 -29
@@ -1304,6 +1304,9 @@ static void mana_fence_rqs(struct mana_port_context *apc)struct mana_rxq *rxq;int err; +if (!apc->rxqs) +return ; +for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { rxq = apc->rxqs[rxq_idx]; err =mana_fence_rq (apc, rxq);
@@ -2324,13 +2327,16 @@ static void mana_destroy_vport(struct mana_port_context *apc)struct mana_rxq *rxq;u32 rxq_idx; -for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { - rxq = apc->rxqs[rxq_idx]; -if (!rxq) -continue ; +if (apc->rxqs) { -mana_destroy_rxq (apc, rxq, true); - apc->rxqs[rxq_idx] =NULL ; +for (rxq_idx =0 ; rxq_idx < apc->num_queues; rxq_idx++) { + rxq = apc->rxqs[rxq_idx]; +if (!rxq) +continue ; + +mana_destroy_rxq (apc, rxq, true); + apc->rxqs[rxq_idx] =NULL ; + } }mana_destroy_txq (apc);
@@ -2633,7 +2639,8 @@ static int mana_dealloc_queues(struct net_device *ndev)if (apc->port_is_up)return -EINVAL ; -mana_chn_setxdp (apc,NULL ); +if (apc->rxqs) +mana_chn_setxdp (apc,NULL );if (gd->gdma_context->is_pf)mana_pf_deregister_filter (apc);
@@ -2651,33 +2658,38 @@ static int mana_dealloc_queues(struct net_device *ndev)* number of queues. */ -for (i =0 ; i < apc->num_queues; i++) { - txq = &apc->tx_qp[i].txq; - tsleep =1000 ; -while (atomic_read (&txq->pending_sends) >0 && -time_before (jiffies, timeout)) { -usleep_range (tsleep, tsleep +1000 ); - tsleep <<=1 ; - } -if (atomic_read (&txq->pending_sends)) { - err =pcie_flr (to_pci_dev (gd->gdma_context->dev)); -if (err) { -netdev_err (ndev,"flr failed %d with %d pkts pending in txq %u\n" , - err,atomic_read (&txq->pending_sends), - txq->gdma_txq_id); +if (apc->tx_qp) { +for (i =0 ; i < apc->num_queues; i++) { + txq = &apc->tx_qp[i].txq; + tsleep =1000 ; +while (atomic_read (&txq->pending_sends) >0 && +time_before (jiffies, timeout)) { +usleep_range (tsleep, tsleep +1000 ); + tsleep <<=1 ; + } +if (atomic_read (&txq->pending_sends)) { + err = +pcie_flr (to_pci_dev (gd->gdma_context->dev)); +if (err) { +netdev_err (ndev,"flr failed %d with %d pkts pending in txq %u\n" , + err, +atomic_read (&txq->pending_sends), + txq->gdma_txq_id); + } +break ; } -break ; } - } -for (i =0 ; i < apc->num_queues; i++) { - txq = &apc->tx_qp[i].txq; -while ((skb =skb_dequeue (&txq->pending_skbs))) { -mana_unmap_skb (skb, apc); -dev_kfree_skb_any (skb); +for (i =0 ; i < apc->num_queues; i++) { + txq = &apc->tx_qp[i].txq; +while ((skb =skb_dequeue (&txq->pending_skbs))) { +mana_unmap_skb (skb, apc); +dev_kfree_skb_any (skb); + } +atomic_set (&txq->pending_sends,0 ); } -atomic_set (&txq->pending_sends,0 ); } +/* We're 100% sure the queues can no longer be woken up, because * we're sure now mana_poll_tx_cq() can't be running. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 82/315 Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
[ Upstream commit 525daaea459fc215f432de1b8debbd9144bf97b0 ]
Since hci_dev_close_sync() can now be called during the reset path, we should also set HCI_CMD_DRAIN_WORKQUEUE. This avoids queuing timeouts while the hdev workqueue is being drained.
--- net/bluetooth/hci_sync.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/hci_sync.c +8 -0
@@ -5246,6 +5246,12 @@ int hci_dev_close_sync(struct hci_dev *hdev)bt_dev_dbg (hdev,"" ); +/* Set HCI_DRAIN_WORKQUEUE flag to prevent queuing work during +* reset/close. See hci_cmd_work() and handle_cmd_cnt_and_timer(). +*/ +hci_dev_set_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE ); +synchronize_rcu (); +if (hci_dev_test_flag (hdev,HCI_UNREGISTER )) {disable_delayed_work (&hdev->power_off);disable_delayed_work (&hdev->ncmd_timer);
@@ -5269,6 +5275,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)if (!test_and_clear_bit (HCI_UP , &hdev->flags)) {cancel_delayed_work_sync (&hdev->cmd_timer); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );return err; }
@@ -5368,6 +5375,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)/* Clear flags */ hdev->flags &=BIT (HCI_RAW );hci_dev_clear_volatile_flags (hdev); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );memset (hdev->eir,0 ,sizeof (hdev->eir));memset (hdev->dev_class,0 ,sizeof (hdev->dev_class));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 68/307 ethtool: pse-pd: fix missing ethnl_ops_complete()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit ab5bf428fb6bd361163c7247b92750d1d24ca2ed ]
pse_prepare_data() is missing ethnl_ops_complete() if ethnl_req_get_phydev() returned an error. Move getting phydev up so that we don't have to worry about this (similar order to linkstate_prepare_data()).
Note that phydev may still be NULL (this is checked in pse_get_pse_attributes()), the goal isn't really to avoid the _begin() / _complete() calls, only to simplify the error handling.
While at it propagate the original error. Why this code overrides the error with -ENODEV but !phydev generates -EOPNOTSUPP is unclear to me...
--- net/ethtool/pse-pd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/ethtool/pse-pd.c +5 -5
@@ -60,14 +60,14 @@ static int pse_prepare_data(const struct ethnl_req_info *req_base,struct phy_device *phydev;int ret; - ret =ethnl_ops_begin (dev); -if (ret <0 ) -return ret; - phydev =ethnl_req_get_phydev (req_base, tb,ETHTOOL_A_PSE_HEADER , info->extack);if (IS_ERR (phydev)) -return -ENODEV ; +return PTR_ERR (phydev); + + ret =ethnl_ops_begin (dev); +if (ret <0 ) +return ret; ret =pse_get_pse_attributes (phydev, info->extack, data);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 63/307 ASoC: codecs: simple-mux: Fix enum control bounds check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit f63ad68e18d774a5d15cd7e405ead63f6b322679 ]
simple_mux_control_put() rejects values greater than e->items, but enum control values are zero based. For the two-entry mux used by this driver, valid values are 0 and 1, so value 2 must be rejected as well.
Accepting e->items can store an invalid mux state, pass it to the GPIO setter, and pass it on to the DAPM mux update path where it is used as an index into the enum text array.
Use the same >= e->items check used by the ASoC enum helpers.
--- sound/soc/codecs/simple-mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/simple-mux.c +1 -1
@@ -49,7 +49,7 @@ static int simple_mux_control_put(struct snd_kcontrol *kcontrol,struct snd_soc_component *c =snd_soc_dapm_to_component (dapm);struct simple_mux *priv =snd_soc_component_get_drvdata (c); -if (ucontrol->value.enumerated.item[0 ] > e->items) +if (ucontrol->value.enumerated.item[0 ] >= e->items)return -EINVAL ;if (priv->mux == ucontrol->value.enumerated.item[0 ])
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 109/315 usb: typec: tcpm: bound altmode_desc[] per iteration in svdm_consume_modes()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 3389c149c68c3fea61910ad5d34f7bf3bff44e32 upstream.
svdm_consume_modes() checks pmdata->altmodes against the array size once before the loop over the count, but forgot to check the bound at every point in the loop.
In the well-behaved SVDM discovery flow this is harmless because each of at most SVID_DISCOVERY_MAX SVIDs contributes at most MODE_DISCOVERY_MAX modes, exactly filling altmode_desc[ALTMODE_DISCOVERY_MAX]. But the CMDT_RSP_ACK handler in tcpm_pd_svdm() does not correlate an incoming ACK with any request the port actually sent. Once port->partner is set, an unsolicited Discover Modes ACK is consumed unconditionally. A broken or malicious port partner can therefore drive altmodes to ALTMODE_DISCOVERY_MAX - 1 via the normal flow, and then send one extra Discover Modes ACK with seven VDOs. Because the pre-loop check passes, the loop could then writes up to five entries past altmode_desc[]. For mode_data_prime the next field in struct tcpm_port is the partner_altmode[] pointer array, which then receives partner-chosen SVID/VDO bytes.
Move the bound check inside the loop so the array can never be indexed past ALTMODE_DISCOVERY_MAX regardless of how many VDOs the partner supplies or how the function was reached.
--- drivers/usb/typec/tcpm/tcpm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +4 -8
@@ -1832,23 +1832,19 @@ static void svdm_consume_modes(struct tcswitch (rx_sop_type) {case TCPC_TX_SOP_PRIME : pmdata = &port->mode_data_prime; -if (pmdata->altmodes >=ARRAY_SIZE (port->plug_prime_altmode)) { -/* Already logged in svdm_consume_svids() */ -return ; - }break ;case TCPC_TX_SOP : pmdata = &port->mode_data; -if (pmdata->altmodes >=ARRAY_SIZE (port->partner_altmode)) { -/* Already logged in svdm_consume_svids() */ -return ; - }break ;default :return ; }for (i =1 ; i < cnt; i++) { +if (pmdata->altmodes >=ALTMODE_DISCOVERY_MAX ) { +/* Already logged in svdm_consume_svids() */ +return ; + } paltmode = &pmdata->altmode_desc[pmdata->altmodes];memset (paltmode,0 ,sizeof (*paltmode));
Greg Kroah-Hartman
maintainerPATCH 93/307 ipv6: fix possible infinite loop in rt6_fill_node()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 9f72412bcf60144f252b0d6205106abf14344abc ]
Sashiko reported this issue [1]. Apply the same fix as
commit f8d8ce1b515a ("ipv6: fix possible infinite loop in fib6_info_uses_dev()").
Writers holding tb6_lock can list_del_rcu(&rt->fib6_siblings) without waiting for RCU readers; rt->fib6_siblings.next then still points into the old ring and this softirq-side walker never reaches &rt->fib6_siblings, causing a CPU stall. fib6_del_route() always WRITE_ONCE()s rt->fib6_nsiblings to 0 before list_del_rcu(), so an inside-loop check is a reliable detach signal.
[1] https://sashiko.dev/#/patchset/20260526020227.4857-1-jiayuan.chen%40linux.dev
--- net/ipv6/route.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/route.c +2 -0
@@ -5812,6 +5812,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, goto nla_put_failure; } +if (!READ_ONCE (rt->fib6_nsiblings)) +break ; }rcu_read_unlock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 110/315 usb: typec: ucsi: displayport: NAK DP_CMD_CONFIGURE without a payload VDO
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 167dd8d12226587ee554f520aed0256b7769cd5d upstream.
ucsi_displayport_vdm() handles a DP_CMD_CONFIGURE by copying the first payload VDO from data[], but unlike the equivalent handler in altmodes/displayport.c it does not check that count covers a VDO beyond the header. A header-only Configure VDM (count == 1) would read one u32 past the caller's array.
In the normal UCSI path the caller controls count, so this is hardening for non-standard delivery paths. NAK and bail when no configuration VDO is present, matching the generic DP altmode driver's existing guard.
--- drivers/usb/typec/ucsi/displayport.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/typec/ucsi/displayport.c +4 -0
@@ -240,6 +240,10 @@ static int ucsi_displayport_vdm(struct t dp->header |=VDO_CMDT (CMDT_RSP_ACK );break ;case DP_CMD_CONFIGURE : +if (count <2 ) { + dp->header |=VDO_CMDT (CMDT_RSP_NAK ); +break ; + } dp->data.conf = *data;if (ucsi_displayport_configure (dp)) { dp->header |=VDO_CMDT (CMDT_RSP_NAK );
Greg Kroah-Hartman
maintainerPATCH 94/307 ipv6: fix possible infinite loop in fib6_select_path()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 9c7da87c2dc860bb17ca1ece942495d28b1ce3b9 ]
Found while auditing the same pattern Sashiko reported in rt6_fill_node() [1]. Apply the same fix as
commit f8d8ce1b515a ("ipv6: fix possible infinite loop in fib6_info_uses_dev()").
Writers holding tb6_lock can list_del_rcu(&first->fib6_siblings) without waiting for RCU readers; first->fib6_siblings.next then still points into the old ring and this softirq-side walker never reaches &first->fib6_siblings as its terminator. fib6_purge_rt() always WRITE_ONCE()s first->fib6_nsiblings to 0 before list_del_rcu(), so an inside-loop check is a reliable detach signal.
[1] https://sashiko.dev/#/patchset/20260526020227.4857-1-jiayuan.chen%40linux.dev
--- net/ipv6/route.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/route.c +3 -0
@@ -482,6 +482,9 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,const struct fib6_nh *nh = sibling->fib6_nh;int nh_upper_bound; +if (!READ_ONCE (first->fib6_nsiblings)) +break ; + nh_upper_bound =atomic_read (&nh->fib_nh_upper_bound);if (hash > nh_upper_bound)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 111/315 usb: typec: altmodes/displayport: validate count before reading Status Update VDO
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 8a18f896e667df491331371b55d4ad644dc51d60 upstream.
A broken/malicious device can send the incorrect count for a status update VDO, which will cause the kernel to read uninitialized stack data and send it off elsewhere.
Fix this up by correctly verifying the count for the update object.
--- drivers/usb/typec/altmodes/displayport.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/typec/altmodes/displayport.c +2 -0
@@ -405,6 +405,8 @@ static int dp_altmode_vdm(struct typec_a dp->state =DP_STATE_EXIT_PRIME ;break ;case DP_CMD_STATUS_UPDATE : +if (count <2 ) +break ; dp->data.status = *vdo; ret =dp_altmode_status_update (dp);break ;
Greg Kroah-Hartman
maintainerPATCH 95/307 net: skbuff: fix pskb_carve leaking zcopy pages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit ff6e798c2eac3ebd0501ad7e796f583fab928de8 ]
When SKBFL_MANAGED_FRAG_REFS is set, frag pages are not refcounted but their lifetime is controlled by the attached ubuf_info. To make a copy of the skb_shared_info, we either should clear the flag and reference the frags, or keep the flag and have frags unreferenced.
pskb_carve_inside_header() and pskb_carve_inside_nonlinear() don't follow the rule and thus can leak page references. Let's clear SKBFL_MANAGED_FRAG_REFS from the original skb to fix it. It's the simplest way to address it, but there are more performant ways to do that if it ever becomes a problem.
--- net/core/skbuff.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/core/skbuff.c +10 -0
@@ -6689,6 +6689,11 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off,skb_copy_from_linear_data_offset (skb, off, data, new_hlen); skb->len -= off; +/* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it +* while refcounting frags below. +*/ +skb_zcopy_downgrade_managed (skb); + memcpy((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info,
@@ -6801,6 +6806,11 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,return -ENOMEM ; size =SKB_WITH_OVERHEAD (size); +/* Remove SKBFL_MANAGED_FRAG_REFS instead of trying to honour it +* while refcounting frags below. +*/ +skb_zcopy_downgrade_managed (skb); +memcpy ((struct skb_shared_info *)(data + size), skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0]));if (skb_orphan_frags (skb, gfp_mask)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 112/315 usb: typec: wcove: dont write past struct pd_message in wcove_read_rx_buffer()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 4af7ad0e6d7aa4403dbb1dac7b9659b0421efcaa upstream.
wcove_read_rx_buffer() copies the PD RX FIFO into the caller's struct pd_message with
for (i = 0; i < USBC_RXINFO_RXBYTES(info); i++) regmap_read(wcove->regmap, USBC_RX_DATA + i, msg + i);
which has two problems:
USBC_RXINFO_RXBYTES() is a 5-bit field (max 31) while struct pd_message is 30 bytes (__le16 header + __le32 payload[PD_MAX_PAYLOAD], packed). The byte count latched in RXINFO is the number of bytes the port partner put on the wire, so a malicious partner that transmits a 31-byte frame can drive the loop one byte past the destination if the WCOVE BMC receiver does not enforce the PD object-count limit in hardware. The existing FIXME flagged this as unverified.
Independently, regmap_read() takes an unsigned int * and stores a full unsigned int at the destination. Passing the byte pointer msg + i means each iteration writes four bytes; the high three are zero (val_bits is
8) and are normally overwritten by the next iteration, but the final iteration's high bytes are not. With RXBYTES == 30 the i == 29 iteration already writes three zero bytes past msg, which sits on the IRQ thread's stack in wcove_typec_irq().
Clamp the loop to sizeof(struct pd_message) and read each register into a local before storing only its low byte, so the copy can never exceed the destination regardless of what RXINFO reports.
--- drivers/usb/typec/tcpm/wcove.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/usb/typec/tcpm/wcove.c +8 -5
@@ -444,9 +444,11 @@ static int wcove_start_toggling(struct treturn regmap_write (wcove->regmap,USBC_CONTROL1 , usbc_ctrl); } -static int wcove_read_rx_buffer (struct wcove_typec *wcove,void *msg) +static int wcove_read_rx_buffer (struct wcove_typec *wcove, +struct pd_message *msg) { -unsigned int info; +unsigned int info, val, len; +u8 *buf = (u8 *)msg;int ret;int i;
@@ -454,12 +456,13 @@ static int wcove_read_rx_buffer(struct wif (ret)return ret; -/* FIXME: Check that USBC_RXINFO_RXBYTES(info) matches the header */ + len =min (USBC_RXINFO_RXBYTES (info),sizeof (*msg)); -for (i =0 ; i <USBC_RXINFO_RXBYTES (info); i++) { - ret =regmap_read (wcove->regmap,USBC_RX_DATA + i, msg + i); +for (i =0 ; i < len; i++) { + ret =regmap_read (wcove->regmap,USBC_RX_DATA + i, &val);if (ret)return ret; + buf[i] = val; } return regmap_write(wcove->regmap, USBC_RXSTATUS,
Greg Kroah-Hartman
maintainerPATCH 96/307 perf: Fix dangling cgroup pointer in cpuctx
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
[ Upstream commit 3b7a34aebbdf2a4b7295205bf0c654294283ec82 ]
Commit a3c3c6667("perf/core: Fix child_total_time_enabled accounting bug at task exit") moves the event->state update to before list_del_event(). This makes the event->state test in list_del_event() always false; never calling perf_cgroup_event_disable().
As a result, cpuctx->cgrp won't be cleared properly; causing havoc.
--- kernel/events/core.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
kernel/events/core.c +4 -12
@@ -2096,18 +2096,6 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)if (event->group_leader == event)del_event_from_groups (event, ctx); -/* -* If event was in error state, then keep it -* that way, otherwise bogus counts will be -* returned on read(). The only way to get out -* of error state is by explicit re-enabling -* of the event -*/ -if (event->state >PERF_EVENT_STATE_OFF ) { -perf_cgroup_event_disable (event, ctx); -perf_event_set_state (event,PERF_EVENT_STATE_OFF ); - } - ctx->generation++; event->pmu_ctx->nr_events--; }
@@ -2457,6 +2445,10 @@ __perf_remove_from_context(struct perf_event *event, state =PERF_EVENT_STATE_DEAD ; }event_sched_out (event, ctx); + +if (event->state >PERF_EVENT_STATE_OFF ) +perf_cgroup_event_disable (event, ctx); +perf_event_set_state (event,min (event->state, state));if (flags &DETACH_GROUP )perf_group_detach (event);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 113/315 usb: typec: tcpm/tcpci_maxim: validate header NDO against RX_BYTE_CNT
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit aa2f716327be1818e1cb156da8a2844804aaec2f upstream.
A broken/malicious port can transmit a CRC-valid frame whose header advertises up to seven data objects but whose body carries fewer than that. Check for this, and rightfully reject the message, instead of reading from uninitialized stack memory.
--- drivers/usb/typec/tcpm/tcpci_maxim_core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/typec/tcpm/tcpci_maxim_core.c +9 -0
@@ -186,6 +186,15 @@ static void process_rx(struct max_tcpci_ rx_buf_ptr = rx_buf +TCPC_RECEIVE_BUFFER_RX_BYTE_BUF_OFFSET ; msg.header =cpu_to_le16 (*(u16 *)rx_buf_ptr); rx_buf_ptr = rx_buf_ptr +sizeof (msg.header); + +if (count <TCPC_RECEIVE_BUFFER_RX_BYTE_BUF_OFFSET +sizeof (msg.header) + +pd_header_cnt_le (msg.header) *sizeof (msg.payload[0 ])) { +max_tcpci_write16 (chip,TCPC_ALERT ,TCPC_ALERT_RX_STATUS ); +dev_err (chip->dev,"Invalid TCPC_RX_BYTE_CNT %d for header cnt %d\n" , + count,pd_header_cnt_le (msg.header)); +return ; + } +for (payload_index =0 ; payload_index <pd_header_cnt_le (msg.header); payload_index++, rx_buf_ptr +=sizeof (msg.payload[0 ])) msg.payload[payload_index] =cpu_to_le32 (*(u32 *)rx_buf_ptr);
Greg Kroah-Hartman
maintainerPATCH 97/307 batman-adv: v: stop OGMv2 on disabled interface
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f8ce8b8331a1bc44ad4905886a482214d428b253 upstream.
When a batadv_hard_iface is disabled, its mesh_iface pointer is set to NULL. However, batadv_v_ogm_send_meshif() may still dispatch OGMs via batadv_v_ogm_queue_on_if() for interfaces that have since lost their mesh_iface association. This results in a NULL pointer dereference when batadv_v_ogm_queue_on_if() unconditionally calls netdev_priv() on the now NULL hard_iface->mesh_iface to retrieve the batadv_priv.
It is necessary to ensure that the batadv_v_ogm_queue_on_if() checks that it is using the same mesh_iface for which batadv_v_ogm_send_meshif() was called.
--- net/batman-adv/bat_v_ogm.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
net/batman-adv/bat_v_ogm.c +21 -12
@@ -115,14 +115,14 @@ static void batadv_v_ogm_start_timer(struct batadv_priv *bat_priv)/** * batadv_v_ogm_send_to_if() - send a batman ogm using a given interface +* @bat_priv: the bat priv with all the mesh interface information * @skb: the OGM to send * @hard_iface: the interface to use to send the OGM */ -static void batadv_v_ogm_send_to_if (struct sk_buff *skb, +static void batadv_v_ogm_send_to_if (struct batadv_priv *bat_priv, +struct sk_buff *skb,struct batadv_hard_iface *hard_iface) { -struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); -if (hard_iface->if_status !=BATADV_IF_ACTIVE ) {kfree_skb (skb);return ;
@@ -189,6 +189,7 @@ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface)/** * batadv_v_ogm_aggr_send() - flush & send aggregation queue +* @bat_priv: the bat priv with all the mesh interface information * @hard_iface: the interface with the aggregation queue to flush * * Aggregates all OGMv2 packets currently in the aggregation queue into a
@@ -198,7 +199,8 @@ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface)* * Caller needs to hold the hard_iface->bat_v.aggr_list.lock. */ -static void batadv_v_ogm_aggr_send (struct batadv_hard_iface *hard_iface) +static void batadv_v_ogm_aggr_send (struct batadv_priv *bat_priv, +struct batadv_hard_iface *hard_iface) {unsigned int aggr_len = hard_iface->bat_v.aggr_len;struct sk_buff *skb_aggr;
@@ -228,27 +230,32 @@ static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface)consume_skb (skb); } -batadv_v_ogm_send_to_if (skb_aggr, hard_iface); +batadv_v_ogm_send_to_if (bat_priv, skb_aggr, hard_iface); }/** * batadv_v_ogm_queue_on_if() - queue a batman ogm on a given interface +* @bat_priv: the bat priv with all the mesh interface information * @skb: the OGM to queue * @hard_iface: the interface to queue the OGM on */ -static void batadv_v_ogm_queue_on_if (struct sk_buff *skb, +static void batadv_v_ogm_queue_on_if (struct batadv_priv *bat_priv, +struct sk_buff *skb,struct batadv_hard_iface *hard_iface) { -struct batadv_priv *bat_priv =netdev_priv (hard_iface->soft_iface); +if (hard_iface->soft_iface != bat_priv->soft_iface) { +kfree_skb (skb); +return ; + }if (!atomic_read (&bat_priv->aggregated_ogms)) { -batadv_v_ogm_send_to_if (skb, hard_iface); +batadv_v_ogm_send_to_if (bat_priv, skb, hard_iface);return ; }spin_lock_bh (&hard_iface->bat_v.aggr_list.lock);if (!batadv_v_ogm_queue_left (skb, hard_iface)) -batadv_v_ogm_aggr_send (hard_iface); +batadv_v_ogm_aggr_send (bat_priv, hard_iface); hard_iface->bat_v.aggr_len +=batadv_v_ogm_len (skb);__skb_queue_tail (&hard_iface->bat_v.aggr_list, skb);
@@ -347,7 +354,7 @@ static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv)break ; } -batadv_v_ogm_queue_on_if (skb_tmp, hard_iface); +batadv_v_ogm_queue_on_if (bat_priv, skb_tmp, hard_iface);batadv_hardif_put (hard_iface); }rcu_read_unlock ();
@@ -387,12 +394,14 @@ void batadv_v_ogm_aggr_work(struct work_struct *work) {struct batadv_hard_iface_bat_v *batv;struct batadv_hard_iface *hard_iface; +struct batadv_priv *bat_priv; batv = container_of(work, struct batadv_hard_iface_bat_v, aggr_wq.work); hard_iface = container_of(batv, struct batadv_hard_iface, bat_v); + bat_priv =netdev_priv (hard_iface->soft_iface);spin_lock_bh (&hard_iface->bat_v.aggr_list.lock); -batadv_v_ogm_aggr_send (hard_iface); +batadv_v_ogm_aggr_send (bat_priv, hard_iface);spin_unlock_bh (&hard_iface->bat_v.aggr_list.lock);batadv_v_ogm_start_queue_timer (hard_iface);
@@ -582,7 +591,7 @@ static void batadv_v_ogm_forward(struct batadv_priv *bat_priv, if_outgoing->net_dev->name,ntohl (ogm_forward->throughput), ogm_forward->ttl, if_incoming->net_dev->name); -batadv_v_ogm_queue_on_if (skb, if_outgoing); +batadv_v_ogm_queue_on_if (bat_priv, skb, if_outgoing); out:batadv_orig_ifinfo_put (orig_ifinfo);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 114/315 usb: typec: ucsi: validate connector number in ucsi_connector_change()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 288a81a8507052bcfbf884d39a463c44c42c5fd9 upstream.
The connector number in a UCSI CCI notification is a 7-bit field supplied by the PPM. ucsi_connector_change() uses it to index the ucsi->connector[] array without checking it against the number of connectors the PPM reported at init time, so a buggy or malicious PPM (EC firmware, or an I2C-attached UCSI controller on the ccg / stm32g0 / glink transports) can drive schedule_work() on memory past the end of the array.
Reject connector numbers that are zero or exceed cap.num_connectors before dereferencing the array.
--- drivers/usb/typec/ucsi/ucsi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +10 -1
@@ -1325,13 +1325,22 @@ out_unlock:*/ void ucsi_connector_change (struct ucsi *ucsi,u8 num) { -struct ucsi_connector *con = &ucsi->connector[num -1 ]; +struct ucsi_connector *con;if (!(ucsi->ntfy &UCSI_ENABLE_NTFY_CONNECTOR_CHANGE )) {dev_dbg (ucsi->dev,"Early connector change event\n" );return ; } +if (!num || num > ucsi->cap.num_connectors) { +dev_warn_ratelimited (ucsi->dev, +"Bogus connector change on %u (max %u)\n" , + num, ucsi->cap.num_connectors); +return ; + } + + con = &ucsi->connector[num -1 ]; +if (!test_and_set_bit (EVENT_PENDING , &ucsi->flags))schedule_work (&con->work); }
Greg Kroah-Hartman
maintainerPATCH 98/307 batman-adv: tvlv: abort OGM send on tvlv append failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 501368506563e151b322c8c3f228b796e615b90d upstream.
batadv_tvlv_container_ogm_append() could fail in two ways: a memory allocation failure when resizing the packet buffer, or the tvlv data exceeding U16_MAX bytes. In both cases the function previously returned the old (now stale) tvlv_value_len rather than signalling an error, causing the OGM/OGM2 send path to transmit a packet whose TVLV length field no longer matched the actual buffer contents. And because it also didn't fill in the new TVLV data, sending either uninitialized or corrupted data on the wire.
All errors in batadv_tvlv_container_ogm_append() must be forwarded to the caller. And the caller must abort the send of the OGM2. For B.A.T.M.A.N. IV, it is currently not allowed to abort the send. The non-TVLV part of the OGM must be queued up instead.
--- net/batman-adv/bat_iv_ogm.c | 16 +++++++++++++--- net/batman-adv/bat_v_ogm.c | 26 ++++++++++++++------------ net/batman-adv/tvlv.c | 17 ++++++++++++----- net/batman-adv/tvlv.h | 2 +- 4 files changed, 40 insertions(+), 21 deletions(-)
net/batman-adv/bat_iv_ogm.c +13 -3
@@ -781,6 +781,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)u32 seqno;u16 tvlv_len =0 ;unsigned long send_time; +int ret;lockdep_assert_held (&hard_iface->bat_iv.ogm_buff_mutex);
@@ -804,9 +805,18 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)* appended as it may alter the tt tvlv container */ batadv_tt_local_commit_changes (bat_priv); - tvlv_len =batadv_tvlv_container_ogm_append (bat_priv, ogm_buff, - ogm_buff_len, -BATADV_OGM_HLEN ); + ret =batadv_tvlv_container_ogm_append (bat_priv, ogm_buff, + ogm_buff_len, +BATADV_OGM_HLEN ); +if (ret <0 ) { +/* OGMs must be queued even when the buffer allocation for +* TVLVs failed. just fall back to the non-TVLV version +*/ + ret =0 ; + *ogm_buff_len =BATADV_OGM_HLEN ; + } + + tvlv_len = ret; } batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
net/batman-adv/bat_v_ogm.c +14 -12
@@ -271,9 +271,9 @@ static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv)struct batadv_hard_iface *hard_iface;struct batadv_ogm2_packet *ogm_packet;struct sk_buff *skb, *skb_tmp; -unsigned char *ogm_buff; -int ogm_buff_len; -u16 tvlv_len =0 ; +unsigned char **ogm_buff; +int *ogm_buff_len; +u16 tvlv_len;int ret;lockdep_assert_held (&bat_priv->bat_v.ogm_buff_mutex);
@@ -281,25 +281,27 @@ static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv)if (atomic_read (&bat_priv->mesh_state) ==BATADV_MESH_DEACTIVATING ) goto out; - ogm_buff = bat_priv->bat_v.ogm_buff; - ogm_buff_len = bat_priv->bat_v.ogm_buff_len; + ogm_buff = &bat_priv->bat_v.ogm_buff; + ogm_buff_len = &bat_priv->bat_v.ogm_buff_len; +/* tt changes have to be committed before the tvlv data is * appended as it may alter the tt tvlv container */ batadv_tt_local_commit_changes (bat_priv); - tvlv_len =batadv_tvlv_container_ogm_append (bat_priv, &ogm_buff, - &ogm_buff_len, -BATADV_OGM2_HLEN ); + ret =batadv_tvlv_container_ogm_append (bat_priv, ogm_buff, + ogm_buff_len, +BATADV_OGM2_HLEN ); +if (ret <0 ) + goto reschedule; - bat_priv->bat_v.ogm_buff = ogm_buff; - bat_priv->bat_v.ogm_buff_len = ogm_buff_len; + tvlv_len = ret; - skb =netdev_alloc_skb_ip_align (NULL ,ETH_HLEN + ogm_buff_len); + skb =netdev_alloc_skb_ip_align (NULL ,ETH_HLEN + *ogm_buff_len);if (!skb) goto reschedule;skb_reserve (skb,ETH_HLEN ); -skb_put_data (skb, ogm_buff, ogm_buff_len); +skb_put_data (skb, *ogm_buff, *ogm_buff_len); ogm_packet = (struct batadv_ogm2_packet *)skb->data; ogm_packet->seqno =htonl (atomic_read (&bat_priv->bat_v.ogm_seqno));
net/batman-adv/tvlv.c +12 -5
@@ -8,6 +8,7 @@#include <linux/byteorder/generic.h> #include <linux/container_of.h> +#include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h> #include <linux/if_ether.h>
@@ -306,9 +307,10 @@ static bool batadv_tvlv_realloc_packet_buff(unsigned char **packet_buff,* The ogm packet might be enlarged or shrunk depending on the current size * and the size of the to-be-appended tvlv containers. * -* Return: size of all appended tvlv containers in bytes. +* Return: size of all appended tvlv containers in bytes (max U16_MAX), negative +* if operation failed */ -u16 batadv_tvlv_container_ogm_append (struct batadv_priv *bat_priv, +int batadv_tvlv_container_ogm_append (struct batadv_priv *bat_priv,unsigned char **packet_buff,int *packet_buff_len,int packet_min_len) {
@@ -316,6 +318,7 @@ u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,struct batadv_tvlv_hdr *tvlv_hdr;u16 tvlv_value_len;void *tvlv_value; +int tvlv_len_ret;bool ret;spin_lock_bh (&bat_priv->tvlv.container_list_lock);
@@ -323,9 +326,12 @@ u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, ret =batadv_tvlv_realloc_packet_buff (packet_buff, packet_buff_len, packet_min_len, tvlv_value_len); - -if (!ret) +if (!ret) { + tvlv_len_ret = -ENOMEM ; goto end; + } + + tvlv_len_ret = tvlv_value_len;if (!tvlv_value_len) goto end;
@@ -344,7 +350,8 @@ u16 batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, end:spin_unlock_bh (&bat_priv->tvlv.container_list_lock); -return tvlv_value_len; + +return tvlv_len_ret; }/**
net/batman-adv/tvlv.h +1 -1
@@ -16,7 +16,7 @@void batadv_tvlv_container_register (struct batadv_priv *bat_priv,u8 type,u8 version,void *tvlv_value,u16 tvlv_value_len); -u16 batadv_tvlv_container_ogm_append (struct batadv_priv *bat_priv, +int batadv_tvlv_container_ogm_append (struct batadv_priv *bat_priv,unsigned char **packet_buff,int *packet_buff_len,int packet_min_len); void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 115/315 USB: serial: safe_serial: fix memory corruption with small endpoint
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 438061ed1ad85e6743e2dce826671772d81089ec upstream.
Make sure that the bulk-out buffer size is at least eight bytes to avoid user-controlled slab corruption in "safe" mode should a malicious device report a smaller size.
--- drivers/usb/serial/safe_serial.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/serial/safe_serial.c +11 -0
@@ -259,6 +259,7 @@ static int safe_prepare_write_buffer(strstatic int safe_startup (struct usb_serial *serial) {struct usb_interface_descriptor *desc; +int bulk_out_size;if (serial->dev->descriptor.bDeviceClass !=CDC_DEVICE_CLASS )return -ENODEV ;
@@ -279,6 +280,16 @@ static int safe_startup(struct usb_seriadefault :return -EINVAL ; } + +/* +* The bulk-out buffer needs to be large enough for the two-byte +* trailer in safe mode, but assume anything smaller than eight bytes +* is broken. +*/ + bulk_out_size = serial->port[0 ]->bulk_out_size; +if (bulk_out_size >0 && bulk_out_size <8 ) +return -EINVAL ; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 99/307 batman-adv: tt: reject oversized local TVLV buffers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 1e9fab756f8395096d5bba7be0c373c4c8f5d165 upstream.
The commit 3a359bf5c61d ("batman-adv: reject oversized global TT response buffers") added a check to ensure that a global return buffer size can be stored in an u16. The same buffer handling also exists for the local data buffer but was not touched.
A similar check should be also be in place for the local TVLV buffer. It doesn't have the similar attack surface because it is only generated from locally discovered MAC addresses but the dynamic nature could still cause temporarily to large buffers.
--- net/batman-adv/translation-table.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/batman-adv/translation-table.c +5 -3
@@ -924,12 +924,12 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, {struct batadv_tvlv_tt_vlan_data *tt_vlan;struct batadv_softif_vlan *vlan; +size_t change_offset;u16 num_vlan =0 ;u16 vlan_entries =0 ;u16 total_entries =0 ;u16 tvlv_len;u8 *tt_change_ptr; -int change_offset;spin_lock_bh (&bat_priv->softif_vlan_list_lock);hlist_for_each_entry (vlan, &bat_priv->softif_vlan_list, list) {
@@ -948,8 +948,10 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv,if (*tt_len <0 ) *tt_len =batadv_tt_len (total_entries); - tvlv_len = *tt_len; - tvlv_len += change_offset; +if (check_add_overflow (*tt_len, change_offset, &tvlv_len)) { + tvlv_len =0 ; + goto out; + } *tt_data =kmalloc (tvlv_len,GFP_ATOMIC );if (!*tt_data) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 116/315 media: rc: igorplugusb: fix control request setup packet
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henri A <[email protected]>
commit 171022c7d594c133a45f92357a2a91475edabe20 upstream.
Commit eac69475b01f ("media: rc: igorplugusb: heed coherency rules") changed the control request storage from an embedded struct to an allocated pointer so it can obey DMA coherency rules.
However, the driver still passes &ir->request to usb_fill_control_urb(). That points the URB setup packet at the pointer field itself rather than at the allocated struct usb_ctrlrequest.
USB core then interprets pointer bytes as the setup packet. This can produce an invalid bRequestType and trigger the control direction warning reported by syzbot:
usb 2-1: BOGUS control dir, pipe 80003580 doesn't match bRequestType 0
Pass ir->request itself as the setup packet.
--- drivers/media/rc/igorplugusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/igorplugusb.c +1 -1
@@ -184,7 +184,7 @@ static int igorplugusb_probe(struct usb_if (!ir->buf_in) goto fail;usb_fill_control_urb (ir->urb, udev, -usb_rcvctrlpipe (udev,0 ), (uint8_t *)&ir->request, +usb_rcvctrlpipe (udev,0 ), (uint8_t *)ir->request, ir->buf_in,MAX_PACKET , igorplugusb_callback, ir);usb_make_path (udev, ir->phys,sizeof (ir->phys));
Greg Kroah-Hartman
maintainerPATCH 100/307 batman-adv: bla: avoid NULL-ptr deref for claim via dropped interface
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f80d3d98d2ff78d9e2fe5d68b1f45948c4f7bd24 upstream.
Without rtnl_lock held, a hardif might be retrieved as primary interface of a meshif, but then (while operating on this interface) getting decoupled from the mesh interface. In this case, the meshif still exists but the pointer from the primary hardif to the meshif is set to NULL.
The mesh_iface must be checked first to be non-NULL before continuing to send an ARP request using meshif.
--- net/batman-adv/bridge_loop_avoidance.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +4 -2
@@ -356,12 +356,14 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac, sizeof(local_claim_dest)); local_claim_dest.type = claimtype; - soft_iface = primary_if->soft_iface; + soft_iface =READ_ONCE (primary_if->soft_iface); +if (!soft_iface) + goto out; skb = arp_create(ARPOP_REPLY, ETH_P_ARP, /* IP DST: 0.0.0.0 */ zeroip, - primary_if->soft_iface, + soft_iface, /* IP SRC: 0.0.0.0 */ zeroip,/* Ethernet DST: Broadcast */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 117/315 Input: ims-pcu - fix usb_free_coherent() size in ims_pcu_buffers_free()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit dab48a7e74e6a394f3aa0461a2b1fb0c7b38fcb8 upstream.
The input buffer size is pcu->max_in_size, but pcu->max_out_size is passed to usb_free_coherent().
Change size to match the allocation size.
--- drivers/input/misc/ims-pcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/ims-pcu.c +1 -1
@@ -1604,7 +1604,7 @@ static void ims_pcu_buffers_free(structusb_kill_urb (pcu->urb_in);usb_free_urb (pcu->urb_in); -usb_free_coherent (pcu->udev, pcu->max_out_size, +usb_free_coherent (pcu->udev, pcu->max_in_size, pcu->urb_in_buf, pcu->read_dma);kfree (pcu->urb_out_buf);
Greg Kroah-Hartman
maintainerPATCH 101/307 batman-adv: tvlv: reject oversized TVLV packets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f50487e3566358b2b982b7801945e858c78ad9ab upstream.
batadv_tvlv_container_ogm_append() builds a TVLV packet section from the tvlv.container_list. The total size of this section is computed by batadv_tvlv_container_list_size(), which sums the sizes of all registered containers.
The return type and accumulator in batadv_tvlv_container_list_size() were u16. If the accumulated size exceeds U16_MAX, the value wraps around, causing the subsequent allocation in batadv_tvlv_container_ogm_append() to be undersized. The memcpy-style copy that follows would then write beyond the end of the allocated buffer, corrupting kernel memory.
Fix this by widening the return type of batadv_tvlv_container_list_size() to size_t. In batadv_tvlv_container_ogm_append(), check the computed length against U16_MAX before proceeding, and bail out as if the allocation had failed when the limit is exceeded.
--- net/batman-adv/tvlv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/batman-adv/tvlv.c +8 -3
@@ -13,6 +13,7 @@#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/kref.h> +#include <linux/limits.h> #include <linux/list.h> #include <linux/lockdep.h> #include <linux/netdevice.h>
@@ -160,10 +161,10 @@ batadv_tvlv_container_get(struct batadv_priv *bat_priv, u8 type, u8 version)* * Return: size of all currently registered tvlv containers in bytes. */ -static u16 batadv_tvlv_container_list_size (struct batadv_priv *bat_priv) +static size_t batadv_tvlv_container_list_size (struct batadv_priv *bat_priv) {struct batadv_tvlv_container *tvlv; -u16 tvlv_len =0 ; +size_t tvlv_len =0 ;lockdep_assert_held (&bat_priv->tvlv.container_list_lock);
@@ -316,13 +317,17 @@ int batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv, {struct batadv_tvlv_container *tvlv;struct batadv_tvlv_hdr *tvlv_hdr; -u16 tvlv_value_len; +size_t tvlv_value_len;void *tvlv_value;int tvlv_len_ret;bool ret;spin_lock_bh (&bat_priv->tvlv.container_list_lock); tvlv_value_len =batadv_tvlv_container_list_size (bat_priv); +if (tvlv_value_len >U16_MAX ) { + tvlv_len_ret = -E2BIG ; + goto end; + } ret =batadv_tvlv_realloc_packet_buff (packet_buff, packet_buff_len, packet_min_len, tvlv_value_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 118/315 HID: quirks: Add ALWAYS_POLL quirk for SIGMACHIP USB mouse
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: hlleng <[email protected]>
commit 07466fc91c55532edcfb5c6a7ccd2ea52728d6bd upstream.
The SIGMACHIP USB mouse with VID/PID 1c4f:0034 can disconnect and re-enumerate repeatedly after it has been enumerated if its interrupt endpoint is not continuously polled.
This was observed with the device reporting itself as "SIGMACHIP Usb Mouse". Keeping the input event device open avoids the disconnects.
Add HID_QUIRK_ALWAYS_POLL for this device so the HID core keeps polling it even when there is no userspace input consumer.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -1244,6 +1244,7 @@#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002 +#define USB_DEVICE_ID_SIGMA_MICRO_USB_MOUSE 0x0034#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2 0x0059#define USB_VENDOR_ID_SIGMATEL 0x066F
drivers/hid/hid-quirks.c +1 -0
@@ -186,6 +186,7 @@ static const struct hid_device_id hid_qu { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS }, { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_USB_MOUSE), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780), HID_QUIRK_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS1030_TOUCH), HID_QUIRK_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS817_TOUCH), HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 102/307 batman-adv: iv: recover OGM scheduling after forward packet error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit aa3153bd139a6c48667dcd02608d3b2c80bff02c upstream.
When batadv_iv_ogm_schedule_buff() fails to allocate and queue a forward packet for OGM transmission, the work item that drives periodic OGM scheduling is never re-armed. This silently halts transmission of the node's own OGMs on the affected interface — only OGMs from other peers continue to be aggregated and forwarded.
Fix this by tracking whether batadv_iv_ogm_queue_add() (and transitively batadv_iv_ogm_aggregate_new()) successfully scheduled a forward packet. When scheduling fails, batadv_iv_ogm_schedule_buff() falls back to queuing a dedicated recovery work item (reschedule_work) that fires after one originator interval and calls batadv_iv_ogm_schedule() again.
--- net/batman-adv/bat_iv_ogm.c | 76 +++++++++++++++++++++++++++---------- net/batman-adv/types.h | 3 ++ 2 files changed, 60 insertions(+), 19 deletions(-)
net/batman-adv/bat_iv_ogm.c +57 -19
@@ -223,6 +223,8 @@ static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface) hard_iface->bat_iv.ogm_buff =NULL ;mutex_unlock (&hard_iface->bat_iv.ogm_buff_mutex); + +cancel_delayed_work_sync (&hard_iface->bat_iv.reschedule_work); }static void batadv_iv_ogm_iface_update_mac (struct batadv_hard_iface *hard_iface)
@@ -527,8 +529,10 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,* @if_incoming: interface where the packet was received * @if_outgoing: interface for which the retransmission should be considered * @own_packet: true if it is a self-generated ogm +* +* Return: whether forward packet was scheduled */ -static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, +static bool batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, int packet_len, unsigned long send_time, bool direct_link, struct batadv_hard_iface *if_incoming,
@@ -552,13 +556,13 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, skb =netdev_alloc_skb_ip_align (NULL , skb_size);if (!skb) -return ; +return false; forw_packet_aggr =batadv_forw_packet_alloc (if_incoming, if_outgoing, queue_left, bat_priv, skb);if (!forw_packet_aggr) {kfree_skb (skb); -return ; +return false; } forw_packet_aggr->skb->priority =TC_PRIO_CONTROL ;
@@ -580,6 +584,8 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, batadv_iv_send_outstanding_bat_ogm_packet);batadv_forw_packet_ogmv1_queue (bat_priv, forw_packet_aggr, send_time); + +return true; }/* aggregate a new packet into the existing ogm packet */
@@ -609,8 +615,10 @@ static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,* @if_outgoing: interface for which the retransmission should be considered * @own_packet: true if it is a self-generated ogm * @send_time: timestamp (jiffies) when the packet is to be sent +* +* Return: whether forward packet was scheduled */ -static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv, +static bool batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv, unsigned char *packet_buff, int packet_len, struct batadv_hard_iface *if_incoming,
@@ -662,14 +670,16 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,if (!own_packet &&atomic_read (&bat_priv->aggregated_ogms)) send_time += max_aggregation_jiffies; -batadv_iv_ogm_aggregate_new (packet_buff, packet_len, - send_time, direct_link, - if_incoming, if_outgoing, - own_packet); +return batadv_iv_ogm_aggregate_new (packet_buff, packet_len, + send_time, direct_link, + if_incoming, if_outgoing, + own_packet); }else {batadv_iv_ogm_aggregate (forw_packet_aggr, packet_buff, packet_len, direct_link);spin_unlock_bh (&bat_priv->forw_bat_list_lock); + +return true; } }
@@ -781,6 +791,8 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)u32 seqno;u16 tvlv_len =0 ;unsigned long send_time; +bool reschedule = false; +bool scheduled;int ret;lockdep_assert_held (&hard_iface->bat_iv.ogm_buff_mutex);
@@ -809,11 +821,8 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface) ogm_buff_len, BATADV_OGM_HLEN);if (ret <0 ) { -/* OGMs must be queued even when the buffer allocation for -* TVLVs failed. just fall back to the non-TVLV version -*/ - ret =0 ; - *ogm_buff_len =BATADV_OGM_HLEN ; + reschedule = true; + goto out; } tvlv_len = ret;
@@ -835,8 +844,11 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)/* OGMs from secondary interfaces are only scheduled on their * respective interfaces. */ -batadv_iv_ogm_queue_add (bat_priv, *ogm_buff, *ogm_buff_len, - hard_iface, hard_iface,1 , send_time); + scheduled =batadv_iv_ogm_queue_add (bat_priv, *ogm_buff, *ogm_buff_len, + hard_iface, hard_iface,1 , send_time); +if (!scheduled) + reschedule = true; + goto out; }
@@ -851,15 +863,28 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)if (!kref_get_unless_zero (&tmp_hard_iface->refcount))continue ; -batadv_iv_ogm_queue_add (bat_priv, *ogm_buff, - *ogm_buff_len, hard_iface, - tmp_hard_iface,1 , send_time); - + scheduled =batadv_iv_ogm_queue_add (bat_priv, *ogm_buff, + *ogm_buff_len, hard_iface, + tmp_hard_iface,1 , send_time);batadv_hardif_put (tmp_hard_iface); + +if (!scheduled && tmp_hard_iface == hard_iface) + reschedule = true; }rcu_read_unlock (); out: +if (reschedule) { +/* there was a failure scheduling the own forward packet. +* as result, the batadv_iv_send_outstanding_bat_ogm_packet() +* work item is no longer scheduled. it is therefore necessary +* to reschedule it manually +*/ +queue_delayed_work (batadv_event_workqueue, + &hard_iface->bat_iv.reschedule_work, +msecs_to_jiffies (atomic_read (&bat_priv->orig_interval))); + } +batadv_hardif_put (primary_if); }
@@ -874,6 +899,17 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)mutex_unlock (&hard_iface->bat_iv.ogm_buff_mutex); } +static void batadv_iv_ogm_reschedule (struct work_struct *work) +{ +struct delayed_work *delayed_work =to_delayed_work (work); +struct batadv_hard_iface *hard_iface; + + hard_iface =container_of (delayed_work, + struct batadv_hard_iface, + bat_iv.reschedule_work); +batadv_iv_ogm_schedule (hard_iface); +} +/** * batadv_iv_orig_ifinfo_sum() - Get bcast_own sum for originator over interface * @orig_node: originator which reproadcasted the OGMs directly
@@ -2277,6 +2313,8 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node *neigh1,static void batadv_iv_iface_enabled (struct batadv_hard_iface *hard_iface) { +INIT_DELAYED_WORK (&hard_iface->bat_iv.reschedule_work, batadv_iv_ogm_reschedule); +/* begin scheduling originator messages on that interface */ batadv_iv_ogm_schedule (hard_iface); }
net/batman-adv/types.h +3 -0
@@ -83,6 +83,9 @@ struct batadv_hard_iface_bat_iv {/** @ogm_seqno: OGM sequence number - used to identify each OGM */ atomic_t ogm_seqno; +/** @reschedule_work: recover OGM schedule after schedule error */ +struct delayed_work reschedule_work; +/** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */ struct mutex ogm_buff_mutex; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 106/315 iio: pressure: bmp280: fix stack leak in bmp580 trigger handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 387c86b582e0782ab332e7bfcd4e6e3f93922961 upstream.
bmp580_trigger_handler() declares its scan buffer on the stack without an initializer and then memcpy()s 3 bytes of 24-bit sensor data into each 4-byte __le32 field. The high byte of comp_temp and comp_press is left uninitialized, and the channel storagebits is 32, so two bytes of stack are pushed to userspace per scan.
This is a regression from when the buffer lived in the private data, the move to a stack-local struct dropped the implicit zeroing. bme280_trigger_handler() was fixed up to handle this bug, but this driver was not fixed because there was no padding hole, but rather a short-fill issue.
Fix this all by just zero-initializing the structure on the stack.
--- drivers/iio/pressure/bmp280-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/bmp280-core.c +1 -1
@@ -2616,7 +2616,7 @@ static irqreturn_t bmp580_trigger_handler(int irq, void *p)__le32 comp_temp;__le32 comp_press;aligned_s64 timestamp; - } buffer; + } buffer = { };int ret;guard (mutex)(&data->lock);
Signature · 1 line
2.54.0
Greg Kroah-Hartman
maintainerPATCH 119/315 Bluetooth: btusb: Allow firmware re-download when version matches
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuai Zhang <[email protected]>
commit 82855073c1081732656734b74d7d1d5e4cfd0da7 upstream.
The Bluetooth host decides whether to download firmware by reading the controller firmware download completion flag and firmware version information.
If a USB error occurs during the firmware download process (for example due to a USB disconnect), the download is aborted immediately. An incomplete firmware transfer does not cause the controller to set the download completion flag, but the firmware version information may be updated at an early stage of the download process.
In this case, after USB reconnection, the host attempts to re-download the firmware because the download completion flag is not set. However, since the controller reports the same firmware version as the target firmware, the download is skipped. This ultimately results in the firmware not being properly updated on the controller.
This change removes the restriction that skips firmware download when the versions are equal. It covers scenarios where the USB connection can be disconnected at any time and ensures that firmware download can be retriggered after USB reconnection, allowing the Bluetooth firmware to be correctly and completely updated.
--- drivers/bluetooth/btusb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +7 -1
@@ -3478,7 +3478,13 @@ static int btusb_setup_qca_load_rampatch"firmware rome 0x%x build 0x%x" , rver_rom, rver_patch, ver_rom, ver_patch); -if (rver_rom != ver_rom || rver_patch <= ver_patch) { +/* Allow rampatch when the patch version equals the firmware version. +* A firmware download may be aborted by a transient USB error (e.g. +* disconnect) after the controller updates version info but before +* completion. +* Allowing equal versions enables re-flashing during recovery. +*/ +if (rver_rom != ver_rom || rver_patch < ver_patch) {bt_dev_err (hdev,"rampatch file version did not match with firmware" ); err = -EINVAL ; goto done;
Greg Kroah-Hartman
maintainerPATCH 103/307 batman-adv: tp_meter: avoid role confusion in tp_list
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ff24f2ecfd94c07a2b89bac497433e3b23271cac upstream.
Session lookups in tp_list matched only on destination address (and optionally session ID), leaving role validation to the caller. If two sessions with the same other_end coexisted (one as sender, one as receiver) a lookup could silently return the wrong one, causing the caller's role to bail out early, potentially skipping necessary cleanup.
Move the role check into the lookup functions themselves so the correct entry is always returned, or none at all. Since batadv_tp_start() legitimately needs to detect any active session to a destination regardless of role, introduce a dedicated helper for that case rather than bending the existing lookup semantics.
--- net/batman-adv/tp_meter.c | 59 ++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 23 deletions(-)
net/batman-adv/tp_meter.c +36 -23
@@ -255,6 +255,7 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,* batadv_tp_list_find() - find a tp_vars object in the global list * @bat_priv: the bat priv with all the soft interface information * @dst: the other endpoint MAC address to look for +* @role: role of the session * * Look for a tp_vars object matching dst as end_point and return it after * having increment the refcounter. Return NULL is not found
@@ -262,7 +263,8 @@ static void batadv_tp_batctl_error_notify(enum batadv_tp_meter_reason reason,* Return: matching tp_vars or NULL when no tp_vars with @dst was found */ static struct batadv_tp_vars *batadv_tp_list_find (struct batadv_priv *bat_priv, -const u8 *dst) +const u8 *dst, +enum batadv_tp_meter_role role) {struct batadv_tp_vars *pos, *tp_vars =NULL ;
@@ -271,6 +273,9 @@ static struct batadv_tp_vars *batadv_tp_list_find(struct batadv_priv *bat_priv,if (!batadv_compare_eth (pos->other_end, dst))continue ; +if (pos->role != role) +continue ; +/* most of the time this function is invoked during the normal * process..it makes sens to pay more when the session is * finished and to speed the process up during the measurement
@@ -286,12 +291,33 @@ static struct batadv_tp_vars *batadv_tp_list_find(struct batadv_priv *bat_priv,return tp_vars; } +/** +* batadv_tp_list_active() - check if session from/to destination is ongoing +* @bat_priv: the bat priv with all the mesh interface information +* @dst: the other endpoint MAC address to look for +* +* Return: if matching session with @dst was found +*/ +static bool batadv_tp_list_active (struct batadv_priv *bat_priv,const u8 *dst) + __must_hold(&bat_priv->tp_list_lock) +{ +struct batadv_tp_vars *tp_vars; + +hlist_for_each_entry_rcu (tp_vars, &bat_priv->tp_list, list) { +if (batadv_compare_eth (tp_vars->other_end, dst)) +return true; + } + +return false; +} +/** * batadv_tp_list_find_session() - find tp_vars session object in the global * list * @bat_priv: the bat priv with all the soft interface information * @dst: the other endpoint MAC address to look for * @session: session identifier +* @role: role of the session * * Look for a tp_vars object matching dst as end_point, session as tp meter * session and return it after having increment the refcounter. Return NULL
@@ -301,7 +327,7 @@ static struct batadv_tp_vars *batadv_tp_list_find(struct batadv_priv *bat_priv,*/ static struct batadv_tp_vars *batadv_tp_list_find_session (struct batadv_priv *bat_priv,const u8 *dst, -const u8 *session) +const u8 *session,enum batadv_tp_meter_role role) {struct batadv_tp_vars *pos, *tp_vars =NULL ;
@@ -313,6 +339,9 @@ batadv_tp_list_find_session(struct batadv_priv *bat_priv, const u8 *dst,if (memcmp (pos->session, session,sizeof (pos->session)) !=0 )continue ; +if (pos->role != role) +continue ; +/* most of the time this function is invoked during the normal * process..it makes sense to pay more when the session is * finished and to speed the process up during the measurement
@@ -671,13 +700,10 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv,/* find the tp_vars */ tp_vars =batadv_tp_list_find_session (bat_priv, icmp->orig, - icmp->session); + icmp->session,BATADV_TP_SENDER );if (unlikely (!tp_vars))return ; -if (unlikely (tp_vars->role !=BATADV_TP_SENDER )) - goto out; -if (unlikely (batadv_tp_sender_stopped (tp_vars))) goto out;
@@ -986,10 +1012,8 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,return ; } - tp_vars =batadv_tp_list_find (bat_priv, dst); -if (tp_vars) { +if (batadv_tp_list_active (bat_priv, dst)) {spin_unlock_bh (&bat_priv->tp_list_lock); -batadv_tp_vars_put (tp_vars);batadv_dbg (BATADV_DBG_TP_METER , bat_priv,"Meter: test to or from the same node already ongoing, aborting\n" ); batadv_tp_batctl_error_notify(BATADV_TP_REASON_ALREADY_ONGOING,
@@ -1110,18 +1134,14 @@ void batadv_tp_stop(struct batadv_priv *bat_priv, const u8 *dst,if (!orig_node)return ; - tp_vars =batadv_tp_list_find (bat_priv, orig_node->orig); + tp_vars =batadv_tp_list_find (bat_priv, orig_node->orig,BATADV_TP_SENDER );if (!tp_vars) {batadv_dbg (BATADV_DBG_TP_METER , bat_priv,"Meter: trying to interrupt an already over connection\n" ); 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_put_orig_node:batadv_orig_node_put (orig_node);
@@ -1377,7 +1397,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, goto out_unlock; tp_vars =batadv_tp_list_find_session (bat_priv, icmp->orig, - icmp->session); + icmp->session,BATADV_TP_RECEIVER );if (tp_vars) goto out_unlock;
@@ -1448,7 +1468,7 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, } }else { tp_vars =batadv_tp_list_find_session (bat_priv, icmp->orig, - icmp->session); + icmp->session,BATADV_TP_RECEIVER );if (!tp_vars) { batadv_dbg(BATADV_DBG_TP_METER, bat_priv, "Unexpected packet from %pM!\n",
@@ -1457,13 +1477,6 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, } } -if (unlikely (tp_vars->role !=BATADV_TP_RECEIVER )) { -batadv_dbg (BATADV_DBG_TP_METER , bat_priv, -"Meter: dropping packet: not expected (role=%u)\n" , - tp_vars->role); - goto out; - } - tp_vars->last_recv_time = jiffies;/* if the packet is a duplicate, it may be the case that an ACK has been
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 120/315 hpfs: fix a crash if hpfs_map_dnode_bitmap fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 974820a59efde7c1a7e1260bcfe9bb81f833cc9f upstream.
If hpfs_map_dnode_bitmap fails, the code would call hpfs_brelse4 on uninitialized quad buffer head, causing a crash.
--- fs/hpfs/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/hpfs/alloc.c +1 -1
@@ -372,8 +372,8 @@ int hpfs_check_free_dnodes(struct super_return 0 ; } } +hpfs_brelse4 (&qbh); } -hpfs_brelse4 (&qbh); i =0 ;if (hpfs_sb (s)->sb_c_bitmap !=-1 ) { bmp =hpfs_map_bitmap (s, b, &qbh,"chkdn1" );
Greg Kroah-Hartman
maintainerPATCH 104/307 s390/cio: Restore GFP_DMA for CHSC allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
[ Upstream commit ea34567db0a6b3a7ce78ba421592344315c8f90e ]
Re-add GFP_DMA when allocating memory for CHSC control blocks. On some supported machines, CHSC cannot access memory outside the DMA zone, causing CHSC command failures.
--- drivers/s390/cio/chsc.c | 4 ++-- drivers/s390/cio/chsc_sch.c | 20 ++++++++++---------- drivers/s390/cio/scm.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/s390/cio/chsc.c +2 -2
@@ -1153,8 +1153,8 @@ int __init chsc_init(void) {int ret; - sei_page = (void *)get_zeroed_page (GFP_KERNEL ); - chsc_page = (void *)get_zeroed_page (GFP_KERNEL ); + sei_page = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA ); + chsc_page = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sei_page || !chsc_page) { ret = -ENOMEM ; goto out_err;
drivers/s390/cio/chsc_sch.c +10 -10
@@ -293,7 +293,7 @@ static int chsc_ioctl_start(void __user *user_area)if (!css_general_characteristics.dynio)/* It makes no sense to try. */ return -EOPNOTSUPP ; - chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + chsc_area = (void *)get_zeroed_page (GFP_DMA |GFP_KERNEL );if (!chsc_area)return -ENOMEM ; request =kzalloc (sizeof (*request),GFP_KERNEL );
@@ -341,7 +341,7 @@ static int chsc_ioctl_on_close_set(void __user *user_area) ret = -ENOMEM ; goto out_unlock; } - on_close_chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + on_close_chsc_area = (void *)get_zeroed_page (GFP_DMA |GFP_KERNEL );if (!on_close_chsc_area) { ret = -ENOMEM ; goto out_free_request;
@@ -393,7 +393,7 @@ static int chsc_ioctl_start_sync(void __user *user_area)struct chsc_sync_area *chsc_area;int ret, ccode; - chsc_area = (void *)get_zeroed_page (GFP_KERNEL ); + chsc_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!chsc_area)return -ENOMEM ;if (copy_from_user (chsc_area, user_area,PAGE_SIZE )) {
@@ -439,7 +439,7 @@ static int chsc_ioctl_info_channel_path(void __user *user_cd)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *scpcd_area; - scpcd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scpcd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scpcd_area)return -ENOMEM ; cd =kzalloc (sizeof (*cd),GFP_KERNEL );
@@ -501,7 +501,7 @@ static int chsc_ioctl_info_cu(void __user *user_cd)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *scucd_area; - scucd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scucd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scucd_area)return -ENOMEM ; cd =kzalloc (sizeof (*cd),GFP_KERNEL );
@@ -564,7 +564,7 @@ static int chsc_ioctl_info_sch_cu(void __user *user_cud)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *sscud_area; - sscud_area = (void *)get_zeroed_page (GFP_KERNEL ); + sscud_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sscud_area)return -ENOMEM ; cud =kzalloc (sizeof (*cud),GFP_KERNEL );
@@ -626,7 +626,7 @@ static int chsc_ioctl_conf_info(void __user *user_ci)u8 data[PAGE_SIZE -20 ]; } __attribute__ ((packed)) *sci_area; - sci_area = (void *)get_zeroed_page (GFP_KERNEL ); + sci_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sci_area)return -ENOMEM ; ci =kzalloc (sizeof (*ci),GFP_KERNEL );
@@ -697,7 +697,7 @@ static int chsc_ioctl_conf_comp_list(void __user *user_ccl)u32 res; } __attribute__ ((packed)) *cssids_parm; - sccl_area = (void *)get_zeroed_page (GFP_KERNEL ); + sccl_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sccl_area)return -ENOMEM ; ccl =kzalloc (sizeof (*ccl),GFP_KERNEL );
@@ -757,7 +757,7 @@ static int chsc_ioctl_chpd(void __user *user_chpd)int ret; chpd =kzalloc (sizeof (*chpd),GFP_KERNEL ); - scpd_area = (void *)get_zeroed_page (GFP_KERNEL ); + scpd_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!scpd_area || !chpd) { ret = -ENOMEM ; goto out_free;
@@ -797,7 +797,7 @@ static int chsc_ioctl_dcal(void __user *user_dcal)u8 data[PAGE_SIZE -36 ]; } __attribute__ ((packed)) *sdcal_area; - sdcal_area = (void *)get_zeroed_page (GFP_KERNEL ); + sdcal_area = (void *)get_zeroed_page (GFP_KERNEL |GFP_DMA );if (!sdcal_area)return -ENOMEM ; dcal =kzalloc (sizeof (*dcal),GFP_KERNEL );
drivers/s390/cio/scm.c +1 -1
@@ -228,7 +228,7 @@ int scm_update_information(void)size_t num;int ret; - scm_info = (void *)__get_free_page (GFP_KERNEL ); + scm_info = (void *)__get_free_page (GFP_KERNEL |GFP_DMA );if (!scm_info)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 121/315 mm/damon/sysfs-schemes: delete tried region in regions_rmdirs()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
commit 441f92f7d386b85bad16de49db95a307cba048a2 upstream.
DAMON sysfs maintains the DAMOS tried region directory objects via a linked list. When the user requests refresh of the directories, DAMON sysfs removes all the region directories first, and then generate updated regions directory on the empty space. The removal function (damon_sysfs_scheme_regions_rm_dirs()) only puts the kobj objects. Deletion of the container region object from the linked list is done inside the kobj release callback function.
If somehow the callback invocation is delayed, the list will contain regions list that gonna be freed. If the updated region directories creation is started in this situation, the list can be corrupted and use-after-free can happen.
Because the kobj objects are managed by only DAMON sysfs, the issue cannot happen in normal situation. But, such delays can be made on kernels that built with CONFIG_DEBUG_KOBJECT_RELEASE. On the kernel, the issue can indeed be reproduced like below.
# damo start --damos_action stat
# cd /sys/kernel/mm/damon/admin/kdamonds/0/
# for i in {1..10}; do echo update_schemes_tried_regions > state; done
# dmesg | grep underflow
[ 89.296152] refcount_t: underflow; use-after-free.Fix the issue by removing the region object from the list when decrementing the reference count.
Also update damos_sysfs_populate_region_dir() to add the region object to the list only after the kobject_init_and_add() is success, so that fail of kobject_init_and_add() is not leaving the deallocated object on the list.
The issue was discovered [1] by Sashiko.
--- mm/damon/sysfs-schemes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/damon/sysfs-schemes.c +4 -4
@@ -89,7 +89,6 @@ static void damon_sysfs_scheme_region_restruct damon_sysfs_scheme_region *region =container_of (kobj, struct damon_sysfs_scheme_region, kobj); -list_del (®ion->list);kfree (region); }
@@ -166,7 +165,7 @@ static void damon_sysfs_scheme_regions_rstruct damon_sysfs_scheme_region *r, *next;list_for_each_entry_safe (r, next, ®ions->regions_list, list) { -/* release function deletes it from the list */ +list_del (&r->list);kobject_put (&r->kobj); regions->nr_regions--; }
@@ -2767,14 +2766,15 @@ void damos_sysfs_populate_region_dir(strif (!region)return ; region->sz_filter_passed = sz_filter_passed; -list_add_tail (®ion->list, &sysfs_regions->regions_list); - sysfs_regions->nr_regions++;if (kobject_init_and_add (®ion->kobj, &damon_sysfs_scheme_region_ktype, &sysfs_regions->kobj,"%d" , sysfs_regions->nr_regions++)) {kobject_put (®ion->kobj); +return ; } +list_add_tail (®ion->list, &sysfs_regions->regions_list); + sysfs_regions->nr_regions++; } int damon_sysfs_schemes_clear_regions(
Greg Kroah-Hartman
maintainerPATCH 105/307 batman-adv: tp_meter: directly shut down timer on cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit d5487249a81ea658717614009c8f46acc5b7101a upstream.
batadv_tp_sender_cleanup() was calling timer_delete_sync() followed by timer_delete() to guard against the timer handler re-arming itself between the two calls. This double-deletion hack relied on the sending status being set to 0 to suppress re-arming.
Replace both calls with a single timer_shutdown_sync(). This function both waits for any running timer callback to complete (like timer_delete_sync()) and permanently disarms the timer so it cannot be re-armed afterwards, making re-arming prevention unconditional and self-documenting.
The re-arming property is also required because otherwise:
1. context 0 (batadv_tp_recv_ack()) checks in batadv_tp_reset_sender_timer() if sending is still 1 -> it is
2. context 1 changes in batadv_tp_sender_shutdown() sending to 0 and in this process forces the kthread to stop timer in batadv_tp_sender_cleanup()
3. context 0 continues in batadv_tp_reset_sender_timer() and rearms the timer -> but the reference for it is already gone
--- net/batman-adv/tp_meter.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
net/batman-adv/tp_meter.c +1 -7
@@ -430,13 +430,7 @@ static void batadv_tp_sender_cleanup(struct batadv_tp_vars *tp_vars)batadv_tp_list_detach (tp_vars);/* kill the timer and remove its reference */ -del_timer_sync (&tp_vars->timer); -/* the worker might have rearmed itself therefore we kill it again. Note -* that if the worker should run again before invoking the following -* del_timer(), it would not re-arm itself once again because the status -* is OFF now -*/ -del_timer (&tp_vars->timer); +timer_shutdown_sync (&tp_vars->timer);batadv_tp_vars_put (tp_vars); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 122/315 ipc: limit next_id allocation to the valid ID range
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linpu Yu <[email protected]>
commit fa0b9b2b7ae3539908d69c2b9ac0d144d9bc5139 upstream.
The checkpoint/restore sysctl path can request the next SysV IPC id through ids->next_id. ipc_idr_alloc() currently forwards that request to idr_alloc() with an open-ended upper bound.
If the valid tail of the SysV IPC id space is full, the allocation can spill beyond ipc_mni. The returned SysV IPC id still uses the normal index encoding, so later lookup and removal can target the wrong slot. This leaves the real IDR entry behind and breaks the IDR state for the object.
The bug is in ipc_idr_alloc() in the checkpoint/restore path.
1. ids->next_id is passed to:
idr_alloc(&ids->ipcs_idr, new, ipcid_to_idx(next_id), 0, ...)
2. The zero upper bound makes the allocation effectively open-ended. Once the valid SysV IPC tail is occupied, idr_alloc() can spill past ipc_mni and allocate an entry beyond the valid IPC id range.
3. The new object id is still encoded with the narrower SysV IPC index width:
new->id = (new->seq << ipcmni_seq_shift()) + idx
4. Later removal goes through ipc_rmid(), which uses:
ipcid_to_idx(ipcp->id)
That truncates the real IDR index. An object actually stored at a high index can then be removed as if it lived at a low in-range index.
5. For shared memory, shm_destroy() frees the current object anyway, but the real high IDR slot is left behind as a dangling pointer.
6. A subsequent walk of /proc/sysvipc/shm reaches the stale IDR entry and dereferences freed memory.
Prevent this by bounding the requested allocation to ipc_mni so the checkpoint/restore path fails once the valid range is exhausted.
--- ipc/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ipc/util.c +1 -1
@@ -253,7 +253,7 @@ static inline int ipc_idr_alloc(struct i }else { new->seq =ipcid_to_seqx (next_id); idx =idr_alloc (&ids->ipcs_idr, new,ipcid_to_idx (next_id), -0 ,GFP_NOWAIT ); + ipc_mni,GFP_NOWAIT ); }if (idx >=0 ) new->id = (new->seq <<ipcmni_seq_shift ()) + idx;
Greg Kroah-Hartman
maintainerPATCH 106/307 batman-adv: tt: fix TOCTOU race for reported vlans
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 94d27005016be15ffc638b2ecbc4d58805ad7b48 upstream.
The local TT based TVLV is generated by first checking the number of VLANs which have at least one TT entry. A new buffer with the correct size for the VLANs is then allocated. Only then, the list of VLANs s used to fill the VLAN entries in the buffer. During this time, the meshif_vlan_list_lock is held. But the actual number of TT entries of each VLAN can still increase during this time - just not the number of VLANs in the list.
But the prefilter used in the buffer size calculation might still cause an increase of the number of VLANs which need to be stored. Simply because a VLAN might now suddenly have at least one entry when it had none in the pre-alloc check - and then needs to occupy space which was not allocated.
It is better to overestimate the buffer size at the beginning and then fill the buffer only with the VLANs which are not empty.
--- net/batman-adv/translation-table.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/batman-adv/translation-table.c +10 -4
@@ -934,11 +934,8 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv,spin_lock_bh (&bat_priv->softif_vlan_list_lock);hlist_for_each_entry (vlan, &bat_priv->softif_vlan_list, list) { vlan_entries =atomic_read (&vlan->tt.num_entries); -if (vlan_entries <1 ) -continue ; - - num_vlan++; total_entries += vlan_entries; + num_vlan++; } change_offset =sizeof (**tt_data);
@@ -964,6 +961,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, (*tt_data)->num_vlan =htons (num_vlan); tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data +1 ); + num_vlan =0 ;hlist_for_each_entry (vlan, &bat_priv->softif_vlan_list, list) { vlan_entries =atomic_read (&vlan->tt.num_entries);if (vlan_entries <1 )
@@ -974,8 +972,16 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv, tt_vlan->reserved =0 ; tt_vlan++; + num_vlan++; } +/* recalculate in case number of VLANs reduced */ + change_offset =sizeof (**tt_data); + change_offset += num_vlan *sizeof (*tt_vlan); + tvlv_len = *tt_len + change_offset; + + (*tt_data)->num_vlan =htons (num_vlan); + tt_change_ptr = (u8 *)*tt_data + change_offset; *tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 123/315 mm: memcontrol: propagate NMI slab stats to memcg vmstats
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Ghiti <[email protected]>
commit e16f17a9c5af50221184d1ef4be4056bf3c4209e upstream.
flush_nmi_stats() drains per-node NMI slab atomics into the per-node lruvec_stats, but does not propagate them to the memcg-level vmstats.
For non NMI case, account_slab_nmi_safe() calls mod_memcg_lruvec_state() which updates both per-node lruvec_stats and memcg-level vmstats, so flush_nmi_stats() needs to flush to per-node lruvec_stats as well as memcg-level vmstats.
So fix this by flushing to the memcg-level vmstats for NMI too.
--- mm/memcontrol.c | 6 ++++++ 1 file changed, 6 insertions(+)
mm/memcontrol.c +6 -0
@@ -4044,6 +4044,9 @@ static void flush_nmi_stats(struct mem_c lstats->state[index] += slab;if (plstats) plstats->state_pending[index] += slab; + memcg->vmstats->state[index] += slab; +if (parent) + parent->vmstats->state_pending[index] += slab; }if (atomic_read (&pn->slab_unreclaimable)) {int slab =atomic_xchg (&pn->slab_unreclaimable,0 );
@@ -4052,6 +4055,9 @@ static void flush_nmi_stats(struct mem_c lstats->state[index] += slab;if (plstats) plstats->state_pending[index] += slab; + memcg->vmstats->state[index] += slab; +if (parent) + parent->vmstats->state_pending[index] += slab; } } }
Greg Kroah-Hartman
maintainerPATCH 107/307 batman-adv: tt: avoid empty VLAN responses
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit fa1bd704940b5bcbc32c0b28db9167405c8ee5e0 upstream.
The commit 16116dac2339 ("batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs") added checks to the local (direct) TT response code. But the response can also be done indirectly by another node using the global TT state. To avoid such inconsistency states reported in the original fix, also avoid sending empty VLANs for replies from the global TT state.
--- net/batman-adv/translation-table.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
net/batman-adv/translation-table.c +18 -3
@@ -843,17 +843,19 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, s32 *tt_len) {u16 num_vlan =0 ; -u16 num_entries =0 ;u16 tvlv_len =0 ;unsigned int change_offset;struct batadv_tvlv_tt_vlan_data *tt_vlan;struct batadv_orig_node_vlan *vlan; +u16 total_entries =0 ;u8 *tt_change_ptr; +int vlan_entries;spin_lock_bh (&orig_node->vlan_list_lock);hlist_for_each_entry (vlan, &orig_node->vlan_list, list) { + vlan_entries =atomic_read (&vlan->tt.num_entries); + total_entries += vlan_entries; num_vlan++; - num_entries +=atomic_read (&vlan->tt.num_entries); } change_offset =sizeof (**tt_data);
@@ -861,7 +863,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,/* if tt_len is negative, allocate the space needed by the full table */ if (*tt_len <0 ) - *tt_len =batadv_tt_len (num_entries); + *tt_len =batadv_tt_len (total_entries);if (change_offset >U16_MAX || *tt_len >U16_MAX - change_offset) { *tt_len =0 ;
@@ -882,14 +884,27 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, (*tt_data)->num_vlan =htons (num_vlan); tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data +1 ); + num_vlan =0 ;hlist_for_each_entry (vlan, &orig_node->vlan_list, list) { + vlan_entries =atomic_read (&vlan->tt.num_entries); +if (vlan_entries <1 ) +continue ; + tt_vlan->vid =htons (vlan->vid); tt_vlan->crc =htonl (vlan->tt.crc); tt_vlan->reserved =0 ; tt_vlan++; + num_vlan++; } +/* recalculate in case number of VLANs reduced */ + change_offset =sizeof (**tt_data); + change_offset += num_vlan *sizeof (*tt_vlan); + tvlv_len = *tt_len + change_offset; + + (*tt_data)->num_vlan =htons (num_vlan); + tt_change_ptr = (u8 *)*tt_data + change_offset; *tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 124/315 memfd: deny writeable mappings when implying SEAL_WRITE
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pratyush Yadav (Google) <[email protected]>
commit 3b041514cb6eae45869b020f743c14d983363222 upstream.
When SEAL_EXEC is added, SEAL_WRITE is implied to make W^X. But the implied seal is set after the check that makes sure the memfd can not have any writable mappings. This means one can use SEAL_EXEC to apply SEAL_WRITE while having writeable mappings.
This breaks the contract that SEAL_WRITE provides and can be used by an attacker to pass a memfd that appears to be write sealed but can still be modified arbitrarily.
Fix this by adding the implied seals before the call for mapping_deny_writable() is done.
--- mm/memfd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/memfd.c +6 -6
@@ -284,6 +284,12 @@ static int memfd_add_seals(struct file * goto unlock; } +/* +* SEAL_EXEC implies SEAL_WRITE, making W^X from the start. +*/ +if (seals &F_SEAL_EXEC && inode->i_mode &0111 ) + seals |=F_SEAL_SHRINK |F_SEAL_GROW |F_SEAL_WRITE |F_SEAL_FUTURE_WRITE ; +if ((seals &F_SEAL_WRITE ) && !(*file_seals &F_SEAL_WRITE )) { error =mapping_deny_writable (file->f_mapping);if (error)
@@ -296,12 +302,6 @@ static int memfd_add_seals(struct file * } } -/* -* SEAL_EXEC implies SEAL_WRITE, making W^X from the start. -*/ -if (seals &F_SEAL_EXEC && inode->i_mode &0111 ) - seals |=F_SEAL_SHRINK |F_SEAL_GROW |F_SEAL_WRITE |F_SEAL_FUTURE_WRITE ; - *file_seals |= seals; error =0 ;
Greg Kroah-Hartman
maintainerPATCH 108/307 batman-adv: bla: avoid double decrement of bla.num_requests
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 83ab69bd12b80f6ea169c8bea6977701b53a043d upstream.
The bla.num_requests is increased when no request_sent was in progress. And it is decremented in various places (announcement was received, backbone is purged, periodic work). But the check if the request_sent is actually set to a specific state and the atomic_dec/_inc are not safe because they are not atomic (TOCTOU) and multiple such code portions can run concurrently.
At the same time, it is necessary to modify request_sent (state) and bla.num_requests atomically. Otherwise batadv_bla_send_request() might set request_sent to 1 and is interrupted. batadv_handle_announce() can then set request_sent back to 0 and decrement num_requests before batadv_bla_send_request() incremented it.
The two operations must therefore be locked. And since state (request_sent) and wait_periods are only accessed inside this lock, they can be converted to simpler datatypes. And to avoid that the bla.num_requests is touched by a parallel running context with a valid backbone_gw reference after batadv_bla_purge_backbone_gw() ran, a third state "stopped" is required to correctly signal that a backbone_gw is in the state of being cleaned up.
--- net/batman-adv/bridge_loop_avoidance.c | 51 ++++++++++++++++++-------- net/batman-adv/soft-interface.c | 1 + net/batman-adv/types.h | 39 ++++++++++++++++---- 3 files changed, 67 insertions(+), 24 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +35 -16
@@ -516,8 +516,8 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig, entry->crc =BATADV_BLA_CRC_INIT ; entry->bat_priv = bat_priv;spin_lock_init (&entry->crc_lock); -atomic_set (&entry->request_sent,0 ); -atomic_set (&entry->wait_periods,0 ); + entry->state =BATADV_BLA_BACKBONE_GW_SYNCED ; + entry->wait_periods =0 ;ether_addr_copy (entry->orig, orig);INIT_WORK (&entry->report_work, batadv_bla_loopdetect_report);kref_init (&entry->refcount);
@@ -546,9 +546,13 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,batadv_bla_send_announce (bat_priv, entry);/* this will be decreased in the worker thread */ -atomic_inc (&entry->request_sent); -atomic_set (&entry->wait_periods,BATADV_BLA_WAIT_PERIODS ); -atomic_inc (&bat_priv->bla.num_requests); +spin_lock_bh (&bat_priv->bla.num_requests_lock); +if (entry->state ==BATADV_BLA_BACKBONE_GW_SYNCED ) { + entry->state =BATADV_BLA_BACKBONE_GW_UNSYNCED ; + entry->wait_periods =BATADV_BLA_WAIT_PERIODS ; +atomic_inc (&bat_priv->bla.num_requests); + } +spin_unlock_bh (&bat_priv->bla.num_requests_lock); }return entry;
@@ -651,10 +655,12 @@ static void batadv_bla_send_request(struct batadv_bla_backbone_gw *backbone_gw) backbone_gw->vid, BATADV_CLAIM_TYPE_REQUEST);/* no local broadcasts should be sent or received, for now. */ -if (!atomic_read (&backbone_gw->request_sent)) { +spin_lock_bh (&backbone_gw->bat_priv->bla.num_requests_lock); +if (backbone_gw->state ==BATADV_BLA_BACKBONE_GW_SYNCED ) { + backbone_gw->state =BATADV_BLA_BACKBONE_GW_UNSYNCED ;atomic_inc (&backbone_gw->bat_priv->bla.num_requests); -atomic_set (&backbone_gw->request_sent,1 ); } +spin_unlock_bh (&backbone_gw->bat_priv->bla.num_requests_lock); }/**
@@ -875,10 +881,12 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,/* if we have sent a request and the crc was OK, * we can allow traffic again. */ -if (atomic_read (&backbone_gw->request_sent)) { +spin_lock_bh (&bat_priv->bla.num_requests_lock); +if (backbone_gw->state ==BATADV_BLA_BACKBONE_GW_UNSYNCED ) { + backbone_gw->state =BATADV_BLA_BACKBONE_GW_SYNCED ;atomic_dec (&backbone_gw->bat_priv->bla.num_requests); -atomic_set (&backbone_gw->request_sent,0 ); } +spin_unlock_bh (&bat_priv->bla.num_requests_lock); }batadv_backbone_gw_put (backbone_gw);
@@ -1257,9 +1265,13 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now) purged = true;/* don't wait for the pending request anymore */ -if (atomic_read (&backbone_gw->request_sent)) +spin_lock_bh (&bat_priv->bla.num_requests_lock); +if (backbone_gw->state ==BATADV_BLA_BACKBONE_GW_UNSYNCED )atomic_dec (&bat_priv->bla.num_requests); + backbone_gw->state =BATADV_BLA_BACKBONE_GW_STOPPED ; +spin_unlock_bh (&bat_priv->bla.num_requests_lock); +batadv_bla_del_backbone_claims (backbone_gw);hlist_del_rcu (&backbone_gw->hash_entry);
@@ -1510,7 +1522,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)batadv_bla_send_loopdetect (bat_priv, backbone_gw); -/* request_sent is only set after creation to avoid +/* state is only set to unsynced after creation to avoid * problems when we are not yet known as backbone gw * in the backbone. *
@@ -1519,14 +1531,21 @@ static void batadv_bla_periodic_work(struct work_struct *work)* some grace time. */ -if (atomic_read (&backbone_gw->request_sent) ==0 ) -continue ; +spin_lock_bh (&bat_priv->bla.num_requests_lock); +if (backbone_gw->state !=BATADV_BLA_BACKBONE_GW_UNSYNCED ) + goto unlock_next; -if (!atomic_dec_and_test (&backbone_gw->wait_periods)) -continue ; +if (backbone_gw->wait_periods >0 ) + backbone_gw->wait_periods--; + +if (backbone_gw->wait_periods >0 ) + goto unlock_next; + backbone_gw->state =BATADV_BLA_BACKBONE_GW_SYNCED ;atomic_dec (&backbone_gw->bat_priv->bla.num_requests); -atomic_set (&backbone_gw->request_sent,0 ); + +unlock_next: +spin_unlock_bh (&bat_priv->bla.num_requests_lock); }rcu_read_unlock (); }
net/batman-adv/soft-interface.c +1 -0
@@ -787,6 +787,7 @@ static int batadv_softif_init_late(struct net_device *dev)atomic_set (&bat_priv->tt.ogm_append_cnt,0 );#ifdef CONFIG_BATMAN_ADV_BLA atomic_set (&bat_priv->bla.num_requests,0 ); +spin_lock_init (&bat_priv->bla.num_requests_lock);#endif atomic_set (&bat_priv->tp_num,0 );
net/batman-adv/types.h +31 -8
@@ -1091,6 +1091,12 @@ struct batadv_priv_bla {/** @num_requests: number of bla requests in flight */ atomic_t num_requests; +/** +* @num_requests_lock: locks update num_requests + +* batadv_backbone_gw::state + batadv_backbone_gw::wait_periods update +*/ +spinlock_t num_requests_lock; +/** * @claim_hash: hash table containing mesh nodes this host has claimed */
@@ -1825,6 +1831,27 @@ struct batadv_priv {#ifdef CONFIG_BATMAN_ADV_BLA +enum batadv_bla_backbone_gw_state { +/** +* @BATADV_BLA_BACKBONE_GW_STOPPED: backbone gw is being removed +* and it must not longer work on requests +*/ +BATADV_BLA_BACKBONE_GW_STOPPED , + +/** +* @BATADV_BLA_BACKBONE_GW_UNSYNCED: backbone was detected out +* of sync and a request was send. No traffic is forwarded until the +* situation is resolved +*/ +BATADV_BLA_BACKBONE_GW_UNSYNCED , + +/** +* @BATADV_BLA_BACKBONE_GW_SYNCED: backbone is consider to be in +* sync. traffic can be forwarded +*/ +BATADV_BLA_BACKBONE_GW_SYNCED , +}; +/** * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN */
@@ -1850,16 +1877,12 @@ struct batadv_bla_backbone_gw {/** * @wait_periods: grace time for bridge forward delays and bla group * forming at bootup phase - no bcast traffic is formwared until it has -* elapsed +* elapsed. Must only be access with num_requests_lock. */ -atomic_t wait_periods; +u8 wait_periods; -/** -* @request_sent: if this bool is set to true we are out of sync with -* this backbone gateway - no bcast traffic is formwared until the -* situation was resolved -*/ -atomic_t request_sent; +/** @state: sync state. Must only be access with num_requests_lock. */ +enum batadv_bla_backbone_gw_state state;/** @crc: crc16 checksum over all claims */ u16 crc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 125/315 mm/rmap: initialize nr_pages to 1 at loop start in try_to_unmap_one
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dev Jain <[email protected]>
commit 3f8968e9cbf95d5d87d32218906cab0b9b9eddbe upstream.
Initialize nr_pages to 1 at the start of each loop iteration, like folio_referenced_one() does.
Without this, nr_pages computed by a previous folio_unmap_pte_batch() call can be reused on a later iteration that does not run folio_unmap_pte_batch() again.
mmap a 64K large folio with MAP_ANONYMOUS | MAP_DROPPABLE, then call madvise(MADV_FREE), then make the last page device-exclusive via HMM_DMIRROR_EXCLUSIVE.
Trigger node reclaim through sysfs. Now, in try_to_unmap_one(), we will first clear the first 15 out of 16 entries mapping the lazyfree folio. This will set nr_pages to 15. In the next pvmw walk, this nr_pages gets reused on a device-exclusive pte, thus potentially corrupting folio refcount/mapcount.
At the moment, I have a userspace program which can make the kernel spit out a trace, but the blow up is in folio_referenced_one(), because there are existing bugs in the interaction between device-private and rmap (which too I am investigating). I did a one liner kernel change to avoid going into folio_referenced_one(), and the kernel blows up at folio_remove_rmap_ptes in try_to_unmap_one which is what I wanted.
Note that the bug is there not since file folio batching but lazyfree folio batching, since device-exclusive only works for anonymous folios.
Userspace visible effect is simply kernel crashing somewhere due to refcount/mapcount corruption.
--- mm/rmap.c | 2 ++ 1 file changed, 2 insertions(+)
mm/rmap.c +2 -0
@@ -1918,6 +1918,8 @@ static bool try_to_unmap_one(struct folimmu_notifier_invalidate_range_start (&range);while (page_vma_mapped_walk (&pvmw)) { + nr_pages =1 ; +/* * If the folio is in an mlock()d vma, we must not swap it out. */
Greg Kroah-Hartman
maintainerPATCH 107/315 usb: typec: ucsi: ccg: reject firmware images without a : record header
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit d7486952bf74e546ee3748fb14b2d07881fa6273 upstream.
do_flash() locates the first .cyacd record with
p = strnchr(fw->data, fw->size, ':');
while (p < eof) {
s = strnchr(p + 1, eof - p - 1, ':');
...
}If the firmware image contains no ':' byte, strnchr() returns NULL. NULL compares less than the valid kernel pointer eof, so the loop body runs and strnchr() is called with p + 1 == (void *)1 and a length of roughly (unsigned long)eof, causing a wonderful crash.
The not_signed_fw fallthrough earlier in do_flash() and the chip-state branches in ccg_fw_update_needed() allow an unsigned blob to reach this loop, so a root user who can place a crafted file under /lib/firmware and write the do_flash sysfs attribute can trigger the oops.
Bail out with -EINVAL when the initial strnchr() returns NULL.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +5 -0
@@ -1242,6 +1242,11 @@ not_signed_fw:*****************************************************************/ p =strnchr (fw->data, fw->size,':' ); +if (!p) { +dev_err (dev,"Bad FW format: no ':' record header found\n" ); + err = -EINVAL ; + goto release_mem; + }while (p < eof) { s =strnchr (p +1 , eof - p -1 ,':' );
Greg Kroah-Hartman
maintainerPATCH 109/307 mm/page_alloc: clear page->private in free_pages_prepare()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Gavrilov <[email protected]>
[ Upstream commit ac1ea219590c09572ed5992dc233bbf7bb70fef9 ]
Several subsystems (slub, shmem, ttm, etc.) use page->private but don't clear it before freeing pages. When these pages are later allocated as high-order pages and split via split_page(), tail pages retain stale page->private values.
This causes a use-after-free in the swap subsystem. The swap code uses page->private to track swap count continuations, assuming freshly allocated pages have page->private == 0. When stale values are present, swap_count_continued() incorrectly assumes the continuation list is valid and iterates over uninitialized page->lru containing LIST_POISON values, causing a crash:
KASAN: maybe wild-memory-access in range [0xdead000000000100-0xdead000000000107] RIP: 0010:__do_sys_swapoff+0x1151/0x1860
Fix this by clearing page->private in free_pages_prepare(), ensuring all freed pages have clean state regardless of previous use.
--- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+)
mm/page_alloc.c +1 -0
@@ -1158,6 +1158,7 @@ __always_inline bool free_pages_prepare(struct page *page,page_cpupid_reset_last (page); page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP ; + page->private =0 ;reset_page_owner (page, order);page_table_check_free (page, order);pgalloc_tag_sub (page,1 << order);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 126/315 auxdisplay: line-display: fix OOB read on zero-length message_store()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stepan Ionichev <[email protected]>
commit a7511dcd9dd4bc55d123f9b800c8a4ed2662e5c6 upstream.
linedisp_display() unconditionally reads msg[count - 1] before checking whether count is zero, so a write of zero bytes to the message sysfs attribute hits msg[-1]:
write(fd, "", 0); -> message_store(..., buf, count=0) -> linedisp_display(linedisp, buf, count=0) -> msg[count - 1] == '\n' ; OOB read
The kernfs write buffer for that store is a 1-byte allocation (kernfs_fop_write_iter() does kmalloc(len + 1) with len == 0), so msg[-1] is a 1-byte read before the slab object. On a KASAN-enabled kernel this trips an out-of-bounds report and panics; on stock kernels it silently reads adjacent slab data and, if that byte happens to be '\n', the following count-- wraps ssize_t 0 to -1 and is then passed to kmemdup_nul().
linedisp_display() is reached from the message_store() sysfs callback (drivers/auxdisplay/line-display.c message attribute, mode 0644) and from the in-tree initial-message setup with count == -1, so the OOB path is only userspace-triggerable via zero-byte writes; vfs_write() does not short-circuit on count == 0 and kernfs_fop_write_iter() dispatches the store callback regardless.
Guard the trailing-newline trim with a count check. The existing if (!count) block then takes the clear-display path unchanged.
Affects every auxdisplay driver that registers via linedisp_register() / linedisp_attach(): ht16k33, max6959, img-ascii-lcd, seg-led-gpio.
--- drivers/auxdisplay/line-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/auxdisplay/line-display.c +1 -1
@@ -90,7 +90,7 @@ static int linedisp_display(struct lined count =strlen (msg);/* if the string ends with a newline, trim it */ -if (msg[count -1 ] =='\n' ) +if (count && msg[count -1 ] =='\n' ) count--;if (!count) {