]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
net: check dev->addr_len for dev_set_mac_address()
authorWANG Cong <xiyou.wangcong@gmail.com>
Wed, 26 Jul 2017 22:22:06 +0000 (15:22 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Jul 2017 18:25:05 +0000 (11:25 -0700)
commit0254e0c632bfe4a0cf610e2d90397474144f00d2
tree80b3164f82ae010a864fff268ffc5c1fb40119b9
parent245db3c349e0b413e0fec8d6179f6b767649ad63
net: check dev->addr_len for dev_set_mac_address()

Historically, dev_ifsioc() uses struct sockaddr as mac
address definition, this is why dev_set_mac_address()
accepts a struct sockaddr pointer as input but now we
have various types of mac addresse whose lengths
are up to MAX_ADDR_LEN, longer than struct sockaddr,
and saved in dev->addr_len.

It is too late to fix dev_ifsioc() due to API
compatibility, so just reject those larger than
sizeof(struct sockaddr), otherwise we would read
and use some random bytes from kernel stack.

Fortunately, only a few IPv6 tunnel devices have addr_len
larger than sizeof(struct sockaddr) and they don't support
ndo_set_mac_addr(). But with team driver, in lb mode, they
can still be enslaved to a team master and make its mac addr
length as the same.

Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev_ioctl.c