From: wzt wzt <wzt.wzt@gmail.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Xiaotian Feng <xtfeng@gmail.com>,
Patrick McHardy <kaber@trash.net>,
linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] Netfilter: Fix integer overflow in net/ipv6/netfilter/ip6_tables.c
Date: Tue, 23 Mar 2010 11:48:06 +0800 [thread overview]
Message-ID: <628d1651003222048k1eaf6929r81fd06e401190e0@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.01.1003230346010.12017@obet.zrqbmnf.qr>
1、 suppose *len = 35, sizeof(struct ipt_get_entries) = 36
2、 set get.size = 0xffffffff from user space
3、 sizeof(struct ipt_get_entries) + get.size = 36 + 0xffffffff = 35;
4、 if (*len != sizeof(struct ipt_get_entries) + get.size) was bypassed.
you can test with c code:
#include <stdio.h>
int main(void)
{
unsigned int arg = 0xffffffff;
printf("%u\n", arg + 36);
if (35 != arg + 36) {
printf("not over flow.\n");
return -1;
}
printf("arg over flow.\n");
return 0;
}
On Tue, Mar 23, 2010 at 11:04 AM, Jan Engelhardt <jengelh@medozas.de> wrote:
>
> On Tuesday 2010-03-23 03:37, wzt wzt wrote:
>>> And, for the addition overflow, can it be caught by
>>>
>>> "if (*len != sizeof(struct ipt_get_entries) + get.size)" ???
>>
>>sizeof(struct ipt_get_entries) + get.size can be overflow as *len,
>>get.size is control by user space with copy_from_user().
>
> The != should catch it.
>
> For 64-bit environments:
> * + invoked with size_t, unsigned int
> => right side promoted to size_t, result type is size_t
> * != invoked with int and size_t
> => left-side promoted to ssize_t (probably; but something as large as size_t)
> * get.size is 32-bit bounded, as is *len,
> so no overflow to worry about at all unless you make
> sizeof(X) hilariously big close to 2^64 which is rather unlikely.
>
> For 32-bit environments:
> * Let *len be a number of choice (e.g. 36)
> * Find a sizeof(X)+get.size that equals 36 mod 2^32.
> * Since sizeof(X) is const, get.size must be 0 mod 2^32.
> * So get.size must be a multiple of 2^32 to fool the system.
> * Since get.size itself is only a 32-bit quantity, you cannot
> represent any value larger than 4294967295.
>
>
> What Was What Was Wanted.
>
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-03-23 3:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-20 14:32 [PATCH] Netfilter: Fix integer overflow in net/ipv6/netfilter/ip6_tables.c wzt.wzt
2010-03-22 17:07 ` Patrick McHardy
2010-03-23 1:34 ` wzt wzt
2010-03-23 2:29 ` Xiaotian Feng
2010-03-23 2:37 ` wzt wzt
2010-03-23 3:04 ` Jan Engelhardt
2010-03-23 3:48 ` wzt wzt [this message]
2010-03-23 4:49 ` Xiaotian Feng
2010-03-23 5:49 ` wzt wzt
2010-03-23 3:05 ` Xiaotian Feng
2010-03-23 3:11 ` wzt wzt
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=628d1651003222048k1eaf6929r81fd06e401190e0@mail.gmail.com \
--to=wzt.wzt@gmail.com \
--cc=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=xtfeng@gmail.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 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).