All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vu Pham <vuhuong-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Bart Van Assche <bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Linux RDMA list <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [ofa-general][PATCH 4/4] SRP fail-over faster
Date: Wed, 14 Oct 2009 14:11:52 -0700	[thread overview]
Message-ID: <4AD63E98.6090309@mellanox.com> (raw)
In-Reply-To: <e2e108260910130409q78e3edbcndd64b7cf419705b9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Bart Van Assche wrote:
>
>> +
>> +       switch (event->event) {
>> +       case IB_EVENT_PORT_ERR:
>> +               list_for_each_entry_safe(host, tmp_host,
>> +                                        &srp_dev->dev_list, list) {
>> +                       if (event->element.port_num == host->port) {
>> +                               spin_lock(&host->target_lock);
>>     
>
> Can srp_remove_work() be executed concurrently with
> srp_event_handler() ? In that case the above code isn't safe and the
> spin_lock(&host->target_lock) should be moved to just before
> list_for_each_entry_safe(). The current implementation can trigger
> reading deallocated memory.
>
>   
>> +                               list_for_each_entry_safe(target, tmp_target,
>> +                                                        &host->target_list, list) {
>> +                                       unsigned long flags;
>> +
>> +                                       spin_lock_irqsave(target->scsi_host->host_lock,
>> +                                                         flags);
>> +                                       if (!target->qp_in_error &&
>> +                                           target->state == SRP_TARGET_LIVE)
>> +                                               srp_qp_err_add_timer(target,
>> +                                                                    srp_dev_loss_tmo);
>> +                                       spin_unlock_irqrestore(target->scsi_host->host_lock,
>> +                                                              flags);
>> +                               }
>> +                               spin_unlock(&host->target_lock);
>> +                       }
>> +               }
>> +               break;
>> +       case IB_EVENT_PORT_ACTIVE:
>> +       case IB_EVENT_LID_CHANGE:
>> +       case IB_EVENT_PKEY_CHANGE:
>> +       case IB_EVENT_SM_CHANGE:
>> +               list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list,
>> +                                        list) {
>> +                       if (event->element.port_num == host->port) {
>> +                               spin_lock(&host->target_lock);
>>     
>
> A remark similar to the above: this code isn't safe against concurrent
> calls of srp_remove_one().
>
>   
I did not pay attention to the races created by unloading module (same 
for patch 3/4). I'll rework patches and address these races.

thanks,
-vu
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2009-10-14 21:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12 22:57 [ofa-general][PATCH 4/4] SRP fail-over faster Vu Pham
     [not found] ` <4AD3B466.8060908-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2009-10-13 11:09   ` Bart Van Assche
     [not found]     ` <e2e108260910130409q78e3edbcndd64b7cf419705b9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-10-14 21:11       ` Vu Pham [this message]
2009-10-22 23:17       ` Vu Pham

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=4AD63E98.6090309@mellanox.com \
    --to=vuhuong-vpraknaxozvwk0htik3j/w@public.gmane.org \
    --cc=bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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.