Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp252517ybs; Tue, 26 May 2020 08:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoHsc6nWWz9Gjgxgq2LGlhTD3Ci5CdT4xaSHhtinPgcsnLOd+2At1yrUMjzXFzwCY4dT+c X-Received: by 2002:a17:906:b2c6:: with SMTP id cf6mr1598803ejb.210.1590506510952; Tue, 26 May 2020 08:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590506510; cv=none; d=google.com; s=arc-20160816; b=G0iy57v5rm4P581etGeh5Un7tUPYf90LQAnXvS3rk+fZPwZxJdxYd9IlFdop3AE40U 7JeFS1ZLkqJlzXSizYRTIwFW82p1FyPxedmgzxDfpIchTaBGd5ZbykfMWcu7fcn+KZ+6 1zJDHOMlRegf9Cs+YiE8W2QxrpEw61PtozXeX9Ce2cp48SBwLwV/eGePRxz6te/3WC3j DCIf/juiX4co7uEsXIrqmFh51IzkR801snfVkCa3810ovqtOTirnTQh+QQhyN8pIaakL V/j9KuV5LKJA9vdrz1JE4/SNuqHrPm3UeXGp/wtuDIjenB5r4/p8onfN3oB1hRGOD27W iDcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hDH2DFAglXWP9IvsKwaFfTJwRoZ4ZUxT5xU4AOWlNtc=; b=YvTgHrBBq8yIpDBIrrVJY6aRgTNEzx6CgL2GrHP6v5+Sav3Cs9US5oHxWu46zaFsPv 9sGvervfkd+FlIzzkp4tnoFgw3F+nAkMmH7x4NhCsnGhZths/5IHv0Ur194WWxWlE46E /u0YmE58i1pWK2Lvwqy6WVItlOaeh1kxd0uI6N2KPbduf7FEWFMmeUu5i07TLsqVq0Jv f2GWpgPRHPDFONkkEH0MmTRActZUk2lXN5yZcwywZMlWtIXuygU3UreAxLP4C8lSxOUe qTwf/4LrcSz4QDk4b+9FfxMZzDko9EFceAVTMkesBXdN5vAXpl90bCKpMl7NEWvzIiyn trAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=ew3v7vK1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j30si63514edj.569.2020.05.26.08.21.27; Tue, 26 May 2020 08:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=ew3v7vK1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729564AbgEZPTb (ORCPT + 99 others); Tue, 26 May 2020 11:19:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729311AbgEZPTa (ORCPT ); Tue, 26 May 2020 11:19:30 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B73EC03E96E for ; Tue, 26 May 2020 08:19:30 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id p12so16357889qtn.13 for ; Tue, 26 May 2020 08:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hDH2DFAglXWP9IvsKwaFfTJwRoZ4ZUxT5xU4AOWlNtc=; b=ew3v7vK1IiRYKmBo4BlEfAQV0X7Vle4ysiILIAaUadDtUs9RZVZjCFWeVNxUuxzqjw V3J53Ve4+4oHwHSttgYhLJOjAlcixkAfLhcM9hafOeetwThu/J10+z15s9Zh2drODxq2 +46Z1+jn0AXkV/K1D7KAjt8B+tqWuySU5D3GWW/Ao+PnsXgFhIJBGYMIRPnZlfmsw2gs KEfuSHDeMej4tQyV3a4FqvPTyUvSP0+1C0Qu61/wsa0bG5PbrORM9tQ9lH8lKzXR2kA5 tuztnNH/+5eqraX3pXjo20jap70rt8AW9cVFHkUtD4EwCBzgii229NXnLkzIhnamct60 ve5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hDH2DFAglXWP9IvsKwaFfTJwRoZ4ZUxT5xU4AOWlNtc=; b=OdUjpYEJEJjH4WvVLiXmriHzzX/tXV/v6a6FC3GyKRnX4NOWn2vw3L5bz3pEubnwKa QF61dp/i1tzNvd9QLxGo/zZQkVHccHI+/a8O0MmkgDvJyZNLYwg/8xlj7hdwFkk1XodV vQvjWYhwO+K0yNp9mVtMfl9g9xxmIIf4eoXWJCqbAH2VByxJNPYgedLBNOPAsSAkQY8p j+1DyRv6NeaHw70cMDaKpWfhKsRNvaRVT4piPXMl6KcJ2Be/eQAf3ill9A1x7MzEzzQF YgJkvB/3p2ZvzO23D4FjfYWpRs/QxckE6zdBAFwR4mU1nWl4N6i+oFpkTjNDMp1zL8UA Ft5A== X-Gm-Message-State: AOAM5320lDLB5ZSj+Z8S+jwcqB8W9ggnjU/sBLBS1hN83Nn9B6iseSTU Ybtz+IjQggXRg4PFy31y/tnVjA== X-Received: by 2002:ac8:2bc4:: with SMTP id n4mr1823482qtn.222.1590506369531; Tue, 26 May 2020 08:19:29 -0700 (PDT) Received: from lca.pw (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id 10sm11741905qkv.136.2020.05.26.08.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 08:19:28 -0700 (PDT) Date: Tue, 26 May 2020 11:19:26 -0400 From: Qian Cai To: Don Brace Cc: "Martin K. Petersen" , Scott Teel , Kevin Barnett , esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: UBSAN: array-index-out-of-bounds in drivers/scsi/hpsa.c:4421:7 Message-ID: <20200526151926.GC991@lca.pw> References: <20200526151416.GB991@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200526151416.GB991@lca.pw> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry, adding a missing subject line. On Tue, May 26, 2020 at 11:14:16AM -0400, Qian Cai wrote: > The commit 64ce60cab246 ("hpsa: correct skipping masked peripherals") > trigger an UBSAN warning below. > > When i == 0 in hpsa_update_scsi_devices(), > > for (i = 0; i < nphysicals + nlogicals + 1; i++) { > ... > int phys_dev_index = i - (raid_ctlr_position == 0); > > It ends up calling LUN[-1]. > > &physdev_list->LUN[phys_dev_index] > > Should there by a test of underflow to set phys_dev_index == 0 in this case? > > [ 118.395557][ T13] hpsa can't handle SMP requests > [ 118.444870][ T13] ================================================================================ > [ 118.486725][ T13] UBSAN: array-index-out-of-bounds in drivers/scsi/hpsa.c:4421:7 > [ 118.521606][ T13] index -1 is out of range for type 'struct ext_report_lun_entry [1024]' > [ 118.559481][ T13] CPU: 0 PID: 13 Comm: kworker/0:1 Not tainted 5.7.0-rc6-next-20200522+ #3 > [ 118.598179][ T13] Hardware name: HP ProLiant BL660c Gen9, BIOS I38 10/17/2018 > [ 118.632882][ T13] Workqueue: events work_for_cpu_fn > [ 118.656492][ T13] Call Trace: > [ 118.670899][ T13] dump_stack+0x10b/0x17f > [ 118.690216][ T13] __ubsan_handle_out_of_bounds+0xd2/0x110 > [ 118.712593][ T378] bnx2x 0000:41:00.1: 63.008 Gb/s available PCIe bandwidth (8.0 GT/s PCIe x8 link) > [ 118.716249][ T13] hpsa_update_scsi_devices+0x28e3/0x2cc0 [hpsa] > [ 118.786774][ T13] hpsa_scan_start+0x228/0x260 [hpsa] > [ 118.810663][ T13] ? _raw_spin_unlock_irqrestore+0x6a/0x80 > [ 118.836529][ T13] do_scsi_scan_host+0x8a/0x110 > [ 118.858104][ T13] scsi_scan_host+0x222/0x280 > [ 118.879287][ T13] ? hpsa_scsi_do_inquiry+0xcd/0xe0 [hpsa] > [ 118.907707][ T13] hpsa_init_one+0x1b79/0x27c0 [hpsa] > [ 118.934818][ T13] ? hpsa_find_device_by_sas_rphy+0xd0/0xd0 [hpsa] > [ 118.964279][ T13] local_pci_probe+0x82/0xe0 > [ 118.985405][ T13] ? pci_name+0x70/0x70 > [ 119.004244][ T13] work_for_cpu_fn+0x3a/0x60 > [ 119.024672][ T13] process_one_work+0x49f/0x8f0 > [ 119.046431][ T13] process_scheduled_works+0x72/0xa0 > [ 119.069906][ T13] worker_thread+0x463/0x5b0 > [ 119.090347][ T13] kthread+0x21d/0x240 > [ 119.108531][ T13] ? pr_cont_work+0xa0/0xa0 > [ 119.128450][ T13] ? __write_once_size+0x30/0x30 > [ 119.150405][ T13] ret_from_fork+0x27/0x40