From: Bart Van Assche <bvanassche@acm.org>
To: Kyungtae Kim <kt0755@gmail.com>, Jens Axboe <axboe@kernel.dk>
Cc: jikos@kernel.org, Byoungyoung Lee <lifeasageek@gmail.com>,
DaeRyong Jeong <threeearcat@gmail.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] floppy: Avoid memory access beyond the array bounds in setup_rw_floppy()
Date: Fri, 26 Oct 2018 08:21:19 -0700 [thread overview]
Message-ID: <1540567279.66186.99.camel@acm.org> (raw)
In-Reply-To: <CAEAjamtxZRiFUYb4re3jRf9naoSyJO7sskChfEgcBh-m-uEKWQ@mail.gmail.com>
On Fri, 2018-10-26 at 10:39 -0400, Kyungtae Kim wrote:
> setup_rw_floppy() writes some bytes of array cmd to the floppy disk
> controller, depending on cmd_count.
> Although the size of array cmd is fixed like 16, cmd_count can be much
> larger through raw_cmd_ioctl().
> Noticed there is no bound check for this, thereby leading to invalid
> memory access.
Against which kernel tree did you prepare this patch? Just above the code
you want to insert I found the following:
if (ptr->cmd_count > 33) ...
Why does that statement compare cmd_count with 33? Is that comparison correct
or not? Anyway, I don't think it makes sense first to compare cmd_count against
33 and next to compare it against 16 ...
> + if (ptr->cmd_count > ARRAY_SIZE(ptr->cmd))
> + return -EINVAL;
This comparison looks suspicious to me. Almost every comparison of the type
"... > ARRAY_SIZE()" I have seen so far was wrong and should be changed into
"... >= ARRAY_SIZE()" instead.
Bart.
next prev parent reply other threads:[~2018-10-26 15:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 14:39 [PATCH] floppy: Avoid memory access beyond the array bounds in setup_rw_floppy() Kyungtae Kim
2018-10-26 14:41 ` Jens Axboe
2018-10-26 14:51 ` Kyungtae Kim
2018-10-26 14:57 ` Jens Axboe
2018-10-26 15:06 ` Kyungtae Kim
2018-10-26 15:21 ` Bart Van Assche [this message]
2018-10-26 15:49 ` Kyungtae Kim
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=1540567279.66186.99.camel@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=jikos@kernel.org \
--cc=kt0755@gmail.com \
--cc=lifeasageek@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=threeearcat@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