netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: michael.christie@oracle.com
To: Chris Leech <cleech@redhat.com>, Lee Duncan <lduncan@suse.com>,
	linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH 11/11] iscsi: force destroy sesions when a network namespace exits
Date: Wed, 10 May 2023 13:14:57 -0700	[thread overview]
Message-ID: <2059dc74-a00b-fd53-f5ce-3dd41bfbf4f1@oracle.com> (raw)
In-Reply-To: <6ea35c03-09b9-425d-ddcd-8cdbf99f4fe8@oracle.com>

On 5/10/23 1:09 PM, michael.christie@oracle.com wrote:
> On 5/6/23 4:29 PM, Chris Leech wrote:
>> The namespace is gone, so there is no userspace to clean up.
>> Force close all the sessions.
>>
>> This should be enough for software transports, there's no implementation
>> of migrating physical iSCSI hosts between network namespaces currently.
>>
>> Reviewed-by: Hannes Reinecke <hare@suse.de>
>> Signed-off-by: Chris Leech <cleech@redhat.com>
>> ---
>>  drivers/scsi/scsi_transport_iscsi.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
>> index 15d28186996d..10e9414844d8 100644
>> --- a/drivers/scsi/scsi_transport_iscsi.c
>> +++ b/drivers/scsi/scsi_transport_iscsi.c
>> @@ -5235,9 +5235,25 @@ static int __net_init iscsi_net_init(struct net *net)
>>  
>>  static void __net_exit iscsi_net_exit(struct net *net)
>>  {
>> +	struct iscsi_cls_session *session, *tmp;
>>  	struct iscsi_net *isn;
>> +	unsigned long flags;
>> +	LIST_HEAD(sessions);
>>  
>>  	isn = net_generic(net, iscsi_net_id);
>> +
>> +	spin_lock_irqsave(&isn->sesslock, flags);
>> +	list_replace_init(&isn->sesslist, &sessions);
>> +	spin_unlock_irqrestore(&isn->sesslock, flags);
>> +
>> +	/* force session destruction, there is no userspace anymore */
>> +	list_for_each_entry_safe(session, tmp, &sessions, sess_list) {
>> +		device_for_each_child(&session->dev, NULL,
>> +				      iscsi_iter_force_destroy_conn_fn);
>> +		flush_work(&session->destroy_work);
> 
> I think if this flush_work actually flushed, then we would be doing a use
> after free because the running work would free the session from under us.
> 
> We should never have a running destroy_work and be ale to see it on the sesslist
> right? Maybe a WARN_ON or something else so it doesn't look like a possible
> bug.

Maybe not a WARN_ON. What happens if there is running destroy_works for this
namespace and we return from this function?

> 
> 
>> +		__iscsi_destroy_session(&session->destroy_work);
>> +	}
>> +
>>  	netlink_kernel_release(isn->nls);
>>  	isn->nls = NULL;
>>  }
> 


  reply	other threads:[~2023-05-10 20:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06 23:29 [PATCH v2 00/11] Make iscsid-kernel communications namespace-aware Chris Leech
2023-05-06 23:29 ` [PATCH 01/11] iscsi: create per-net iscsi netlink kernel sockets Chris Leech
2023-05-06 23:29 ` [PATCH 02/11] iscsi: associate endpoints with a host Chris Leech
2023-05-06 23:29 ` [PATCH 03/11] iscsi: sysfs filtering by network namespace Chris Leech
2023-05-10 19:50   ` michael.christie
2023-05-06 23:29 ` [PATCH 04/11] iscsi: make all iSCSI netlink multicast namespace aware Chris Leech
2023-05-10 19:48   ` michael.christie
2023-05-06 23:29 ` [PATCH 05/11] iscsi: check net namespace for all iscsi lookup Chris Leech
2023-05-12 22:30   ` Mike Christie
2023-05-06 23:29 ` [PATCH 06/11] iscsi: set netns for tcp and iser hosts Chris Leech
2023-05-07  1:29   ` kernel test robot
2023-05-07  2:01   ` kernel test robot
2023-05-10 19:40   ` michael.christie
2023-05-06 23:29 ` [PATCH 07/11] iscsi: convert flashnode devices from bus to class Chris Leech
2023-05-10 19:28   ` michael.christie
2023-05-06 23:29 ` [PATCH 08/11] iscsi: rename iscsi_bus_flash_* to iscsi_flash_* Chris Leech
2023-05-06 23:29 ` [PATCH 09/11] iscsi: filter flashnode sysfs by net namespace Chris Leech
2023-05-06 23:29 ` [PATCH 10/11] iscsi: make session and connection lists per-net Chris Leech
2023-05-10 19:25   ` michael.christie
2023-05-06 23:29 ` [PATCH 11/11] iscsi: force destroy sesions when a network namespace exits Chris Leech
2023-05-10 20:09   ` michael.christie
2023-05-10 20:14     ` michael.christie [this message]
2023-05-10 19:54 ` [PATCH v2 00/11] Make iscsid-kernel communications namespace-aware michael.christie
  -- strict thread matches above, loose matches on Subject: below --
2023-03-14 16:27 [RFC PATCH 4/9] iscsi: make all iSCSI netlink multicast namespace aware Hannes Reinecke
2023-04-10 19:10 ` [PATCH 11/11] iscsi: force destroy sesions when a network namespace exits Chris Leech
2023-04-11  6:21   ` Hannes Reinecke
2023-04-11 18:19     ` Chris Leech
2023-04-12  6:02       ` Hannes Reinecke

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=2059dc74-a00b-fd53-f5ce-3dd41bfbf4f1@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=cleech@redhat.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=open-iscsi@googlegroups.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;
as well as URLs for NNTP newsgroup(s).