Linux USB
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Chenyuan Yang <chenyuan0y@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: valentina.manea.m@gmail.com, shuah@kernel.org, i@zenithal.me,
	linux-usb@vger.kernel.org, Zijie Zhao <zzjas98@gmail.com>,
	syzkaller@googlegroups.com, linux-media@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [drivers/usb/usbip] BUG: corrupted list in vep_queue
Date: Fri, 11 Oct 2024 11:05:10 -0600	[thread overview]
Message-ID: <73247327-5bc2-4390-a60d-a73e5683f0a6@linuxfoundation.org> (raw)
In-Reply-To: <CALGdzuooWHVS54xOFj7n=MPohy6xMEALet3Q_9EGZ6fRk6Z+_A@mail.gmail.com>

On 10/11/24 10:21, Chenyuan Yang wrote:
> Hi Greg,
> 
> I'm curious about the best approach to fix this issue. I'm unsure if
> adding a spinlock or mutex around the code would be good to ensure
> that only one thread can modify the list at a time (then fix this
> issue).
> 
> Alternatively, we could check if the entry is already in the list
> within the vep_queue function:
> ```
> if (!list_empty(&new_entry->list)) {
>      // Entry is already in the list, handle it (e.g., log an error or ignore)
>      return -EEXIST; // Or another appropriate error code
> }
> 

vep_queue() function is holding udc lock when it updates
the status and calls list_add_tail(). vep_dequeue() does
the same.

vep_free_request() doesn't see to hold the udc lock. I will
tale a look at this a bit more and get back to you on the
best approach. My guess is that the fix will be in another
function such as vep_free_request() - at the moment - that
routine is the one I suspect.


> // Safe to add the entry to the list
> list_add_tail(&new_entry->list, &queue->list);
> ```
> 
> This approach would avoid unnecessary locking overhead if the entry is
> not already in the list.
> 
> Please let me know your thoughts on these options or if you have any
> other suggestions.
> 
> Best,
> Chenyuan
> 

thanks,
-- Shuah


  reply	other threads:[~2024-10-11 17:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  5:13 [drivers/usb/usbip] BUG: corrupted list in vep_queue Chenyuan Yang
2024-10-11  5:21 ` Greg KH
2024-10-11 16:21   ` Chenyuan Yang
2024-10-11 17:05     ` Shuah Khan [this message]
2024-10-11 22:56       ` Shuah Khan

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=73247327-5bc2-4390-a60d-a73e5683f0a6@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=chenyuan0y@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=i@zenithal.me \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=valentina.manea.m@gmail.com \
    --cc=zzjas98@gmail.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