From: Patrick McHardy <kaber@trash.net>
To: David Miller <davem@davemloft.net>
Cc: 12o3l@tiscali.nl, 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: Thu, 17 Apr 2008 06:55:35 +0200 [thread overview]
Message-ID: <4806D847.2030806@trash.net> (raw)
In-Reply-To: <20080416.213712.78410382.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]
David Miller wrote:
> 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.
The change is also unnecessary because the attribute was
already validated and the length can not be less than zero.
This patch changes it to only check for zero length.
Signed-off-by: Patrick McHardy <kaber@trash.net>
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 417 bytes --]
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index fbde461..64b2d13 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -115,7 +115,7 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
return -EINVAL;
datalen = nla_len(tb[TCA_DEF_DATA]);
- if (datalen <= 0)
+ if (datalen == 0)
return -EINVAL;
pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
next prev parent reply other threads:[~2008-04-17 4:55 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
2008-04-17 4:55 ` Patrick McHardy [this message]
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=4806D847.2030806@trash.net \
--to=kaber@trash.net \
--cc=12o3l@tiscali.nl \
--cc=davem@davemloft.net \
--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).