提交 2abedb90 编写于 作者: P Phillip Potter 提交者: Zheng Zengkai

net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info

stable inclusion
from stable-5.10.39
commit 86587f35cba979c2d55376d08a9d553d846e84a5
bugzilla: 51881
CVE: NA

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

[ Upstream commit 2e9f6093 ]

Check at start of fill_frame_info that the MAC header in the supplied
skb is large enough to fit a struct hsr_ethhdr, as otherwise this is
not a valid HSR frame. If it is too small, return an error which will
then cause the callers to clean up the skb. Fixes a KMSAN-found
uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=f7e9b601f1414f814f7602a82b6619a8d80bce3f

Reported-by: syzbot+e267bed19bfc5478fb33@syzkaller.appspotmail.com
Signed-off-by: NPhillip Potter <phil@philpotter.co.uk>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 24ae53e5
...@@ -493,6 +493,10 @@ static int fill_frame_info(struct hsr_frame_info *frame, ...@@ -493,6 +493,10 @@ static int fill_frame_info(struct hsr_frame_info *frame,
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
__be16 proto; __be16 proto;
/* Check if skb contains hsr_ethhdr */
if (skb->mac_len < sizeof(struct hsr_ethhdr))
return -EINVAL;
memset(frame, 0, sizeof(*frame)); memset(frame, 0, sizeof(*frame));
frame->is_supervision = is_supervision_frame(port->hsr, skb); frame->is_supervision = is_supervision_frame(port->hsr, skb);
frame->node_src = hsr_get_node(port, &hsr->node_db, skb, frame->node_src = hsr_get_node(port, &hsr->node_db, skb,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册