]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info
authorPhillip Potter <phil@philpotter.co.uk>
Sun, 2 May 2021 21:34:42 +0000 (22:34 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 May 2021 20:33:54 +0000 (13:33 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/hsr/hsr_forward.c

index b218e4594009ca5e690e21f1bba04dba3a5ace05..6852e9bccf5b8c694004e6f94851bf528039ba6d 100644 (file)
@@ -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,