public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Lauro Ramos Venancio
	<lauro.venancio-430g2QfJUUCGglJvpFV4uA@public.gmane.org>,
	Aloisio Almeida Jr
	<aloisio.almeida-430g2QfJUUCGglJvpFV4uA@public.gmane.org>,
	Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	"John W. Linville"
	<linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
	Thierry Escande
	<thierry.escande-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-nfc-y27Ovi1pjclAfugRpC6u6w@public.gmane.org"
	<linux-nfc-y27Ovi1pjclAfugRpC6u6w@public.gmane.org>,
	"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [patch] NFC: llcp: integer underflow in nfc_llcp_set_remote_gb()
Date: Thu, 7 Feb 2013 11:16:01 +0100	[thread overview]
Message-ID: <2148581.S8tzak9aE2@uw000953> (raw)
In-Reply-To: <20130131081645.GA14812-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>

Hi Dan,

On Thursday 31 of January 2013 10:16:46 Dan Carpenter wrote:
> If gb_len is less than 3 it would cause an integer underflow and
> possibly memory corruption in nfc_llcp_parse_gb_tlv().
> 
> I removed the old test for gb_len == 0.  I also removed the test for
> ->remote_gb == NULL.  It's not possible for ->remote_gb to be NULL and
> we have already dereferenced ->remote_gb_len so it's too late to test.
> 
> The old test return -ENODEV but my test returns -EINVAL.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> 
> diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
> index 85bc75c..746f5a2 100644
> --- a/net/nfc/llcp/llcp.c
> +++ b/net/nfc/llcp/llcp.c
> @@ -549,14 +549,13 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len)
>  		pr_err("No LLCP device\n");
>  		return -ENODEV;
>  	}
> +	if (gb_len < 3)
> +		return -EINVAL;

Maybe define NFC_MIN_GT_LEN and test it together with NFC_MAX_GT_LEN in
nfc_set_remote_general_bytes() ?

>  
>  	memset(local->remote_gb, 0, NFC_MAX_GT_LEN);
>  	memcpy(local->remote_gb, gb, gb_len);
>  	local->remote_gb_len = gb_len;
>  
> -	if (local->remote_gb == NULL || local->remote_gb_len == 0)
> -		return -ENODEV;
> -
>  	if (memcmp(local->remote_gb, llcp_magic, 3)) {
>  		pr_err("MAC does not support LLCP\n");
>  		return -EINVAL;

-- 
BR
Szymon Janc
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-02-07 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31  8:16 [patch] NFC: llcp: integer underflow in nfc_llcp_set_remote_gb() Dan Carpenter
     [not found] ` <20130131081645.GA14812-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2013-02-07 10:16   ` Szymon Janc [this message]
2013-03-01  5:20     ` [patch] NFC: llcp: cleanup underflow check Dan Carpenter

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=2148581.S8tzak9aE2@uw000953 \
    --to=szymon.janc-++hxygjemp0avxtiumwx3w@public.gmane.org \
    --cc=aloisio.almeida-430g2QfJUUCGglJvpFV4uA@public.gmane.org \
    --cc=dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lauro.venancio-430g2QfJUUCGglJvpFV4uA@public.gmane.org \
    --cc=linux-nfc-y27Ovi1pjclAfugRpC6u6w@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=thierry.escande-VuQAYsv1563Yd54FQh9/CA@public.gmane.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