]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: Make sock protocol value checks more specific
authorMat Martineau <mathew.j.martineau@linux.intel.com>
Thu, 9 Jan 2020 15:59:14 +0000 (07:59 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 10 Jan 2020 02:41:40 +0000 (18:41 -0800)
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>
include/net/sock.h
net/ax25/af_ax25.c
net/decnet/af_decnet.c

index 8dff68b4c3168a75c762e31e8fe91abb519554e2..091e554284154f0b4519ae70aaf9943a0539ea39 100644 (file)
@@ -458,7 +458,6 @@ struct sock {
                                sk_userlocks : 4,
                                sk_protocol  : 8,
                                sk_type      : 16;
-#define SK_PROTOCOL_MAX U8_MAX
        u16                     sk_gso_max_segs;
        u8                      sk_pacing_shift;
        unsigned long           sk_lingertime;
index 324306d6fde02cb67e13073986bde1c4ed7eae5f..ff57ea89c27e652c1128f68e69e22d41be361dac 100644 (file)
@@ -808,7 +808,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))
index e19a92a62e142611f78d942ba22d2b1908430660..0a46ea3bddd541666320cbdef464adc17c97a033 100644 (file)
@@ -670,7 +670,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
 {
        struct sock *sk;
 
-       if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+       if (protocol < 0 || protocol > U8_MAX)
                return -EINVAL;
 
        if (!net_eq(net, &init_net))