Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbaFFRuy (ORCPT ); Fri, 6 Jun 2014 13:50:54 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:63167 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750717AbaFFRuw (ORCPT ); Fri, 6 Jun 2014 13:50:52 -0400 Message-ID: <5391FF87.1010000@cogentembedded.com> Date: Fri, 06 Jun 2014 21:51:03 +0400 From: Sergei Shtylyov Organization: Cogent Embedded User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Dave Jones , Sasha Levin , Arnaldo Carvalho de Melo , "David S. Miller" , "netdev@vger.kernel.org" , LKML Subject: Re: net: llc: NULL ptr deref in llc_ui_sendmsg References: <5391D971.4030001@oracle.com> <20140606154231.GA7629@redhat.com> In-Reply-To: <20140606154231.GA7629@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 06/06/2014 07:42 PM, Dave Jones wrote: > > Hi all, > > While fuzzing with trinity inside a KVM tools guest running the latest -next > > kernel I've stumbled on the following spew: > > [ 269.531162] BUG: unable to handle kernel NULL pointer dereference at 000000000000021e > > [ 269.531217] IP: llc_ui_sendmsg (net/llc/af_llc.c:912) > 905 /* must bind connection to sap if user hasn't done it. */ > 906 if (sock_flag(sk, SOCK_ZAPPED)) { > 907 /* bind to sap with null dev, exclusive. */ > 908 rc = llc_ui_autobind(sock, addr); > 909 if (rc) > 910 goto release; > 911 } > 912 hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr); > looks like llc->dev was null, (understandable, given Trinity doesn't really know > how to set up llc beyond random socket()/setsockopt() calls). > llc_ui_autobind returns -ENODEV in that case, so it looks like the SOCK_ZAPPED test > was false. Something like the patch below maybe ? It feels ugly to be duplicating that > test there, but if this is agreed upon I'll resubmit this properly. > Dave > diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c > index 0080d2b0a8ae..9b192db9883b 100644 > --- a/net/llc/af_llc.c > +++ b/net/llc/af_llc.c > @@ -908,6 +908,11 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, > rc = llc_ui_autobind(sock, addr); > if (rc) > goto release; > + } else { > + if (!llc->dev) { } else if (!llc->dev) { > + rc = -ENODEV; > + goto release; > + } > } > hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr); > size = hdrlen + len; WBR, Sergei -- 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/