summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2020-03-22 20:51:13 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-02 16:28:10 +0300
commit1e62437e33fd8c75b84a06419ed1fba7d9263248 (patch)
treefb1d6a3a8c36c091b46a21dee9af66aa3e863753
parentb1ab6a51895d569c0996734d6e320ea79fd9a924 (diff)
downloadlinux-1e62437e33fd8c75b84a06419ed1fba7d9263248.tar.xz
macsec: restrict to ethernet devices
[ Upstream commit b06d072ccc4b1acd0147b17914b7ad1caa1818bb ] Only attach macsec to ethernet devices. Syzbot was able to trigger a KMSAN warning in macsec_handle_frame by attaching to a phonet device. Macvlan has a similar check in macvlan_port_create. v1->v2 - fix commit message typo Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/macsec.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 9a8ec94e8a44..df7d6de7c59c 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -20,6 +20,7 @@
#include <net/genetlink.h>
#include <net/sock.h>
#include <net/gro_cells.h>
+#include <linux/if_arp.h>
#include <uapi/linux/if_macsec.h>
@@ -3248,6 +3249,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
real_dev = __dev_get_by_index(net, nla_get_u32(tb[IFLA_LINK]));
if (!real_dev)
return -ENODEV;
+ if (real_dev->type != ARPHRD_ETHER)
+ return -EINVAL;
dev->priv_flags |= IFF_MACSEC;