Patch "mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mac80211_hwsim-check-hwsim_attr_radio_name-length.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Thu Oct 19 15:04:02 CEST 2017
From: Johannes Berg <[email protected]>
Date: Mon, 27 Feb 2017 17:15:28 +0100
Subject: mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length
From: Johannes Berg <[email protected]>
[ Upstream commit ff4dd73dd2b4806419f8ff65cbce11d5019548d0 ]
Unfortunately, the nla policy was defined to have HWSIM_ATTR_RADIO_NAME as an NLA_STRING, rather than NLA_NUL_STRING, so we can't use it as a NUL-terminated string in the kernel.
Rather than break the API, kasprintf() the string to a new buffer to guarantee NUL termination.
--- drivers/net/wireless/mac80211_hwsim.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +21 -7
@@ -3046,6 +3046,7 @@ static int hwsim_register_received_nl(ststatic int hwsim_new_radio_nl (struct sk_buff *msg,struct genl_info *info) {struct hwsim_new_radio_params param = {0 }; +const char *hwname =NULL ; param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG ]; param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE ];
@@ -3059,8 +3060,14 @@ static int hwsim_new_radio_nl(struct sk_if (info->attrs[HWSIM_ATTR_NO_VIF ]) param.no_vif = true; -if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) - param.hwname =nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ]); +if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) { + hwname =kasprintf (GFP_KERNEL ,"%.*s" , +nla_len (info->attrs[HWSIM_ATTR_RADIO_NAME ]), + (char *)nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ])); +if (!hwname) +return -ENOMEM ; + param.hwname = hwname; + }if (info->attrs[HWSIM_ATTR_USE_CHANCTX ]) param.use_chanctx = true;
@@ -3088,11 +3095,15 @@ static int hwsim_del_radio_nl(struct sk_s64 idx =-1 ;const char *hwname =NULL ; -if (info->attrs[HWSIM_ATTR_RADIO_ID ]) +if (info->attrs[HWSIM_ATTR_RADIO_ID ]) { idx =nla_get_u32 (info->attrs[HWSIM_ATTR_RADIO_ID ]); -else if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) - hwname = (void *)nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ]); -else + }else if (info->attrs[HWSIM_ATTR_RADIO_NAME ]) { + hwname =kasprintf (GFP_KERNEL ,"%.*s" , +nla_len (info->attrs[HWSIM_ATTR_RADIO_NAME ]), + (char *)nla_data (info->attrs[HWSIM_ATTR_RADIO_NAME ])); +if (!hwname) +return -ENOMEM ; + }else return -EINVAL ;spin_lock_bh (&hwsim_radio_lock);
@@ -3101,7 +3112,8 @@ static int hwsim_del_radio_nl(struct sk_if (data->idx != idx)continue ; }else { -if (strcmp (hwname,wiphy_name (data->hw->wiphy))) +if (!hwname || +strcmp (hwname,wiphy_name (data->hw->wiphy)))continue ; }
@@ -3112,10 +3124,12 @@ static int hwsim_del_radio_nl(struct sk_spin_unlock_bh (&hwsim_radio_lock);mac80211_hwsim_del_radio (data,wiphy_name (data->hw->wiphy), info); +kfree (hwname);return 0 ; }spin_unlock_bh (&hwsim_radio_lock); +kfree (hwname);return -ENODEV ; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/mac80211-fix-power-saving-clients-handling-in-iwlwifi.patch queue-4.9/mac80211_hwsim-check-hwsim_attr_radio_name-length.patch