From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Kang Yin Su <cantona@cantona.net>
Cc: Alexander Shiyan <shc_work@mail.ru>, Jiri Slaby <jslaby@suse.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] serial: max310x: Fix out of bounds access
Date: Wed, 12 Aug 2015 08:17:07 -0700 [thread overview]
Message-ID: <20150812151707.GB12397@kroah.com> (raw)
In-Reply-To: <CABJLtPG7gfR8VSVfzRgF8XgON7F-mhfMu7C2an0sfQYLBNiLpg@mail.gmail.com>
On Wed, Aug 12, 2015 at 07:50:25PM +0800, Kang Yin Su wrote:
> On 12 August 2015 at 17:46, Alexander Shiyan <shc_work@mail.ru> wrote:
> >> Среда, 12 августа 2015, 15:36 +08:00 от cantona <cantona@cantona.net>:
> >>
> >>
> >> added Alexander Shiyan < shc_work@mail.ru >.
> >>
> >> On 12 August 2015 at 15:22, Su Kang Yin < cantona@cantona.net > wrote:
> >> >Max310x driver supports up to 4 UART devices but array size of
> >> >"struct max310x_one" is set to 1. That leads to out of bounds
> >> >access on UART port registration.
> >> >
> >> >This patch fixed it by increase the array size to 4 which is
> >> >maximum supported UART.
> >> >
> >> >Signed-off-by: Su Kang Yin < cantona@cantona.net >
> >> >---
> > ...
> >
> > This seems incorrect. The number of ports is allocated dynamically by:
> > ...
> > /* Alloc port structure */
> > s = devm_kzalloc(dev, sizeof(*s) + sizeof(struct max310x_one) * devtype->nr, GFP_KERNEL);
> > ...
> >
> > Thanks.
> >
> > ---
> >
>
>
> Oh, my bad. But it looks confusing. So we must ensure "struct
> max310x_one p[0]" must the last element of "struct max310x_port".
Yes, that is a very common pattern we use in the kernel.
prev parent reply other threads:[~2015-08-12 15:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-12 7:22 [PATCH v2] serial: max310x: Fix out of bounds access Su Kang Yin
[not found] ` <CABJLtPHPCw7VN+wG4ApDxB-ZM7wRz_1xHfpNLL4o4_80JYyKaQ@mail.gmail.com>
2015-08-12 9:46 ` Alexander Shiyan
2015-08-12 11:50 ` Kang Yin Su
2015-08-12 15:17 ` Greg Kroah-Hartman [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=20150812151707.GB12397@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=cantona@cantona.net \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=shc_work@mail.ru \
/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