Skip to contentSkip to conversation

net: inet_is_local_reserved_port() port arg should be unsigned short

PATCH Applied Maciej Żenczykowski 2 participants 2 messages Nov 26, 2019

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

PATCH 1/1 net: inet_is_local_reserved_port() port arg should be unsigned short

From: Maciej Żenczykowski <[email protected]>

Any argument outside of that range would result in an out of bound memory access, since the accessed array is 65536 bits long.

---
 include/net/ip.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/net/ip.h +2 -2
index c823aa279d21..cea69efe5322 100644
@@ -339,7 +339,7 @@ static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_o
 void inet_get_local_port_range(struct net *net, int *low, int *high);
 
 #ifdef CONFIG_SYSCTL
-static inline bool inet_is_local_reserved_port(struct net *net, int port)
+static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
 {
 	if (!net->ipv4.sysctl_local_reserved_ports)
 		return false;
@@ -358,7 +358,7 @@ static inline bool inet_port_requires_bind_service(struct net *net, unsigned sho
 }
 
 #else
-static inline bool inet_is_local_reserved_port(struct net *net, int port)
+static inline bool inet_is_local_reserved_port(struct net *net, unsigned short port)
 {
 	return false;
 }
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog