Thread (8 messages) flat view 8 messages, 3 authors, 2018-01-09

Re: [PATCH net-next 1/3] ethtool: Ensure new ring parameters are within bounds during SRINGPARAM

From: Jakub Kicinski <hidden>
Date: 2018-01-09 07:35:56

On Tue, 9 Jan 2018 09:30:05 +0200
Tariq Toukan [off-list ref] wrote:
quoted
quoted
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 50a79203043b..9ea7cd52fde0 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1704,14 +1704,23 @@ static int ethtool_get_ringparam(struct
net_device *dev, void __user *useraddr) 
  static int ethtool_set_ringparam(struct net_device *dev, void
__user *useraddr) {
-	struct ethtool_ringparam ringparam;
+	struct ethtool_ringparam ringparam, max = { .cmd =
ETHTOOL_GRINGPARAM }; 
-	if (!dev->ethtool_ops->set_ringparam)
+	if (!dev->ethtool_ops->set_ringparam
|| !dev->ethtool_ops->get_ringparam) return -EOPNOTSUPP;
  
  	if (copy_from_user(&ringparam, useraddr,
sizeof(ringparam))) return -EFAULT;
  
+	dev->ethtool_ops->get_ringparam(dev, &max);  
Perhaps check the return value here?  It's pretty unlikely but
get_ringparam may fail.
  
get_ringparam NDO returns void.
Ah, you're right, I looked at the return of ethtool_get_ringparam().
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help