ethtool: check the ethtool_ops is NULL in dev_ethtool
Subsystems (2)
PATCH 1/1 ethtool: check the ethtool_ops is NULL in dev_ethtool
some drivers maybe not implement the ethtool_ops with only set NULL. So when call the ethtool cmds will lead to a 'NULL pointer dereference'.
So add a checking in dev_ethtool.
--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/ethtool.c +3 -0
@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; } + +if (!dev->ethtool_ops) +return -EOPNOTSUPP ;if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);
Signature · 1 line
1.7.12
Quoted 16 lines · Wang Weidong
some drivers maybe not implement the
ethtool_opswith only set NULL. So when call the ethtool cmds will lead to a 'NULL pointer dereference'.So add a checking in
dev_ethtool.Signed-off-by Wang Weidong <[email protected]>--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)net/core/ethtool.c +0
-0
net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) · line 1502
Quoted 4 lines
net/core/ethtool.c +1
-0@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; } +
You have a trailing whitespace/tab in the line above. Please use checkpatch for detecting such things.
Can you be more specific with "some drivers"? Any driver that is in the mainline tree?
Quoted 6 lines
net/core/ethtool.c +2
-0+if (!dev->ethtool_ops) +return -EOPNOTSUPP ;if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);
Quoted 12 lines · Daniel Borkmann
Quoted 11 lines · Wang Weidong
some drivers maybe not implement the
ethtool_opswith only set NULL. So when call the ethtool cmds will lead to a 'NULL pointer dereference'.So add a checking in
dev_ethtool.Signed-off-by Wang Weidong <[email protected]>--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 13 lines
net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) · line 1502
Quoted 9 lines
net/core/ethtool.c +1
-0@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; } +You have a trailing whitespace/tab in the line above. Please use checkpatch for detecting such things.
Sorry for that. I will fix it soon.
Quoted 3 lines
Can you be more specific with "some drivers"? Any driver that is in the mainline tree?
No. My team implements a driver without considering the ethtool_ops. So I got the problem.
Quoted 8 lines
Quoted 6 lines
net/core/ethtool.c +2
-0+if (!dev->ethtool_ops) +return -EOPNOTSUPP ;if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);
Quoted 26 lines · Wang Weidong
Quoted 12 lines · Daniel Borkmann
Quoted 11 lines · Wang Weidong
some drivers maybe not implement the
ethtool_opswith only set NULL. So when call the ethtool cmds will lead to a 'NULL pointer dereference'.So add a checking in
dev_ethtool.Signed-off-by Wang Weidong <[email protected]>--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 13 lines
net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) · line 1502
Quoted 9 lines
net/core/ethtool.c +1
-0@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; } +You have a trailing whitespace/tab in the line above. Please use checkpatch for detecting such things.
Quoted 7 lines
Sorry for that. I will fix it soon.
Quoted 3 lines
Can you be more specific with "some drivers"? Any driver that is in the mainline tree?
No. My team implements a driver without considering the
ethtool_ops. So I got the problem.
If it's code that is out of the mainline tree, then why should the kernel support that? Submit your driver to the tree first, and then such a change could be considered. Or, even better, let them implement ethtool ops/stubs.
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
net/core/ethtool.c +2
-0+if (!dev->ethtool_ops) +return -EOPNOTSUPP ;if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);
Quoted 32 lines · Daniel Borkmann
Quoted 31 lines · Wang Weidong
Quoted 12 lines · Daniel Borkmann
Quoted 11 lines · Wang Weidong
some drivers maybe not implement the
ethtool_opswith only set NULL. So when call the ethtool cmds will lead to a 'NULL pointer dereference'.So add a checking in
dev_ethtool.Signed-off-by Wang Weidong <[email protected]>--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 13 lines
net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) · line 1502
Quoted 9 lines
net/core/ethtool.c +1
-0@@ -1499,6 +1499,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; } +You have a trailing whitespace/tab in the line above. Please use checkpatch for detecting such things.
Sorry for that. I will fix it soon.
Quoted 3 lines
Can you be more specific with "some drivers"? Any driver that is in the mainline tree?
Quoted 8 lines
Quoted 2 lines
No. My team implements a driver without considering the
ethtool_ops. So I got the problem.If it's code that is out of the mainline tree, then why should the kernel support that? Submit your driver to the tree first, and then such a change could be considered. Or, even better, let them implement ethtool ops/stubs.
Thanks for your reply. I will suggest them to implement ethtool ops.
Regards
Wang
Quoted 12 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
net/core/ethtool.c +2
-0+if (!dev->ethtool_ops) +return -EOPNOTSUPP ;if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);
PATCH v2 1/1 ethtool: check the ethtool_ops is NULL in dev_ethtool
In reply to Wang Weidongsome drivers maybe not implement the ethtool_ops with only set NULL to ethtool_ops. So when call the ethtool devx will lead to a 'NULL pointer dereference'.
So add a check in dev_ethtool
---
Change note:
v2: fix a trailing whitespace/tab pointed out by Daniel
--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/ethtool.c +3 -0
@@ -1500,6 +1500,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)return -EPERM ; } +if (!dev->ethtool_ops) +return -EOPNOTSUPP ; +if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);if (rc <0 )
Signature · 1 line
1.7.12
Just ignore it.
Regards
Wang
Quoted 31 lines · Wang Weidong
some drivers maybe not implement the
ethtool_opswith only set NULL toethtool_ops. So when call the ethtool devx will lead to a 'NULL pointer dereference'.So add a check in
dev_ethtoolSigned-off-by Wang Weidong <[email protected]>---
Change note:v2: fix a trailing whitespace/tab pointed out by Daniel
--- net/core/ethtool.c | 3 +++ 1 file changed, 3 insertions(+)net/core/ethtool.c +3
-0@@ -1500,6 +1500,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)return -EPERM ; } +if (!dev->ethtool_ops) +return -EOPNOTSUPP ; +if (dev->ethtool_ops->begin) { rc = dev->ethtool_ops->begin (dev);if (rc <0 )