developer | 7e32f7e | 2022-05-18 21:10:08 +0800 | [diff] [blame^] | 1 | From b06d072ccc4b1acd0147b17914b7ad1caa1818bb Mon Sep 17 00:00:00 2001 |
| 2 | From: Willem de Bruijn <willemb@google.com> |
| 3 | Date: Sun, 22 Mar 2020 13:51:13 -0400 |
| 4 | Subject: macsec: restrict to ethernet devices |
| 5 | |
| 6 | Only attach macsec to ethernet devices. |
| 7 | |
| 8 | Syzbot was able to trigger a KMSAN warning in macsec_handle_frame |
| 9 | by attaching to a phonet device. |
| 10 | |
| 11 | Macvlan has a similar check in macvlan_port_create. |
| 12 | |
| 13 | v1->v2 |
| 14 | - fix commit message typo |
| 15 | |
| 16 | Reported-by: syzbot <syzkaller@googlegroups.com> |
| 17 | Signed-off-by: Willem de Bruijn <willemb@google.com> |
| 18 | Signed-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 | |