linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "wubo (T)" <wubo40@huawei.com>
To: Lee Duncan <LDuncan@suse.com>,
	"cleech@redhat.com" <cleech@redhat.com>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"open-iscsi@googlegroups.com" <open-iscsi@googlegroups.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Mingfangsen <mingfangsen@huawei.com>,
	"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>
Subject: 答复: [PATCH] scsi: avoid potential deadloop in iscsi_if_rx func
Date: Tue, 29 Oct 2019 08:07:49 +0000	[thread overview]
Message-ID: <EDBAAA0BBBA2AC4E9C8B6B81DEEE1D6915DF66B3@dggeml505-mbs.china.huawei.com> (raw)
In-Reply-To: <92b221da-18a8-8b7b-0436-ca59088fd45b@suse.com>

On 2019/10/29 2:04, Lee Duncan wrote:
> On 10/26/19 1:55 AM, wubo (T) wrote:
>> From: Bo Wu <wubo40@huawei.com>
>>
>> In iscsi_if_rx func, after receiving one request through 
>> iscsi_if_recv_msg func,iscsi_if_send_reply will be called to try to 
>> reply the request in do-loop. If the return of iscsi_if_send_reply 
>> func fails all the time, one deadloop will occur.
>>
>> Signed-off-by: Bo Wu <wubo40@huawei.com>
>> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> ---
>>  drivers/scsi/scsi_transport_iscsi.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi_transport_iscsi.c 
>> b/drivers/scsi/scsi_transport_iscsi.c
>> index 417b868d8735..f377bfed6b0c 100644
>> --- a/drivers/scsi/scsi_transport_iscsi.c
>> +++ b/drivers/scsi/scsi_transport_iscsi.c
>> @@ -24,6 +24,8 @@
>>  
>>  #define ISCSI_TRANSPORT_VERSION "2.0-870"
>>  
>> +#define ISCSI_SEND_MAX_ALLOWED     10
>> +
>>  #define CREATE_TRACE_POINTS
>>  #include <trace/events/iscsi.h>
>>  
>> @@ -3682,6 +3684,7 @@ iscsi_if_rx(struct sk_buff *skb)
>>  		struct nlmsghdr	*nlh;
>>  		struct iscsi_uevent *ev;
>>  		uint32_t group;
>> +		int retries = ISCSI_SEND_MAX_ALLOWED;
>>  
>>  		nlh = nlmsg_hdr(skb);
>>  		if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) || @@ -3710,8 
>> +3713,11 @@ iscsi_if_rx(struct sk_buff *skb)
>>  				break;
>>  			if (ev->type == ISCSI_UEVENT_GET_CHAP && !err)
>>  				break;
>> +			if (retries <= 0)
>> +				break;
>>  			err = iscsi_if_send_reply(portid, nlh->nlmsg_type,
>>  						  ev, sizeof(*ev));
>> +			retries--;
>>  		} while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
>>  		skb_pull(skb, rlen);
>>  	}
>>
> 
> You could have used "if (--retries < 0)" (or some variation thereof) 
> but that may not be as clear, and certainly is only a nit. So I'm fine 
> with that.
> 

Thanks for your suggestion, I will modify it in v2 patch.

> But I would like to see some sort of error or even debug kernel 
> message if we time out waiting to receive a response. Otherwise, how 
> will some human diagnose this problem?
>

You are right, I will add some sort of error or debug kernel message in the v2 patch.

Thanks,
Bo Wu

      reply	other threads:[~2019-10-29  8:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26  8:55 [PATCH] scsi: avoid potential deadloop in iscsi_if_rx func wubo (T)
2019-10-28 18:04 ` Lee Duncan
2019-10-29  8:07   ` wubo (T) [this message]

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=EDBAAA0BBBA2AC4E9C8B6B81DEEE1D6915DF66B3@dggeml505-mbs.china.huawei.com \
    --to=wubo40@huawei.com \
    --cc=LDuncan@suse.com \
    --cc=cleech@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=mingfangsen@huawei.com \
    --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).