From: Kanishka De Silva <kpskanna1915@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kanishka De Silva <kpskanna1915@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] usb: adutux: fix unlocked read_buffer_length write in adu_open()
Date: Mon, 13 Jul 2026 11:07:37 +0530 [thread overview]
Message-ID: <20260713053737.912-1-kpskanna1915@gmail.com> (raw)
In-Reply-To: <2026071358-illusion-basics-1146@gregkh>
adu_open() clears dev->read_buffer_length while holding only
adutux_mutex, but every other path that touches this field
(adu_interrupt_in_callback() and adu_read()) correctly holds
dev->buflock, per the locking scheme documented at the top of
this file. This is a data race: an IRQ callback incrementing
read_buffer_length concurrently with adu_open() clearing it can
have its update silently lost, corrupting buffer state.
Take buflock around the reset to bring adu_open() in line with
the documented locking contract.
Cc: stable@vger.kernel.org
Signed-off-by: Kanishka De Silva <kpskanna1915@gmail.com>
---
drivers/usb/misc/adutux.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 369d0d2..606ef91 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -228,6 +228,7 @@ static int adu_open(struct inode *inode, struct file *file)
{
struct adu_device *dev = NULL;
struct usb_interface *interface;
+ unsigned long flags;
int subminor;
int retval;
@@ -265,7 +266,9 @@ static int adu_open(struct inode *inode, struct file *file)
file->private_data = dev;
/* initialize in direction */
+ spin_lock_irqsave(&dev->buflock, flags);
dev->read_buffer_length = 0;
+ spin_unlock_irqrestore(&dev->buflock, flags);
/* fixup first read by having urb waiting for it */
usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
--
2.43.0
next prev parent reply other threads:[~2026-07-13 5:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 4:45 [PATCH RFC] usb: adutux: fix unlocked read_buffer_length write in adu_open() (data race) Kanishka De Silva
2026-07-13 5:15 ` Greg KH
2026-07-13 5:37 ` Kanishka De Silva [this message]
2026-07-13 7:25 ` Oliver Neukum
2026-07-13 7:56 ` [PATCH v2] usb: adutux: take buflock when resetting read_buffer_length in adu_open() Kanishka De Silva
2026-07-13 12:03 ` Greg KH
2026-07-13 13:48 ` Alan Stern
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=20260713053737.912-1-kpskanna1915@gmail.com \
--to=kpskanna1915@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.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
all inboxes | Powered by JetHome®