[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b2ba5228-dec0-9acf-49e9-d57f156814ef@virtuozzo.com>
Date: Fri, 22 Nov 2019 01:20:23 +0300
From: Andrey Ryabinin <aryabinin@...tuozzo.com>
To: Walter Wu <walter-zh.wu@...iatek.com>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Matthias Brugger <matthias.bgg@...il.com>
Cc: kasan-dev@...glegroups.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
wsd_upstream <wsd_upstream@...iatek.com>,
linux-mediatek@...ts.infradead.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v4 1/2] kasan: detect negative size in memory operation
function
On 11/12/19 9:53 AM, Walter Wu wrote:
> KASAN missed detecting size is a negative number in memset(), memcpy(),
> and memmove(), it will cause out-of-bounds bug. So needs to be detected
> by KASAN.
>
> If size is a negative number, then it has a reason to be defined as
> out-of-bounds bug type.
> Casting negative numbers to size_t would indeed turn up as
> a large size_t and its value will be larger than ULONG_MAX/2,
> so that this can qualify as out-of-bounds.
>
> KASAN report is shown below:
>
> BUG: KASAN: out-of-bounds in kmalloc_memmove_invalid_size+0x70/0xa0
> Read of size 18446744073709551608 at addr ffffff8069660904 by task cat/72
>
> CPU: 2 PID: 72 Comm: cat Not tainted 5.4.0-rc1-next-20191004ajb-00001-gdb8af2f372b2-dirty #1
> Hardware name: linux,dummy-virt (DT)
> Call trace:
> dump_backtrace+0x0/0x288
> show_stack+0x14/0x20
> dump_stack+0x10c/0x164
> print_address_description.isra.9+0x68/0x378
> __kasan_report+0x164/0x1a0
> kasan_report+0xc/0x18
> check_memory_region+0x174/0x1d0
> memmove+0x34/0x88
> kmalloc_memmove_invalid_size+0x70/0xa0
>
> [1] https://bugzilla.kernel.org/show_bug.cgi?id=199341
>
> Signed-off-by: Walter Wu <walter-zh.wu@...iatek.com>
> Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
> Suggested-by: Dmitry Vyukov <dvyukov@...gle.com>
> Reviewed-by: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: Andrey Ryabinin <aryabinin@...tuozzo.com>
> Cc: Alexander Potapenko <glider@...gle.com>
> Reported-by: kernel test robot <lkp@...el.com>
> ---
Reviewed-by: Andrey Ryabinin <aryabinin@...tuozzo.com>
Powered by blists - more mailing lists