Skip to contentSkip to conversation

net: Do not allow negative values for busy_read and busy_poll sysctl interfaces

PATCH Applied Alexander Duyck 3 participants 3 messages Mar 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Do not allow negative values for busy_read and busy_poll sysctl interfaces

From: Alexander Duyck <[email protected]>

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.

---
 net/core/sysctl_net_core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/sysctl_net_core.c +4 -2
index 4ead336e14ea..7f9cc400eca0 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Alexander Duyck

From: Alexander Duyck <[email protected]>

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.

Quoted 6 lines

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.

---

maintainer Applied
#2 lore raw
In reply to Alexander Duyck

From: Alexander Duyck <[email protected]>
Date: Fri, 24 Mar 2017 09:38:03 -0700

Quoted 9 lines

From: Alexander Duyck <[email protected]>

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.

Quoted 5 lines

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.

Applied, thanks.