From: "Chris Lu (陸稚泓)" <Chris.Lu@mediatek.com>
To: "luiz.dentz@gmail.com" <luiz.dentz@gmail.com>
Cc: "marcel@holtmann.org" <marcel@holtmann.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>,
"johan.hedberg@gmail.com" <johan.hedberg@gmail.com>,
"Steve Lee (李視誠)" <steve.lee@mediatek.com>,
"Sean Wang" <Sean.Wang@mediatek.com>,
"Aaron Hou (侯俊仰)" <Aaron.Hou@mediatek.com>
Subject: Re: [PATCH v4] Bluetooth: btmtk: Fix null pointer when processing coredump
Date: Thu, 13 Jul 2023 06:10:58 +0000 [thread overview]
Message-ID: <97c0ef9580415d56086230761c5d10d392f58add.camel@mediatek.com> (raw)
In-Reply-To: <CABBYNZLoJtUpAR-yKpq9a1NCTjhdgWMNSdwGd7f9jtFR0LuEAA@mail.gmail.com>
On Wed, 2023-07-12 at 13:29 -0700, Luiz Augusto von Dentz wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Hi Chris,
>
> On Wed, Jul 12, 2023 at 6:03 AM Chris Lu <chris.lu@mediatek.com>
> wrote:
> >
> > There may be a potential null pointer risk if offset value is
> > less than 0 when doing memcmp in btmtk_process_coredump().
> > Check offset is valid before doing memcmp.
> >
> > Signed-off-by: Chris Lu <chris.lu@mediatek.com>
> > Co-developed-by: Sean Wang <sean.wang@mediatek.com>
> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>
>
> You should probably include the Fixes tag of the patch that
> introduced
> the problem.
>
Hi Luiz,
Thanks for reminding, I'll update Bug ad fixs info in commit message
and send the v5 patch.
BRs,
Chris
> > ---
> > v2: fix typo
> > v3: fix bot checking error
> > v4: reduce variable 'offset' declaration in v3
> > ---
> > drivers/bluetooth/btmtk.c | 12 ++++++------
> > drivers/bluetooth/btmtk.h | 1 +
> > 2 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> > index 786f775196ae..9cc789272ab7 100644
> > --- a/drivers/bluetooth/btmtk.c
> > +++ b/drivers/bluetooth/btmtk.c
> > @@ -395,12 +395,12 @@ int btmtk_process_coredump(struct hci_dev
> *hdev, struct sk_buff *skb)
> >
> > /* Mediatek coredump data would be more than
> MTK_COREDUMP_NUM */
> > if (data->cd_info.cnt > MTK_COREDUMP_NUM &&
> > - skb->len > sizeof(MTK_COREDUMP_END) &&
> > - !memcmp((char *)&skb->data[skb->len -
> sizeof(MTK_COREDUMP_END)],
> > - MTK_COREDUMP_END,
> sizeof(MTK_COREDUMP_END) - 1)) {
> > - bt_dev_info(hdev, "Mediatek coredump end");
> > - hci_devcd_complete(hdev);
> > - }
> > + skb->len > MTK_COREDUMP_END_LEN)
> > + if (!memcmp((char *)&skb->data[skb->len -
> MTK_COREDUMP_END_LEN],
> > + MTK_COREDUMP_END, MTK_COREDUMP_END_LEN
> - 1)) {
> > + bt_dev_info(hdev, "Mediatek
> coredump end");
> > + hci_devcd_complete(hdev);
> > + }
> >
> > break;
> > }
> > diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
> > index 68309dfe076a..56f5502baadf 100644
> > --- a/drivers/bluetooth/btmtk.h
> > +++ b/drivers/bluetooth/btmtk.h
> > @@ -24,6 +24,7 @@
> >
> > #define MTK_COREDUMP_SIZE (1024 * 1000)
> > #define MTK_COREDUMP_END "coredump end"
> > +#define MTK_COREDUMP_END_LEN (sizeof(MTK_COREDUMP_END))
> > #define MTK_COREDUMP_NUM 255
> >
> > enum {
> > --
> > 2.18.0
> >
>
>
> --
> Luiz Augusto von Dentz
prev parent reply other threads:[~2023-07-13 6:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 13:02 Chris Lu
2023-07-12 20:29 ` Luiz Augusto von Dentz
2023-07-13 6:10 ` Chris Lu (陸稚泓) [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=97c0ef9580415d56086230761c5d10d392f58add.camel@mediatek.com \
--to=chris.lu@mediatek.com \
--cc=Aaron.Hou@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=steve.lee@mediatek.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
all inboxes | Powered by JetHome®