netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces
@ 2017-03-24 16:38 Alexander Duyck
  2017-03-24 19:43 ` Eric Dumazet
  2017-03-24 22:02 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Duyck @ 2017-03-24 16:38 UTC (permalink / raw)
  To: netdev; +Cc: edumazet, davem

From: Alexander Duyck <alexander.h.duyck@intel.com>

This change basically codifies what I think was already the limitations on
the busy_poll and busy_read sysctl interfaces.  We weren't checking the
lower bounds and as such could input negative values. The behavior when
that was used was dependent on the architecture. In order to prevent any
issues with that I am just disabling support for values less than 0 since
this way we don't have to worry about any odd behaviors.

By limiting the sysctl values this way it also makes it consistent with how
we handle the SO_BUSY_POLL socket option since the value appears to be
reported as a signed integer value and negative values are rejected.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
 net/core/sysctl_net_core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 4ead336e14ea..7f9cc400eca0 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -408,14 +408,16 @@ static int proc_do_rss_key(struct ctl_table *table, int write,
 		.data		= &sysctl_net_busy_poll,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &zero,
 	},
 	{
 		.procname	= "busy_read",
 		.data		= &sysctl_net_busy_read,
 		.maxlen		= sizeof(unsigned int),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &zero,
 	},
 #endif
 #ifdef CONFIG_NET_SCHED

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces
  2017-03-24 16:38 [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces Alexander Duyck
@ 2017-03-24 19:43 ` Eric Dumazet
  2017-03-24 22:02 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2017-03-24 19:43 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: netdev, edumazet, davem

On Fri, 2017-03-24 at 09:38 -0700, Alexander Duyck wrote:
> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This change basically codifies what I think was already the limitations on
> the busy_poll and busy_read sysctl interfaces.  We weren't checking the
> lower bounds and as such could input negative values. The behavior when
> that was used was dependent on the architecture. In order to prevent any
> issues with that I am just disabling support for values less than 0 since
> this way we don't have to worry about any odd behaviors.
> 
> By limiting the sysctl values this way it also makes it consistent with how
> we handle the SO_BUSY_POLL socket option since the value appears to be
> reported as a signed integer value and negative values are rejected.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> ---


Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces
  2017-03-24 16:38 [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces Alexander Duyck
  2017-03-24 19:43 ` Eric Dumazet
@ 2017-03-24 22:02 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-03-24 22:02 UTC (permalink / raw)
  To: alexander.duyck; +Cc: netdev, edumazet

From: Alexander Duyck <alexander.duyck@gmail.com>
Date: Fri, 24 Mar 2017 09:38:03 -0700

> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This change basically codifies what I think was already the limitations on
> the busy_poll and busy_read sysctl interfaces.  We weren't checking the
> lower bounds and as such could input negative values. The behavior when
> that was used was dependent on the architecture. In order to prevent any
> issues with that I am just disabling support for values less than 0 since
> this way we don't have to worry about any odd behaviors.
> 
> By limiting the sysctl values this way it also makes it consistent with how
> we handle the SO_BUSY_POLL socket option since the value appears to be
> reported as a signed integer value and negative values are rejected.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-24 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-24 16:38 [net PATCH] net: Do not allow negative values for busy_read and busy_poll sysctl interfaces Alexander Duyck
2017-03-24 19:43 ` Eric Dumazet
2017-03-24 22:02 ` 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).