BACKPORT: net: Make sock protocol value checks more specific

SK_PROTOCOL_MAX is only used in two places, for DECNet and AX.25. The
limits have more to do with the those protocol definitions than they do
with the data type of sk_protocol, so remove SK_PROTOCOL_MAX and use
U8_MAX directly.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Change-Id: I3d1e12f0cd3ddb2db11a2eaad5e3a1a85c59db06
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
Mat Martineau 2020-01-09 07:59:14 -08:00 • committed by Sorayukii
commit 8c2bb3ec8d
2 changed files with 1 additions and 2 deletions

View file

@ -443,7 +443,6 @@ struct sock {
sk_userlocks : 4,
sk_protocol : 8,
sk_type : 16;
#define SK_PROTOCOL_MAX U8_MAX
kmemcheck_bitfield_end(flags);
u16 sk_gso_max_segs;

View file

@ -826,7 +826,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk;
ax25_cb *ax25;
if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
if (protocol < 0 || protocol > U8_MAX)
return -EINVAL;
if (!net_eq(net, &init_net))