netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: 12o3l@tiscali.nl
Cc: hadi@cyberus.ca, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NET: catch signed nla_len() retval in tcf_simp_init()
Date: Wed, 16 Apr 2008 21:37:12 -0700 (PDT)	[thread overview]
Message-ID: <20080416.213712.78410382.davem@davemloft.net> (raw)
In-Reply-To: <4806C501.20300@tiscali.nl>

From: Roel Kluin <12o3l@tiscali.nl>
Date: Thu, 17 Apr 2008 05:33:21 +0200

> 'datalen' is unsigned, use 'ret' instead to catch a negative return value.
> 
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
> index fbde461..b78d015 100644
> --- a/net/sched/act_simple.c
> +++ b/net/sched/act_simple.c
> @@ -114,9 +114,10 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
>  	if (defdata == NULL)
>  		return -EINVAL;
>  
> -	datalen = nla_len(tb[TCA_DEF_DATA]);
> -	if (datalen <= 0)
> +	ret = nla_len(tb[TCA_DEF_DATA]);
> +	if (ret <= 0)
>  		return -EINVAL;
> +	datalen = ret;
>  
>  	pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
>  	if (!pc) {

This clobbers 'ret' which is compared to ACT_P_CREATED
later in the function.  If the !pc branch below this code
is not taken, ret must be left at it's initial value of
zero.  Now, it will take on some non-zero positive value
which is not correct.


  reply	other threads:[~2008-04-17  4:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-17  3:33 [PATCH] NET: catch signed nla_len() retval in tcf_simp_init() Roel Kluin
2008-04-17  4:37 ` David Miller [this message]
2008-04-17  4:55   ` Patrick McHardy
2008-04-17 12:58     ` jamal
2008-04-17 13:10       ` Patrick McHardy
2008-04-17 13:36         ` jamal
2008-04-18  6:20     ` 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=20080416.213712.78410382.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=12o3l@tiscali.nl \
    --cc=hadi@cyberus.ca \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).