From patchwork Tue Feb 7 13:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 9560089 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 E044E6047A for ; Tue, 7 Feb 2017 13:27:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D181928047 for ; Tue, 7 Feb 2017 13:27:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4CC4282E2; Tue, 7 Feb 2017 13:27:34 +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, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 80A6827F86 for ; Tue, 7 Feb 2017 13:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754717AbdBGN1L (ORCPT ); Tue, 7 Feb 2017 08:27:11 -0500 Received: from mail.linux-iscsi.org ([67.23.28.174]:41070 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754292AbdBGN0N (ORCPT ); Tue, 7 Feb 2017 08:26:13 -0500 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id CC18A40B07; Tue, 7 Feb 2017 13:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1486473473; bh=PB67Pev0WCOMUtsM+iOF6udHzIyJ833 1jBu9wzbpwIs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=VaRPiUV7QjfbPPQ9W3/iiUdvsRF47rb9VlODbNsuaooA6/GIjg63 V3LewTh4K7VCRSXDiNUalOOsy9s+vTqyXUclvJi1oFOp9x/I7SljuKjw2MIgT+SUIZO TweN+i5DP586KB9u2/gL0q06Yvx4HwPM9xrlylUgiaE8Y7xfNg78= From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , lkml , Nicholas Bellinger , Benjamin ESTRABAUD Subject: [PATCH 1/5] target: Don't BUG_ON during NodeACL dynamic -> explicit conversion Date: Tue, 7 Feb 2017 13:17:46 +0000 Message-Id: <1486473470-15837-2-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1486473470-15837-1-git-send-email-nab@linux-iscsi.org> References: <1486473470-15837-1-git-send-email-nab@linux-iscsi.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger After the v4.2+ RCU conversion to se_node_acl->lun_entry_hlist, a BUG_ON() was added in core_enable_device_list_for_node() to detect when the passed *lun does not match the existing orig->se_lun pointer reference. However, this scenario can occur happen when a dynamically generated NodeACL is being converted to an explicit NodeACL, when the explicit NodeACL contains a different LUN mapping than the default provided by the WWN endpoint. So instead of triggering BUG_ON(), go ahead and fail instead following the original pre RCU conversion logic. Reported-by: Benjamin ESTRABAUD Cc: Benjamin ESTRABAUD Cc: stable@vger.kernel.org # 4.2+ Signed-off-by: Nicholas Bellinger Reviewed-by: Christoph Hellwig --- drivers/target/target_core_device.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 1ebd13e..23e89af 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -345,14 +345,22 @@ int core_enable_device_list_for_node( lockdep_is_held(&nacl->lun_entry_mutex)); if (orig_lun != lun) { - pr_err("Existing orig->se_lun doesn't match new lun" - " for dynamic -> explicit NodeACL conversion:" - " %s\n", nacl->initiatorname); + pr_warn_ratelimited("Existing orig->se_lun doesn't match" + " new lun for dynamic -> explicit NodeACL" + " conversion: %s\n", nacl->initiatorname); + mutex_unlock(&nacl->lun_entry_mutex); + kfree(new); + return -EINVAL; + } + if (orig->se_lun_acl != NULL) { + pr_warn_ratelimited("Detected existing explicit" + " se_lun_acl->se_lun_group reference for %s" + " mapped_lun: %llu, ignoring\n", + nacl->initiatorname, mapped_lun); mutex_unlock(&nacl->lun_entry_mutex); kfree(new); return -EINVAL; } - BUG_ON(orig->se_lun_acl != NULL); rcu_assign_pointer(new->se_lun, lun); rcu_assign_pointer(new->se_lun_acl, lun_acl);