Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755457AbbLPVHe (ORCPT ); Wed, 16 Dec 2015 16:07:34 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:35883 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755435AbbLPVHc (ORCPT ); Wed, 16 Dec 2015 16:07:32 -0500 MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 16 Dec 2015 13:07:30 -0800 Message-ID: Subject: Re: net: heap-out-of-bounds in sock_setsockopt From: Eric Dumazet To: Cong Wang Cc: Dmitry Vyukov , Willem de Bruijn , "David S. Miller" , "Eric W. Biederman" , Mel Gorman , Craig Gallek , Ying Xue , Hannes Frederic Sowa , Edward Jee , Julia Lawall , netdev , LKML , syzkaller , Kostya Serebryany , Alexander Potapenko , Sasha Levin Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1353 Lines: 31 On Wed, Dec 16, 2015 at 12:22 PM, Cong Wang 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/