Skip to content

Commit

Permalink
net: inet_is_local_reserved_port() port arg should be unsigned short
Browse files Browse the repository at this point in the history
Any argument outside of that range would result in an out of bound
memory access, since the accessed array is 65536 bits long.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Maciej Żenczykowski authored and David S. Miller committed Nov 26, 2019
1 parent 4e81c0b commit 66e2f5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/net/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -357,7 +357,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;
}
Expand Down

0 comments on commit 66e2f5f

Please sign in to comment.