From: Pavel Skripkin <paskripkin@gmail.com>
To: stefan@datenfreihafen.org, alex.aring@gmail.com,
davem@davemloft.net, kuba@kernel.org
Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Pavel Skripkin <paskripkin@gmail.com>,
Alexander Potapenko <glider@google.com>
Subject: [PATCH v2] ieee802154: atusb: fix uninit value in atusb_set_extended_addr
Date: Mon, 3 Jan 2022 15:09:25 +0300 [thread overview]
Message-ID: <20220103120925.25207-1-paskripkin@gmail.com> (raw)
In-Reply-To: <CAB_54W50xKFCWZ5vYuDG2p4ijpd63cSutRrV4MLs9oasLmKgzQ@mail.gmail.com>
Alexander reported a use of uninitialized value in
atusb_set_extended_addr(), that is caused by reading 0 bytes via
usb_control_msg().
Fix it by validating if the number of bytes transferred is actually
correct, since usb_control_msg() may read less bytes, than was requested
by caller.
Fail log:
BUG: KASAN: uninit-cmp in ieee802154_is_valid_extended_unicast_addr include/linux/ieee802154.h:310 [inline]
BUG: KASAN: uninit-cmp in atusb_set_extended_addr drivers/net/ieee802154/atusb.c:1000 [inline]
BUG: KASAN: uninit-cmp in atusb_probe.cold+0x29f/0x14db drivers/net/ieee802154/atusb.c:1056
Uninit value used in comparison: 311daa649a2003bd stack handle: 000000009a2003bd
ieee802154_is_valid_extended_unicast_addr include/linux/ieee802154.h:310 [inline]
atusb_set_extended_addr drivers/net/ieee802154/atusb.c:1000 [inline]
atusb_probe.cold+0x29f/0x14db drivers/net/ieee802154/atusb.c:1056
usb_probe_interface+0x314/0x7f0 drivers/usb/core/driver.c:396
Fixes: 7490b008d123 ("ieee802154: add support for atusb transceiver")
Reported-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
Changes in v2:
- Reworked fix approach, since moving to new USB API is not
suitable for backporting to stable kernels
---
drivers/net/ieee802154/atusb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 23ee0b14cbfa..e6cc816dd7a1 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -93,7 +93,9 @@ static int atusb_control_msg(struct atusb *atusb, unsigned int pipe,
ret = usb_control_msg(usb_dev, pipe, request, requesttype,
value, index, data, size, timeout);
- if (ret < 0) {
+ if (ret < size) {
+ ret = ret < 0 ? ret : -ENODATA;
+
atusb->err = ret;
dev_err(&usb_dev->dev,
"%s: req 0x%02x val 0x%x idx 0x%x, error %d\n",
--
2.34.1
next prev parent reply other threads:[~2022-01-03 12:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG_fn=VDEoQx5c7XzWX1yaYBd5y5FrG1aagrkv+SZ03c8TfQYQ@mail.gmail.com>
2022-01-02 17:19 ` [PATCH RFT] ieee802154: atusb: move to new USB API Pavel Skripkin
2022-01-02 22:15 ` Alexander Aring
2022-01-02 22:21 ` Pavel Skripkin
2022-01-02 22:36 ` Alexander Aring
2022-01-03 12:09 ` Pavel Skripkin [this message]
2022-01-03 15:27 ` [PATCH v2] ieee802154: atusb: fix uninit value in atusb_set_extended_addr Alexander Aring
2022-01-04 15:40 ` Stefan Schmidt
2022-01-04 17:27 ` Pavel Skripkin
2022-01-04 18:04 ` Stefan Schmidt
2022-01-04 18:11 ` Pavel Skripkin
2022-01-04 18:28 ` [PATCH v3] " Pavel Skripkin
2022-01-04 18:57 ` Alexander Aring
2022-01-04 19:25 ` Stefan Schmidt
2022-01-03 13:04 ` [PATCH RFT] ieee802154: atusb: move to new USB API Greg KH
2022-01-03 13:03 ` Greg KH
2022-01-03 15:35 ` Alexander Aring
2022-01-04 19:41 ` Stefan Schmidt
2022-01-05 8:08 ` Greg KH
2022-01-05 9:01 ` Stefan Schmidt
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=20220103120925.25207-1-paskripkin@gmail.com \
--to=paskripkin@gmail.com \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=glider@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stefan@datenfreihafen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).