LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: ajk@comnets.uni-bremen.de, davem@davemloft.net, kuba@kernel.org,
	linux-hams@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	syzbot+fc8cd9a673d4577fb2e4@syzkaller.appspotmail.com
Subject: Re: [PATCH] net: 6pack: fix slab-out-of-bounds in decode_data
Date: Fri, 13 Aug 2021 18:09:16 +0300	[thread overview]
Message-ID: <0c5bc329-6555-edb1-82ad-038cae6b0299@gmail.com> (raw)
In-Reply-To: <20210813145834.GC1931@kadam>

On 8/13/21 5:58 PM, Dan Carpenter wrote:
> On Fri, Aug 13, 2021 at 02:28:55PM +0300, Pavel Skripkin wrote:
>> Syzbot reported slab-out-of bounds write in decode_data().
>> The problem was in missing validation checks.
>> 
>> Syzbot's reproducer generated malicious input, which caused
>> decode_data() to be called a lot in sixpack_decode(). Since
>> rx_count_cooked is only 400 bytes and noone reported before,
>> that 400 bytes is not enough, let's just check if input is malicious
>> and complain about buffer overrun.
>> 
>> Fail log:
>> ==================================================================
>> BUG: KASAN: slab-out-of-bounds in drivers/net/hamradio/6pack.c:843
>> Write of size 1 at addr ffff888087c5544e by task kworker/u4:0/7
>> 
>> CPU: 0 PID: 7 Comm: kworker/u4:0 Not tainted 5.6.0-rc3-syzkaller #0
>> ...
>> Workqueue: events_unbound flush_to_ldisc
>> Call Trace:
>>  __dump_stack lib/dump_stack.c:77 [inline]
>>  dump_stack+0x197/0x210 lib/dump_stack.c:118
>>  print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
>>  __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
>>  kasan_report+0x12/0x20 mm/kasan/common.c:641
>>  __asan_report_store1_noabort+0x17/0x20 mm/kasan/generic_report.c:137
>>  decode_data.part.0+0x23b/0x270 drivers/net/hamradio/6pack.c:843
>>  decode_data drivers/net/hamradio/6pack.c:965 [inline]
>>  sixpack_decode drivers/net/hamradio/6pack.c:968 [inline]
>> 
>> Reported-and-tested-by: syzbot+fc8cd9a673d4577fb2e4@syzkaller.appspotmail.com
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
>> ---
>>  drivers/net/hamradio/6pack.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>> 
>> diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
>> index fcf3af76b6d7..f4ffc2a80ab7 100644
>> --- a/drivers/net/hamradio/6pack.c
>> +++ b/drivers/net/hamradio/6pack.c
>> @@ -827,6 +827,12 @@ static void decode_data(struct sixpack *sp, unsigned char inbyte)
>>  		return;
>>  	}
>>  
>> +	if (sp->rx_count_cooked + 3 >= sizeof(sp->cooked_buf)) {
> 
> It should be + 2 instead of + 3.
> 
> We write three bytes.  idx, idx + 1, idx + 2.  Otherwise, good fix!
> 

Indeed. Will fix in v2, thank you for pointing it out!


With regards,
Pavel Skripkin

  reply	other threads:[~2021-08-13 15:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 11:28 Pavel Skripkin
2021-08-13 14:58 ` Dan Carpenter
2021-08-13 15:09   ` Pavel Skripkin [this message]
2021-08-13 15:14   ` [PATCH v2] " Pavel Skripkin
2021-08-13 21:09     ` Dan Carpenter
2021-08-13 21:32       ` Pavel Skripkin
2021-08-16 10:10     ` patchwork-bot+netdevbpf
2021-08-14  0:23   ` [PATCH] " Kevin Dawson
2021-08-14 14:17     ` Pavel Skripkin
2021-08-16  7:13       ` 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=0c5bc329-6555-edb1-82ad-038cae6b0299@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=ajk@comnets.uni-bremen.de \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-hams@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+fc8cd9a673d4577fb2e4@syzkaller.appspotmail.com \
    --subject='Re: [PATCH] net: 6pack: fix slab-out-of-bounds in decode_data' \
    /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

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).