Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mat Martineau and committed by
David S. Miller
e9cdced7 6b3acfc3

+2 -3
-1
include/net/sock.h
··· 458 458 sk_userlocks : 4, 459 459 sk_protocol : 8, 460 460 sk_type : 16; 461 - #define SK_PROTOCOL_MAX U8_MAX 462 461 u16 sk_gso_max_segs; 463 462 u8 sk_pacing_shift; 464 463 unsigned long sk_lingertime;
+1 -1
net/ax25/af_ax25.c
··· 808 808 struct sock *sk; 809 809 ax25_cb *ax25; 810 810 811 - if (protocol < 0 || protocol > SK_PROTOCOL_MAX) 811 + if (protocol < 0 || protocol > U8_MAX) 812 812 return -EINVAL; 813 813 814 814 if (!net_eq(net, &init_net))
+1 -1
net/decnet/af_decnet.c
··· 670 670 { 671 671 struct sock *sk; 672 672 673 - if (protocol < 0 || protocol > SK_PROTOCOL_MAX) 673 + if (protocol < 0 || protocol > U8_MAX) 674 674 return -EINVAL; 675 675 676 676 if (!net_eq(net, &init_net))