Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp434781lqr; Wed, 5 Jun 2024 10:04:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWK/7bMnNWhw1zX5eEegFOT86WBZQNY6Jjo9Fw3HQ9zixWjrQAj2HRB7784rPOuaonoiiOS/ldOXnRRFyKE9rrGzVU+6dW2L4nLzxDBMg== X-Google-Smtp-Source: AGHT+IHbBseREXXLJT0YK8U4y3YkdqH4Qd7E7J5veNXxwt++V5C0Hw1e7eRMYEfsOLEVfjxGHn8q X-Received: by 2002:a05:6358:6f04:b0:18f:6026:2d6a with SMTP id e5c5f4694b2df-19c6c8fa93fmr362455255d.21.1717607086382; Wed, 05 Jun 2024 10:04:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717607086; cv=pass; d=google.com; s=arc-20160816; b=bCCYnwejCPZk2DDeDEBIDRpYy0f95PZ0ijn1Lckox3NR0QH5IqS0/hIaJ35e/VGIda EDwvNecINH1PLpEfhl0WEzGyiIqoKfJSgI+N0UAHx5rn4E8Ay7wQPfT8FK1OBn1YR1e6 Y3lHGy9hhfqHhb++7ketBLmuvwspbEO/vO3l+bjJmTsqVlb/6g8SSb2Vv/al9724LIMZ hUcbjJYKmn4iLte9VNWDS2PBH5ZrCVMcQ5NLQC+cWEve5fjtowQPJgRif3+Iw28MI2dy FBLJgGhe747GLAPgpyXo7TihCnYFY5dUex7Isp8eFcwr8uDSuMJEQm+zRTRlmN0y1Wrd RK6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qNS1dAySq8mx9lv9Ko8+KvXHQop/2h4qxx2oYvcn5WE=; fh=t/mUdBrDhj8saqECpPW9HFxPJA683GKnt7csiVOOTQM=; b=YencorqdSwa2TEPTlrBSyoO8BacFNcpAd30W5ggJ9MVkin5gKXoWwgTJL2yDiSsrfp r+xd2YvYJBkAal2wZK1kdHxPW14JMPfp6DgGgq361dZshZ1iP187HSAi7R5n4GsALvqo LzAO4UHDA/vuMf9m2lWcc5XRZiQ7wDmssCDe0bqa1AC9sn2/c+qopAC/YJZAPdMbpSJF ROQ3f0d4JIMhiJ52h50ZY16FAE1T65KwOFsSAoUOCLfXPcj/nVkDJmRAle29DovNtpfC ivDOCqIIC0xV7oEXva6JGQGATY0fmhN43HPWVFFhJei3X+VUU1fWwXUWIAL5BN1hYchf a36g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fa1YcfXG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202955-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202955-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e0540dsi3516852a12.278.2024.06.05.10.04.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 10:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202955-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fa1YcfXG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202955-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202955-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 056F628212E for ; Wed, 5 Jun 2024 17:04:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35FCC18FDAF; Wed, 5 Jun 2024 17:04:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fa1YcfXG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5260D17559; Wed, 5 Jun 2024 17:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717607072; cv=none; b=qUoOH0UwABSd6IHHaBQnpP0tICMbqODiDy4jNH0nAwGgRqGxH8ixK9Rzh9N2fRYCsHoKtajWy6QusG8D4h6pCnVr0dATZODq8XlxV1Ew67qUney3EeQf2C1e/G7rWxLCdMuxWoAqmUpsHt2yLt/qRWtenNzagfszhBIvYLHIuaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717607072; c=relaxed/simple; bh=nhFWFsp+9ExjOIXbu0vBmHM9s9CAsaCAVQQ7E358h9U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r2E5snRV8u7tRQ3KcR7YjCNoZVPB2C2FhMzIn8p324IQhJRNpv3UMrf7Fe8AbyZ63QQyz8mo+CRcG/0AHOWj3eASp2yMHZgvDXu2okkFZG4g2k9nKOYRnZ9GSg/b4UaQ82SjrAILDqYOgC3qBpoVjE5mvGsEshcYf7AmelzbJIU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fa1YcfXG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B7AC2BD11; Wed, 5 Jun 2024 17:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717607072; bh=nhFWFsp+9ExjOIXbu0vBmHM9s9CAsaCAVQQ7E358h9U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fa1YcfXGmjcOXmffGBJge6qX26nr1zo/kXEqmVo1su2WdAIlSKFcpEiDDS2DDH2Fx HpaQiGe7X51iLeB+wcUeUGyRuenIfOBL59LWtA6H+MaVPZyNyYdcIV3LphhusJWYzz l1VnWcAL95uFrkuPXeK3r4PhzYPOERC8x2bcAoo1m5LLKKRqDpP2fHvHaldLPsrwtq rgFQE7CGpMotRiVYDgSEGAgmhai9hhAUNSsg+WUE+1P/WYNaOpU4RmLWSX61ew/mJm 558DLmWiXztnaPcho+7DEHIHLR6trO3Yw80kOi8ZLgda3ENjPjgPdjyxxuCT6RMmQy d+YcPETCnTAdg== Date: Wed, 5 Jun 2024 11:04:28 -0600 From: Keith Busch To: Breno Leitao Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , "James E.J. Bottomley" , "Martin K. Petersen" , Chaitra P B , leit@meta.com, stable@vger.kernel.org, "open list:LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)" , "open list:LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)" , open list Subject: Re: [PATCH v2] mpt3sas: Avoid test/set_bit() operating in non-allocated memory Message-ID: References: <20240605085530.499432-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240605085530.499432-1-leitao@debian.org> On Wed, Jun 05, 2024 at 01:55:29AM -0700, Breno Leitao wrote: > There is a potential out-of-bounds access when using test_bit() on a > single word. The test_bit() and set_bit() functions operate on long > values, and when testing or setting a single word, they can exceed the > word boundary. KASAN detects this issue and produces a dump: > > BUG: KASAN: slab-out-of-bounds in _scsih_add_device.constprop.0 (./arch/x86/include/asm/bitops.h:60 ./include/asm-generic/bitops/instrumented-atomic.h:29 drivers/scsi/mpt3sas/mpt3sas_scsih.c:7331) mpt3sas > > Write of size 8 at addr ffff8881d26e3c60 by task kworker/u1536:2/2965 > > For full log, please look at [1]. > > Make the allocation at least the size of sizeof(unsigned long) so that > set_bit() and test_bit() have sufficient room for read/write operations > without overwriting unallocated memory. Looks good. Reviewed-by: Keith Busch