public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dave Jones <davej@redhat.com>
Cc: netdev@vger.kernel.org, Matthew Daley <mattjd@gmail.com>
Subject: Re: [v2] Fix NULL dereference in x25_recvmsg
Date: Wed, 02 Nov 2011 03:30:17 +0100	[thread overview]
Message-ID: <1320201017.4728.31.camel@edumazet-laptop> (raw)
In-Reply-To: <20111102022644.GB8512@redhat.com>

Le mardi 01 novembre 2011 à 22:26 -0400, Dave Jones a écrit :
> commit cb101ed2 in 3.0 introduced a bug in x25_recvmsg()
> When passed bogus junk from userspace, x25->neighbour can be NULL,
> as shown in this oops..
> 
...
> Signed-off-by: Dave Jones <davej@redhat.com>
> 
> diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
> index 5f03e4e..3e16c6a 100644
> --- a/net/x25/af_x25.c
> +++ b/net/x25/af_x25.c
> @@ -1261,14 +1261,19 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
>  	struct x25_sock *x25 = x25_sk(sk);
>  	struct sockaddr_x25 *sx25 = (struct sockaddr_x25 *)msg->msg_name;
>  	size_t copied;
> -	int qbit, header_len = x25->neighbour->extended ?
> -		X25_EXT_MIN_LEN : X25_STD_MIN_LEN;
> -
> +	int qbit, header_len;
>  	struct sk_buff *skb;
>  	unsigned char *asmptr;
>  	int rc = -ENOTCONN;
>  
>  	lock_sock(sk);
> +
> +	if (x25->neighbour == NULL)
> +		goto out;
> +
> +	header_len = x25->neighbour->extended ?
> +		X25_EXT_MIN_LEN : X25_STD_MIN_LEN;
> +
>  	/*
>  	 * This works for seqpacket too. The receiver has ordered the queue for
>  	 * us! We do one quick check first though

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

  reply	other threads:[~2011-11-02  2:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02  1:53 Fix NULL dereference in x25_recvmsg Dave Jones
2011-11-02  2:10 ` Eric Dumazet
2011-11-02  2:15   ` Dave Jones
2011-11-02  2:19     ` Eric Dumazet
2011-11-02  2:21       ` Eric Dumazet
2011-11-02  2:16 ` Eric Dumazet
2011-11-02  2:26   ` [v2] " Dave Jones
2011-11-02  2:30     ` Eric Dumazet [this message]
2011-11-02  4:50       ` David Miller

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=1320201017.4728.31.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davej@redhat.com \
    --cc=mattjd@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox