From: Paolo Abeni <pabeni@redhat.com>
To: Ryosuke Yasuoka <ryasuoka@redhat.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
syoshida@redhat.com,
syzbot+7ea9413ea6749baf5574@syzkaller.appspotmail.com
Subject: Re: [PATCH net] nfc: nci: Fix uninit-value in nci_dev_up
Date: Thu, 14 Mar 2024 12:58:14 +0100 [thread overview]
Message-ID: <498dc99d25965877f7d15592dcbb340f97d803b4.camel@redhat.com> (raw)
In-Reply-To: <ZfLKjD6aMrGPEgHh@zeus>
On Thu, 2024-03-14 at 18:59 +0900, Ryosuke Yasuoka wrote:
> On Wed, Mar 13, 2024 at 10:01:27AM +0100, Krzysztof Kozlowski wrote:
> > On 12/03/2024 15:56, Ryosuke Yasuoka wrote:
> >
> > > CPU: 1 PID: 5012 Comm: syz-executor935 Not tainted 6.7.0-syzkaller-00562-g9f8413c4a66f #0
> > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
> >
> > These two lines are not really relevant, it's a virtual platform, so
> > whether this is Google or Amazon it does not matter, and your log paste
> > is already quite long. If there is going to be any resend, I propose to
> > drop.
>
> OK. Do you mean all these log messages that syzbot reported should be
> dropped or I should leave only relavant messages?
It's not a big deal either way, but there is a quite established
practice of including the whole splat.
> > > Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation")
> > > Reported-and-tested-by: syzbot+7ea9413ea6749baf5574@syzkaller.appspotmail.com
> > > Closes: https://syzkaller.appspot.com/bug?extid=7ea9413ea6749baf5574 [1]
> > > Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> > > ---
> > > net/nfc/nci/ntf.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> > >
> > > diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
> > > index 994a0a1efb58..56624387e253 100644
> > > --- a/net/nfc/nci/ntf.c
> > > +++ b/net/nfc/nci/ntf.c
> > > @@ -765,6 +765,9 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
> > > nci_opcode_oid(ntf_opcode),
> > > nci_plen(skb->data));
> > >
> > > + if (!nci_plen(skb->data))
> > > + goto end;
> >
> > Looks reasonable, however wouldn't there be the same issue in
> > nci_rsp_packet() and other cases from nci_rx_work()? I wonder why only
> > NTF packets could be constructed without payload.
>
> Yes, I can reproduced very similar bug reported by syzbot [2] in my lab.
> When the MT is NCI_MT_RSP_PKT (0x2), KMSAN detects the following bug in
> nci_rsp_packet().
[...]
> So it means we should check the payload length in not >
nci_ntf_packet()
> but in nci_rx_work(). Like this. (Note that it has not tested.)
>
> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
> index 6c9592d05120..f9880d6ad2b2 100644
> --- a/net/nfc/nci/core.c
> +++ b/net/nfc/nci/core.c
> @@ -1512,6 +1512,11 @@ static void nci_rx_work(struct work_struct *work)
> nfc_send_to_raw_sock(ndev->nfc_dev, skb,
> RAW_PAYLOAD_NCI, NFC_DIRECTION_RX);
>
> + if (!nci_plen(skb->data)) {
> + skb(free);
> + break;
> + }
> +
> /* Process frame */
> switch (nci_mt(skb->data)) {
> case NCI_MT_RSP_PKT:
>
> Let me know if you have any idea.
>
> https://syzkaller.appspot.com/bug?extid=7ea9413ea6749baf5574 [1]
> https://syzkaller.appspot.com/bug?extid=685805de744584f4d24b [2]
I think addressing the issue early in the code path would be better -
unless there is some functional issue with that I can't foresee.
Thanks,
Paolo
next prev parent reply other threads:[~2024-03-14 11:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 14:56 [PATCH net] nfc: nci: Fix uninit-value in nci_dev_up Ryosuke Yasuoka
2024-03-13 9:01 ` Krzysztof Kozlowski
2024-03-14 9:59 ` Ryosuke Yasuoka
2024-03-14 11:58 ` Paolo Abeni [this message]
2024-03-25 19:19 ` Krzysztof Kozlowski
[not found] <ZfBmZmSHjcXgqVly@zeus>
2024-03-12 14:27 ` syzbot
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=498dc99d25965877f7d15592dcbb340f97d803b4.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ryasuoka@redhat.com \
--cc=syoshida@redhat.com \
--cc=syzbot+7ea9413ea6749baf5574@syzkaller.appspotmail.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 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.