Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1293346

Re: net: heap-out-of-bounds in sock_setsockopt

From Eric Dumazet <edumazet@google.com>
Newsgroups linux.kernel
Subject Re: net: heap-out-of-bounds in sock_setsockopt
Date 2015-12-16 22:10 +0100
Message-ID <qGruG-70F-11@gated-at.bofh.it> (permalink)
References <qGq5A-5XV-7@gated-at.bofh.it> <qGqRY-6vM-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Dec 16, 2015 at 12:22 PM, Cong Wang <cwang@twopensource.com> wrote:

> Hmm, we should exclude the raw socket case, something like the
> following, but I am not sure if the check is too strict or not, also
> not sure if we should return an error for this raw socket case.
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 765be83..c26e80a 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -872,7 +872,7 @@ int sock_setsockopt(struct socket *sock, int
> level, int optname,
>
>                 if (val & SOF_TIMESTAMPING_OPT_ID &&
>                     !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
> -                       if (sk->sk_protocol == IPPROTO_TCP) {
> +                       if (sk->sk_protocol == IPPROTO_TCP &&
> sk->sk_type == SOCK_STREAM) {
>                                 if (sk->sk_state != TCP_ESTABLISHED) {
>                                         ret = -EINVAL;
>                                         break;

This looks right, please post this officially ;)

tcp_sk(sk) only works for TCP sockets , and the test must include
sk->sk_type == SOCK_STREAM
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

net: heap-out-of-bounds in sock_setsockopt Dmitry Vyukov <dvyukov@google.com> - 2015-12-16 20:40 +0100
  Re: net: heap-out-of-bounds in sock_setsockopt Cong Wang <cwang@twopensource.com> - 2015-12-16 21:30 +0100
    Re: net: heap-out-of-bounds in sock_setsockopt Eric Dumazet <edumazet@google.com> - 2015-12-16 22:10 +0100
    Re: net: heap-out-of-bounds in sock_setsockopt Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2015-12-17 00:00 +0100

csiph-web