lkml.org 
[lkml]   [2019]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject答复: [PATCH] scsi: avoid potential deadloo p in iscsi if rx func
Date
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
\
 
 \ /
  Last update: 2019-10-29 09:09    [W:0.038 / U:2.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site