From patchwork Wed May 31 03:26:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 9755737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B8CB9603F7 for ; Wed, 31 May 2017 03:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A905E205F8 for ; Wed, 31 May 2017 03:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DA4B28474; Wed, 31 May 2017 03:25:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 550ED205F8 for ; Wed, 31 May 2017 03:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751080AbdEaDY4 (ORCPT ); Tue, 30 May 2017 23:24:56 -0400 Received: from m12-11.163.com ([220.181.12.11]:43170 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751039AbdEaDYz (ORCPT ); Tue, 30 May 2017 23:24:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=iLzS4vk19cqtIojcGg xEWKERTnhH31qu5lmEIA3kudQ=; b=hl8lS5dI5/vzjKFsKSj/rlHnDsy5b/Th9L C/4F4wm8bx8mPesB1LHTdY8QDLtdPVJmBOvWs5JFSgMCFHb/IiVBAnqrp2JDyFQU QOW7ICvRyAPc2CACq5isN9goxYHTFdXEbdbejbv7vHkXeHsWTzP5c4gWON6gif7a 2MwYnndBo= Received: from bai-oslab.tsinghua.edu.cn (unknown [166.111.70.19]) by smtp7 (Coremail) with SMTP id C8CowAA3RBBqNy5ZgSYzHw--.31021S2; Wed, 31 May 2017 11:24:30 +0800 (CST) From: Jia-Ju Bai To: nab@linux-iscsi.org, bart.vanassche@sandisk.com, davem@davemloft.net, hare@suse.com, elfring@users.sourceforge.net Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] iscsi: Fix a sleep-in-atomic bug Date: Wed, 31 May 2017 11:26:39 +0800 Message-Id: <1496201199-3661-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: C8CowAA3RBBqNy5ZgSYzHw--.31021S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5ZF4Utr1rXrb_yoWDCFbE9r y5tr12gr1Ygrn3tw1jkrsrCFy29348ur1xuan7tw4ayFyUZrWqyF9FvFyfuwsrX393Ary5 uwnIqrWkCFnrXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjH5l7UUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiTQ7oelc69W8oGAAAsW Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/target/iscsi/iscsi_target_parameters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index fce6276..8768916 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c @@ -702,7 +702,7 @@ int iscsi_update_param_value(struct iscsi_param *param, char *value) { kfree(param->value); - param->value = kstrdup(value, GFP_KERNEL); + param->value = kstrdup(value, GFP_ATOMIC); if (!param->value) { pr_err("Unable to allocate memory for value.\n"); return -ENOMEM;