From: Stefan Schmidt <stefan@datenfreihafen.org>
To: Alexander Aring <aahringo@redhat.com>
Cc: Haimin Zhang <tcs.kernel@gmail.com>,
Alexander Aring <alex.aring@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-wpan - ML <linux-wpan@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Haimin Zhang <tcs_kernel@tencent.com>
Subject: Re: [PATCH] net/ieee802154: fix uninit value bug in dgram_sendmsg
Date: Mon, 29 Aug 2022 11:08:42 +0200 [thread overview]
Message-ID: <85f66a3a-95fa-5aaa-def0-998bf3f5139f@datenfreihafen.org> (raw)
In-Reply-To: <CAK-6q+hf27dY9d-FyAh2GtA_zG5J4kkHEX2Qj38Rac_PH63bQg@mail.gmail.com>
Hello Alex.
On 23.08.22 14:22, Alexander Aring wrote:
> Hi,
>
> On Tue, Aug 23, 2022 at 5:42 AM Stefan Schmidt
> <stefan@datenfreihafen.org> wrote:
>>
>> Hello.
>>
>> On 22.08.22 09:19, Haimin Zhang wrote:
>>> There is uninit value bug in dgram_sendmsg function in
>>> net/ieee802154/socket.c when the length of valid data pointed by the
>>> msg->msg_name isn't verified.
>>>
>>> This length is specified by msg->msg_namelen. Function
>>> ieee802154_addr_from_sa is called by dgram_sendmsg, which use
>>> msg->msg_name as struct sockaddr_ieee802154* and read it, that will
>>> eventually lead to uninit value read. So we should check the length of
>>> msg->msg_name is not less than sizeof(struct sockaddr_ieee802154)
>>> before entering the ieee802154_addr_from_sa.
>>>
>>> Signed-off-by: Haimin Zhang <tcs_kernel@tencent.com>
>>
>>
>> This patch has been applied to the wpan tree and will be
>> part of the next pull request to net. Thanks!
>
> For me this patch is buggy or at least it is questionable how to deal
> with the size of ieee802154_addr_sa here.
You are right. I completely missed this. Thanks for spotting!
> There should be a helper to calculate the size which depends on the
> addr_type field. It is not required to send the last 6 bytes if
> addr_type is IEEE802154_ADDR_SHORT.
> Nitpick is that we should check in the beginning of that function.
Haimin, in ieee802154 we could have two different sizes for
ieee802154_addr_sa depending on the addr_type. We have short and
extended addresses.
Could you please rework this patch to take this into account as Alex
suggested?
I reverted your original patch from my tree.
regards
Stefan Schmidt
next prev parent reply other threads:[~2022-08-29 9:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 7:19 Haimin Zhang
2022-08-23 8:40 ` Stefan Schmidt
2022-08-23 12:22 ` Alexander Aring
[not found] ` <CAB2z9exhnzte0rpT9t6=VpFCm9x+zZdmr01UHFxqvYy8y9ifag@mail.gmail.com>
2022-08-24 12:38 ` Alexander Aring
2022-08-29 9:08 ` Stefan Schmidt [this message]
2022-08-30 7:04 ` zhang haiming
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=85f66a3a-95fa-5aaa-def0-998bf3f5139f@datenfreihafen.org \
--to=stefan@datenfreihafen.org \
--cc=aahringo@redhat.com \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tcs.kernel@gmail.com \
--cc=tcs_kernel@tencent.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®