提交 c62a9a0a 编写于 作者: P Phil Turnbull 提交者: Zheng Zengkai

wifi: wilc1000: validate length of IEEE80211_P2P_ATTR_OPER_CHANNEL attribute

stable inclusion
from stable-v5.10.157
commit 905f886eae4b065656a575e8a02544045cbaadcf
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I66M3L
CVE: CVE-2022-47519

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=905f886eae4b065656a575e8a02544045cbaadcf

--------------------------------

commit 051ae669 upstream.

Validate that the IEEE80211_P2P_ATTR_OPER_CHANNEL attribute contains
enough space for a 'struct struct wilc_attr_oper_ch'. If the attribute is
too small then it triggers an out-of-bounds write later in the function.
Signed-off-by: NPhil Turnbull <philipturnbull@github.com>
Tested-by: NAjay Kathat <ajay.kathat@microchip.com>
Acked-by: NAjay Kathat <ajay.kathat@microchip.com>
Signed-off-by: NKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221123153543.8568-3-philipturnbull@github.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NBaisong Zhong <zhongbaisong@huawei.com>
Reviewed-by: NLiu Jian <liujian56@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 19484b6e
...@@ -939,14 +939,24 @@ static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u32 len, u8 sta_ch) ...@@ -939,14 +939,24 @@ static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u32 len, u8 sta_ch)
return; return;
while (index + sizeof(*e) <= len) { while (index + sizeof(*e) <= len) {
u16 attr_size;
e = (struct wilc_attr_entry *)&buf[index]; e = (struct wilc_attr_entry *)&buf[index];
attr_size = le16_to_cpu(e->attr_len);
if (index + sizeof(*e) + attr_size > len)
return;
if (e->attr_type == IEEE80211_P2P_ATTR_CHANNEL_LIST) if (e->attr_type == IEEE80211_P2P_ATTR_CHANNEL_LIST)
ch_list_idx = index; ch_list_idx = index;
else if (e->attr_type == IEEE80211_P2P_ATTR_OPER_CHANNEL) else if (e->attr_type == IEEE80211_P2P_ATTR_OPER_CHANNEL &&
attr_size == (sizeof(struct wilc_attr_oper_ch) - sizeof(*e)))
op_ch_idx = index; op_ch_idx = index;
if (ch_list_idx && op_ch_idx) if (ch_list_idx && op_ch_idx)
break; break;
index += le16_to_cpu(e->attr_len) + sizeof(*e);
index += sizeof(*e) + attr_size;
} }
if (ch_list_idx) { if (ch_list_idx) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册