All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Dave Jones <davej@redhat.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: net: llc: NULL ptr deref in llc_ui_sendmsg
Date: Fri, 06 Jun 2014 21:51:03 +0400	[thread overview]
Message-ID: <5391FF87.1010000@cogentembedded.com> (raw)
In-Reply-To: <20140606154231.GA7629@redhat.com>

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


  reply	other threads:[~2014-06-06 17:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 15:08 net: llc: NULL ptr deref in llc_ui_sendmsg Sasha Levin
2014-06-06 15:42 ` Dave Jones
2014-06-06 17:51   ` Sergei Shtylyov [this message]
2014-06-06 17:53   ` Sasha Levin
2014-06-07 15:02     ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5391FF87.1010000@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=acme@redhat.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sasha.levin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.