Received: by 10.213.65.68 with SMTP id h4csp13293imn; Mon, 19 Mar 2018 17:53:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELsWsV+7XveXE47oOPg7QkPa/3kCBxcKAOxKettgvUr2NhaYdinW1gmh/PVESB43YMGL99hW X-Received: by 10.98.182.26 with SMTP id j26mr11783708pff.223.1521507238453; Mon, 19 Mar 2018 17:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521507238; cv=none; d=google.com; s=arc-20160816; b=s5Bwp0q7bFQ4tvZanBSfq+ewc7/8Iw0Ock41ZuzX21Vuo0MLgBgUzKOawckAHgVxX5 RO/dLoSWBC5CrJbNJT5K8Dyr6JJVyyDD0ingHuFj6jVZd2qfpMf30uJn+I4PvE75xoWZ Qm21cfvll+xDEnd7qrzfzxX7gInognTvcTIcdLTE7rYrWTxI5NSn2OjSmCYseg9PYixJ MvRs6GB8pzmYkR5bzj1MbzQVFCIv90A5tAC+fxyvT5CoQ/nD0arzBmfHyEdkxS7YmGz3 twftPosYYE7FRM6WO5Cu79xqd2l97niL2Hd1dxmfwMRKLrxpU3OVa2GVCczZaxAtqj2Q BDxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0dolgLdlsnFktHgrWxEXxK2M5uIeO7c2MZbVq8j1QzQ=; b=AEh1/OQORvM0WRkfyCKcWGjHNNj26B8IwVxXtGl1dbVDNmkpcCAi+VvGEEa+IxZFEj UeD9NZlc5Ml8buBnAejkhY/6AoeBP4bTVNnHgZ0f9cXmybR447GXcRsvT9xcVC5vAfoW q/b6xyM3wADClCCKtVndx212IDA1bOwYVDll+UqV5/Hz81ysKwiNHy5JEclrDaPjpWrK ypneZaZi8v7SXUqb0jhk2Xt8xLEKXMl725Hn+yv4OHHAnL2lEmHwauFQNdprUAcy0P8L n/V4Lj0jGtle9GBCmOSI1shECv+Br+uyT0VNqDiBptI7vvnB0jnwUPuJ67d5jdAWhmN9 8ubA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si330974pgr.708.2018.03.19.17.53.44; Mon, 19 Mar 2018 17:53:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031063AbeCSSVN (ORCPT + 99 others); Mon, 19 Mar 2018 14:21:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47928 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031028AbeCSSVC (ORCPT ); Mon, 19 Mar 2018 14:21:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E2D621247; Mon, 19 Mar 2018 18:21:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jitendra Bhivare , Tomas Henzl , Chris Leech , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 071/241] scsi: be2iscsi: Check tag in beiscsi_mccq_compl_wait Date: Mon, 19 Mar 2018 19:05:36 +0100 Message-Id: <20180319180754.142621693@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jitendra Bhivare [ Upstream commit eb419229be58dc6d4a3a814116a265908e088c39 ] scsi host12: BS_1377 : mgmt_invalidate_connection Failed for cid=256 BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [] __list_add+0xf/0xc0 PGD 0 Oops: 0000 [#1] SMP Modules linked in: ... CPU: 9 PID: 1542 Comm: iscsid Tainted: G ------------ T 3.10.0-514.el7.x86_64 #1 Hardware name: HP ProLiant DL360 Gen9/ProLiant DL360 Gen9, BIOS P89 09/12/2016 task: ffff88076f310fb0 ti: ffff88076bba8000 task.ti: ffff88076bba8000 RIP: 0010:[] [] __list_add+0xf/0xc0 RSP: 0018:ffff88076bbab8e8 EFLAGS: 00010046 RAX: 0000000000000246 RBX: ffff88076bbab990 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff880468badf58 RDI: ffff88076bbab990 RBP: ffff88076bbab900 R08: 0000000000000246 R09: 00000000000020de R10: 0000000000000000 R11: ffff88076bbab5be R12: 0000000000000000 R13: ffff880468badf58 R14: 000000000001adb0 R15: ffff88076f310fb0 FS: 00007f377124a880(0000) GS:ffff88046fa40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000008 CR3: 0000000771318000 CR4: 00000000001407e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Stack: ffff88076bbab990 ffff880468badf50 0000000000000001 ffff88076bbab938 ffffffff810b128b 0000000000000246 00000000cf9b7040 ffff880468bac7a0 0000000000000000 ffff880468bac7a0 ffff88076bbab9d0 ffffffffa05a6ea3 Call Trace: [] prepare_to_wait+0x7b/0x90 [] beiscsi_mccq_compl_wait+0x153/0x330 [be2iscsi] [] ? wake_up_atomic_t+0x30/0x30 [] beiscsi_ep_disconnect+0x91/0x2d0 [be2iscsi] [] iscsi_if_ep_disconnect.isra.14+0x5a/0x70 [scsi_transport_iscsi] [] iscsi_if_recv_msg+0x113b/0x14a0 [scsi_transport_iscsi] [] ? __kmalloc_node_track_caller+0x58/0x290 [] iscsi_if_rx+0x8e/0x1f0 [scsi_transport_iscsi] [] netlink_unicast+0xed/0x1b0 [] netlink_sendmsg+0x31e/0x690 [] ? netlink_rcv_wake+0x44/0x60 [] ? netlink_recvmsg+0x1e3/0x450 beiscsi_mccq_compl_wait gets called even when MCC tag allocation failed for mgmt_invalidate_connection. mcc_wait is not initialized for tag 0 so causes crash in prepare_to_wait. Signed-off-by: Jitendra Bhivare Reviewed-by: Tomas Henzl Reviewed-by: Chris Leech Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/be2iscsi/be_cmds.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -246,6 +246,12 @@ int beiscsi_mccq_compl_wait(struct beisc { int rc = 0; + if (!tag || tag > MAX_MCC_CMD) { + __beiscsi_log(phba, KERN_ERR, + "BC_%d : invalid tag %u\n", tag); + return -EINVAL; + } + if (beiscsi_hba_in_error(phba)) { clear_bit(MCC_TAG_STATE_RUNNING, &phba->ctrl.ptag_state[tag].tag_state);