From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Jia-Ju Bai <baijiaju1990@163.com>
Cc: bart.vanassche@sandisk.com, davem@davemloft.net, hare@suse.com,
elfring@users.sourceforge.net, linux-scsi@vger.kernel.org,
target-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iscsi: Fix a sleep-in-atomic bug
Date: Thu, 01 Jun 2017 20:20:03 -0700 [thread overview]
Message-ID: <1496373603.27407.211.camel@haakon3.risingtidesystems.com> (raw)
In-Reply-To: <5930BBC1.9070608@163.com>
On Fri, 2017-06-02 at 09:13 +0800, Jia-Ju Bai wrote:
> On 06/01/2017 02:21 PM, Nicholas A. Bellinger wrote:
> > Hi Jia-Ju,
> >
> > On Wed, 2017-05-31 at 11:26 +0800, Jia-Ju Bai wrote:
> >> The driver may sleep under a spin lock, and the function call path is:
> >> iscsit_tpg_enable_portal_group (acquire the lock by spin_lock)
> >> iscsi_update_param_value
> >> kstrdup(GFP_KERNEL) --> may sleep
> >>
> >> To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".
> >>
> >> Signed-off-by: Jia-Ju Bai<baijiaju1990@163.com>
> >> ---
> >> drivers/target/iscsi/iscsi_target_parameters.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> > Btw, the use of tpg->tpg_state_lock in iscsit_tpg_enable_portal_group()
> > while checking existing state and calling iscsi_update_param_value() is
> > not necessary, since lio_target_tpg_enable_store() is already holding
> > iscsit_get_tpg() -> tpg->tpg_access_lock.
> >
> > How about the following instead to only take tpg->tpg_state_lock when
> > updating tpg->tpg_state instead..?
> >
> > diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
> > index 2e7e08d..abaabba 100644
> > --- a/drivers/target/iscsi/iscsi_target_tpg.c
> > +++ b/drivers/target/iscsi/iscsi_target_tpg.c
> > @@ -311,11 +311,9 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
> > struct iscsi_tiqn *tiqn = tpg->tpg_tiqn;
> > int ret;
> >
> > - spin_lock(&tpg->tpg_state_lock);
> > if (tpg->tpg_state == TPG_STATE_ACTIVE) {
> > pr_err("iSCSI target portal group: %hu is already"
> > " active, ignoring request.\n", tpg->tpgt);
> > - spin_unlock(&tpg->tpg_state_lock);
> > return -EINVAL;
> > }
> > /*
> > @@ -324,10 +322,8 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
> > * is enforced (as per default), and remove the NONE option.
> > */
> > param = iscsi_find_param_from_key(AUTHMETHOD, tpg->param_list);
> > - if (!param) {
> > - spin_unlock(&tpg->tpg_state_lock);
> > + if (!param)
> > return -EINVAL;
> > - }
> >
> > if (tpg->tpg_attrib.authentication) {
> > if (!strcmp(param->value, NONE)) {
> > @@ -341,6 +337,7 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
> > goto err;
> > }
> >
> > + spin_lock(&tpg->tpg_state_lock);
> > tpg->tpg_state = TPG_STATE_ACTIVE;
> > spin_unlock(&tpg->tpg_state_lock);
> >
> > @@ -353,7 +350,6 @@ int iscsit_tpg_enable_portal_group(struct iscsi_portal_group *tpg)
> > return 0;
> >
> > err:
> > - spin_unlock(&tpg->tpg_state_lock);
> > return ret;
> > }
> >
> I think it is fine to me.
>
> Thanks,
> Jia-Ju Bai
Applied with your Reported-by and Reviewed-by.
Thanks!
prev parent reply other threads:[~2017-06-02 3:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 3:26 Jia-Ju Bai
2017-06-01 6:21 ` Nicholas A. Bellinger
2017-06-02 1:13 ` Jia-Ju Bai
2017-06-02 3:20 ` Nicholas A. Bellinger [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=1496373603.27407.211.camel@haakon3.risingtidesystems.com \
--to=nab@linux-iscsi.org \
--cc=baijiaju1990@163.com \
--cc=bart.vanassche@sandisk.com \
--cc=davem@davemloft.net \
--cc=elfring@users.sourceforge.net \
--cc=hare@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=target-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®