From: Phillip Potter <phil@philpotter.co.uk>
To: davem@davemloft.net
Cc: kuba@kernel.org, m-karicheri2@ti.com, olteanv@gmail.com,
george.mccollister@gmail.com, ap420073@gmail.com,
wanghai38@huawei.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info
Date: Sun, 2 May 2021 22:34:42 +0100 [thread overview]
Message-ID: <20210502213442.2139-1-phil@philpotter.co.uk> (raw)
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: Phillip Potter <phil@philpotter.co.uk>
---
net/hsr/hsr_forward.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index ed82a470b6e1..f86cdd83e9a8 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -520,6 +520,10 @@ static int fill_frame_info(struct hsr_frame_info *frame,
struct ethhdr *ethhdr;
__be16 proto;
+ /* Check if skb contains hsr_ethhdr */
+ if (skb->mac_len < sizeof(struct hsr_ethhdr))
+ return -EINVAL;
+
memset(frame, 0, sizeof(*frame));
frame->is_supervision = is_supervision_frame(port->hsr, skb);
frame->node_src = hsr_get_node(port, &hsr->node_db, skb,
--
2.30.2
next reply other threads:[~2021-05-02 21:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-02 21:34 Phillip Potter [this message]
2021-05-03 20:40 ` [PATCH] net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210502213442.2139-1-phil@philpotter.co.uk \
--to=phil@philpotter.co.uk \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=george.mccollister@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-karicheri2@ti.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=wanghai38@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).