Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2525349imm; Mon, 28 May 2018 09:44:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXA7xj3aHQ3hTO/Yo63uq4uwcaf/NxVe6bq93LV2bPe4VVrHheQiXzmf5l5QXjUJmMmXrI X-Received: by 2002:a65:64d9:: with SMTP id t25-v6mr11156508pgv.148.1527525883932; Mon, 28 May 2018 09:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527525883; cv=none; d=google.com; s=arc-20160816; b=XnGXj+tulgTsWSpNjL55ze8WhD8ESyiwpY2w9bj4PcikE2j0ra7jjHzwYN/ERQBBy1 OGZKwievVUvtTx2dv0umJwRbIciuiLjI2Qy/ukrEuVWBu3NC099EgxOBIyFXOWcvOAw7 i3LqQzXU5yBc/e4ZmPXOqPPn73ufB9ZY/DJUKp7rveffd3+keC/mXrITaut066WvmgM8 JwwikB2VySB0niJ/NvvwuzhU/U7EXTaS3V4Kmwk8cImRx1j6OjCTEBm1UAGyz3lZqFe8 9Ro23yJxaGYfLhKKJQSAciQWNUeyMaTUOesggM4nl6pgPQNrFjlhyBpzit2+gZWlW06p Kfag== 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:dkim-signature :arc-authentication-results; bh=g5toIlsBjKy0Qu95Tl4ZrV/PaXFXIbBOZYpe9SdJ8Ng=; b=yMhs0Duw1X5olRfV8K4fCJ6VMeKbYRo4T+nHKipoo7LihunmC1CkkHOlGaQ6FhgiLr MpAsJeX4Hbfq6FkEy60uaCyxNAKrBsd8ZxK8cIaM7aKkBekZamWrpjPtWpqunotyyC+s qThhLMUstPFrF57KYKutyKrN/7DDG7ZZ8SprzUdVSlK9EXvutxMioAgTUlLiHShsmfN9 8xqecf5ix8/7ZTqPsqWHZ4oAp8rixlr+Gsf70mN3Z52FbvwFywZPfipE/+g88g1J+3OC Kt3wiojmcHjA3UvR+YpfdsLffpHsVYQKMj4MxZtzwVcrqYUOaCQKHwPKqt9YCSYZhNrw cAPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yQDPQYDm; 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 j20-v6si31118226pfa.57.2018.05.28.09.43.58; Mon, 28 May 2018 09:44:43 -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; dkim=pass header.i=@kernel.org header.s=default header.b=yQDPQYDm; 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 S940357AbeE1Qmh (ORCPT + 99 others); Mon, 28 May 2018 12:42:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:55842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933622AbeE1KHs (ORCPT ); Mon, 28 May 2018 06:07:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F95020876; Mon, 28 May 2018 10:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502067; bh=YQcBbyaxx54FKyBjdCN3Em5qzJwg8HqcneTBq7tTVBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQDPQYDmQV1QjLRnoOffSL4Omje+uf8Xpy0MbLr4k0s0Mjpjob3OPSs+lJbuLX4st bbET2frzMzyAjJ3Bultv8RkNBGEMbRWgqXSV+XZyz8Qahmn1kr6Ej1nBOhCt0S4W7Q WEN7bBA9Akjw64h4NeDZHSf1deEBVA6PfXgrF8QY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meelis Roos , Bart Van Assche , Himanshu Madhani , Laurence Oberman , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 3.18 050/185] scsi: qla2xxx: Avoid triggering undefined behavior in qla2x00_mbx_completion() Date: Mon, 28 May 2018 12:01:31 +0200 Message-Id: <20180528100055.150963794@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche [ Upstream commit c02189e12ce3bf3808cb880569d3b10249f50bd9 ] A left shift must shift less than the bit width of the left argument. Avoid triggering undefined behavior if ha->mbx_count == 32. This patch avoids that UBSAN reports the following complaint: UBSAN: Undefined behaviour in drivers/scsi/qla2xxx/qla_isr.c:275:14 shift exponent 32 is too large for 32-bit type 'int' Call Trace: dump_stack+0x4e/0x6c ubsan_epilogue+0xd/0x3b __ubsan_handle_shift_out_of_bounds+0x112/0x14c qla2x00_mbx_completion+0x1c5/0x25d [qla2xxx] qla2300_intr_handler+0x1ea/0x3bb [qla2xxx] qla2x00_mailbox_command+0x77b/0x139a [qla2xxx] qla2x00_mbx_reg_test+0x83/0x114 [qla2xxx] qla2x00_chip_diag+0x354/0x45f [qla2xxx] qla2x00_initialize_adapter+0x2c2/0xa4e [qla2xxx] qla2x00_probe_one+0x1681/0x392e [qla2xxx] pci_device_probe+0x10b/0x1f1 driver_probe_device+0x21f/0x3a4 __driver_attach+0xa9/0xe1 bus_for_each_dev+0x6e/0xb5 driver_attach+0x22/0x3c bus_add_driver+0x1d1/0x2ae driver_register+0x78/0x130 __pci_register_driver+0x75/0xa8 qla2x00_module_init+0x21b/0x267 [qla2xxx] do_one_initcall+0x5a/0x1e2 do_init_module+0x9d/0x285 load_module+0x20db/0x38e3 SYSC_finit_module+0xa8/0xbc SyS_finit_module+0x9/0xb do_syscall_64+0x77/0x271 entry_SYSCALL64_slow_path+0x25/0x25 Reported-by: Meelis Roos Signed-off-by: Bart Van Assche Cc: Himanshu Madhani Reviewed-by: Laurence Oberman Acked-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_isr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -268,7 +268,8 @@ qla2x00_mbx_completion(scsi_qla_host_t * struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; /* Read all mbox registers? */ - mboxes = (1 << ha->mbx_count) - 1; + WARN_ON_ONCE(ha->mbx_count > 32); + mboxes = (1ULL << ha->mbx_count) - 1; if (!ha->mcp) ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); else @@ -2454,7 +2455,8 @@ qla24xx_mbx_completion(scsi_qla_host_t * struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; /* Read all mbox registers? */ - mboxes = (1 << ha->mbx_count) - 1; + WARN_ON_ONCE(ha->mbx_count > 32); + mboxes = (1ULL << ha->mbx_count) - 1; if (!ha->mcp) ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); else