From: Kees Cook <keescook@chromium.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Tejun Heo <tj@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
Jeffrin Thalakkottoor <jeffrin@rajagiritech.edu.in>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
tobin@kernel.org, Dmitry Vyukov <dvyukov@google.com>,
Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH] libata: zpodd: Fix small read overflow in zpodd_get_mech_type()
Date: Mon, 22 Jul 2019 11:18:12 -0700 [thread overview]
Message-ID: <201907221117.254D219F9E@keescook> (raw)
In-Reply-To: <CAKwvOdkkqhwHz_yLN5VjAdENj3qtwdJ080QKpQ9vr--F1xQPhA@mail.gmail.com>
On Mon, Jul 22, 2019 at 10:40:40AM -0700, Nick Desaulniers wrote:
> On Fri, Jul 19, 2019 at 8:41 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in
> > eject_tray()"), this fixes a cdb[] buffer length, this time in
> > zpodd_get_mech_type():
> >
> > We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be
> > ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.
> >
> > The KASAN report was:
> >
> > BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
> > Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
> > ...
> > The buggy address belongs to the variable:
> > cdb.48319+0x0/0x40
> >
> > Reported-by: Jeffrin Thalakkottoor <jeffrin@rajagiritech.edu.in>
> > Fixes: afe759511808c ("libata: identify and init ZPODD devices")
> > Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Interesting, both initializer lists are less than ATAPI_CDB_LEN (16)
> elements, yet ata_exec_internal_sg() in drivers/ata/libata-core.c very
> clearly has a ATAPI_CDB_LEN byte memcpy on that element. Probably
> both initializer lists should just lead off the trailing zero's or
> provide the entire 16 elements. For now, thank you for the patch.
Yup, with the specific size added it'll be zero-padded.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Thanks!
-Kees
>
> > ---
> > drivers/ata/libata-zpodd.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c
> > index 173e6f2dd9af..eefda51f97d3 100644
> > --- a/drivers/ata/libata-zpodd.c
> > +++ b/drivers/ata/libata-zpodd.c
> > @@ -56,7 +56,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
> > unsigned int ret;
> > struct rm_feature_desc *desc;
> > struct ata_taskfile tf;
> > - static const char cdb[] = { GPCMD_GET_CONFIGURATION,
> > + static const char cdb[ATAPI_CDB_LEN] = { GPCMD_GET_CONFIGURATION,
> > 2, /* only 1 feature descriptor requested */
> > 0, 3, /* 3, removable medium feature */
> > 0, 0, 0,/* reserved */
> > --
> > 2.17.1
> >
> >
> > --
> > Kees Cook
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
--
Kees Cook
prev parent reply other threads:[~2019-07-22 18:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-20 3:41 [PATCH] libata: zpodd: Fix small read overflow in zpodd_get_mech_type() Kees Cook
2019-07-22 17:40 ` Nick Desaulniers
2019-07-22 18:18 ` Kees Cook [this message]
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=201907221117.254D219F9E@keescook \
--to=keescook@chromium.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dan.carpenter@oracle.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=jeffrin@rajagiritech.edu.in \
--cc=linux-kernel@vger.kernel.org \
--cc=ndesaulniers@google.com \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=tobin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.