* [PATCH net] hsr: check protocol version in hsr_newlink()
@ 2020-04-07 13:23 Taehee Yoo
2020-04-08 1:35 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Taehee Yoo @ 2020-04-07 13:23 UTC (permalink / raw)
To: davem, kuba, netdev; +Cc: ap420073
In the current hsr code, only 0 and 1 protocol versions are valid.
But current hsr code doesn't check the version, which is received by
userspace.
Test commands:
ip link add dummy0 type dummy
ip link add dummy1 type dummy
ip link add hsr0 type hsr slave1 dummy0 slave2 dummy1 version 4
In the test commands, version 4 is invalid.
So, the command should be failed.
After this patch, following error will occur.
"Error: hsr: Only versions 0..1 are supported."
Fixes: ee1c27977284 ("net/hsr: Added support for HSR v1")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
net/hsr/hsr_netlink.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
index 5465a395da04..1decb25f6764 100644
--- a/net/hsr/hsr_netlink.c
+++ b/net/hsr/hsr_netlink.c
@@ -69,10 +69,16 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
else
multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]);
- if (!data[IFLA_HSR_VERSION])
+ if (!data[IFLA_HSR_VERSION]) {
hsr_version = 0;
- else
+ } else {
hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]);
+ if (hsr_version > 1) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Only versions 0..1 are supported");
+ return -EINVAL;
+ }
+ }
return hsr_dev_finalize(dev, link, multicast_spec, hsr_version, extack);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] hsr: check protocol version in hsr_newlink()
2020-04-07 13:23 [PATCH net] hsr: check protocol version in hsr_newlink() Taehee Yoo
@ 2020-04-08 1:35 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-04-08 1:35 UTC (permalink / raw)
To: ap420073; +Cc: kuba, netdev
From: Taehee Yoo <ap420073@gmail.com>
Date: Tue, 7 Apr 2020 13:23:21 +0000
> In the current hsr code, only 0 and 1 protocol versions are valid.
> But current hsr code doesn't check the version, which is received by
> userspace.
>
> Test commands:
> ip link add dummy0 type dummy
> ip link add dummy1 type dummy
> ip link add hsr0 type hsr slave1 dummy0 slave2 dummy1 version 4
>
> In the test commands, version 4 is invalid.
> So, the command should be failed.
>
> After this patch, following error will occur.
> "Error: hsr: Only versions 0..1 are supported."
>
> Fixes: ee1c27977284 ("net/hsr: Added support for HSR v1")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-08 1:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 13:23 [PATCH net] hsr: check protocol version in hsr_newlink() Taehee Yoo
2020-04-08 1:35 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).