net/sock: allow the user to set negative peek offset
authorPaolo Abeni <pabeni@redhat.com>
Wed, 23 Aug 2017 09:57:51 +0000 (11:57 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Aug 2017 05:18:44 +0000 (22:18 -0700)
This is necessary to allow the user to disable peeking with
offset once it's enabled.
Unix sockets already allow the above, with this patch we
permit it for udp[6] sockets, too.

Fixes: 627d2d6b5500 ("udp: enable MSG_PEEK at non-zero offset")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 0f04d8bff607bfc7c46aa07544fb44cc02054f95..dfdd14cac775e9bfcee0085ee32ffcd0ab28b67b 100644 (file)
@@ -2454,9 +2454,6 @@ EXPORT_SYMBOL(__sk_mem_reclaim);
 
 int sk_set_peek_off(struct sock *sk, int val)
 {
-       if (val < 0)
-               return -EINVAL;
-
        sk->sk_peek_off = val;
        return 0;
 }