blob: bae5efa0c17a5b74c885905927e40953423e6059 [file] [log] [blame]
developer7e32f7e2022-05-18 21:10:08 +08001From b06d072ccc4b1acd0147b17914b7ad1caa1818bb Mon Sep 17 00:00:00 2001
2From: Willem de Bruijn <willemb@google.com>
3Date: Sun, 22 Mar 2020 13:51:13 -0400
4Subject: macsec: restrict to ethernet devices
5
6Only attach macsec to ethernet devices.
7
8Syzbot was able to trigger a KMSAN warning in macsec_handle_frame
9by attaching to a phonet device.
10
11Macvlan has a similar check in macvlan_port_create.
12
13v1->v2
14 - fix commit message typo
15
16Reported-by: syzbot <syzkaller@googlegroups.com>
17Signed-off-by: Willem de Bruijn <willemb@google.com>
18Signed-off-by: David S. Miller <davem@davemloft.net>
19---
20 drivers/net/macsec.c | 3 +++
21 1 file changed, 3 insertions(+)
22
23--- a/drivers/net/macsec.c
24+++ b/drivers/net/macsec.c
25@@ -20,6 +20,7 @@
26 #include <net/macsec.h>
27 #include <linux/phy.h>
28 #include <linux/byteorder/generic.h>
29+#include <linux/if_arp.h>
30
31 #include <uapi/linux/if_macsec.h>
32
33@@ -3859,6 +3860,8 @@ static int macsec_newlink(struct net *ne
34 real_dev = __dev_get_by_index(net, nla_get_u32(tb[IFLA_LINK]));
35 if (!real_dev)
36 return -ENODEV;
37+ if (real_dev->type != ARPHRD_ETHER)
38+ return -EINVAL;
39
40 dev->priv_flags |= IFF_MACSEC;
41