Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp822219lqm; Wed, 1 May 2024 17:47:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaJMrGUhiRfUVAJaSOJOfai4i1Dcw+rQF1yckvXYMmqGkdXsSVkQhkxaRUpmnbi0IGEnDjdam0PyV5mPpnTgAZ4D/wWPj4hkJauDFPtA== X-Google-Smtp-Source: AGHT+IESBmTDhBi95HEIjMaBuPkzI9xjsikhV+xktrLm6e/F2gF2mMgnG07ve9xbs5+jx6r5rp4j X-Received: by 2002:ae9:e507:0:b0:78e:f058:66ef with SMTP id w7-20020ae9e507000000b0078ef05866efmr630807qkf.77.1714610837780; Wed, 01 May 2024 17:47:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714610837; cv=pass; d=google.com; s=arc-20160816; b=MDt6Jj/rbzHRWJ6hfoZzr/cyrO4FBSWhSy582Wc8+wgNt9pHfl1PZAtdnHczjPL/6h Bhl/m25EjuhiIeG5aFDvoggj6ygIU59dVbKiOKWKrmHOgPH/dj2kPZA+rNK9S2DEz7FS qf+IhLpAPX4ZUiHyjCSh/VEHXEj/g1bfUkDpOVQmZtw/vVQa54HluBYPt8ePnjUN8ta/ 5vsGnvTu78Pznq+moK9xWWfvRggQP3AgkoaPtx1Lw34MNQnSb8xgNrGCE9KHKt/8QsEV WZvrpKFKD5fmR0T1ByYBEh1JwsRiXcEKRWnwHfMHXP7nHZ0kuIsijED553/qrsEzJ42u MkGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date :feedback-id:dkim-signature; bh=x7TQftPd3+u6tHbbTYbf5pRgfpcoMKlpeUB0ct1nLso=; fh=eahsJbzhC0uIJZ72GFtQr0BT1T+HZm+DAF6cZBoVN8g=; b=k8ZG7TvZHOvRES5SvXijBjsGq6KGl5yW1/FL31qYFF1k3GSQi7kSElGeyXp2pQ/cYb 0YxnKEV759mR0mg0vu3THMEoer5bOVFsX5uJn4KnNgAcorGhFhVZ9UPiFp0qe29EmeQI mQZaxuOFU49BDXyIBgnUNMVQ6FosX4ZQqGZ/fEecdg5eoYGoPpxAEGRtv8QtdkU7aRaW HSgyaPDZ6CfAlHU4qol44r9PWtiIordYbUE6CsU7MSdrYVa0PjpPZKxhYY7Lpyi1LuAQ CKmkCy0Dvm9DoAUPjeMDDWYHjHCwWR784E+dA8JEkmgSJ912ngPIx2dcfMOsnVPUMAuG 31Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BBmNKNX0; arc=pass (i=1 dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-165883-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165883-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wx23-20020a05620a5a5700b007909b9a4bf2si16280982qkn.502.2024.05.01.17.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 17:47:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165883-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BBmNKNX0; arc=pass (i=1 dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-165883-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165883-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 809CA1C213BA for ; Thu, 2 May 2024 00:47:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30F341172C; Thu, 2 May 2024 00:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BBmNKNX0" Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 62168171AD; Thu, 2 May 2024 00:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714610826; cv=none; b=GgVSZBjDHxgNgRGTuwLlM952V7RzMBT/3JFzHd1+AzqowijAE1WHH38++v9wskelGims3qGXDpVrh4h4Sfbojynb/dOYIzWmk1xjrPMYBJWCt9YRk5NE0uq4tIqqXPZXurv1BNAjJwNiAKu6JegUAwOnjl0uT7tBPOykU/d1XbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714610826; c=relaxed/simple; bh=apm/m1mGLASExEwoGmuvs++Qafh2JxKXrQa8djaX1W0=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=Fxi/ZQThWyaQ5upBVIhWHkzrVatD3qGZYbH/+v/0/Fk6ze8MqKiETJWRNxv2cKDt1adQ63kbgCXax6LWC3mRSXERBViTQpOckkvAHGYVzHtsu1zjt3jeP+aqS6iXW/vRIawW/LI7cA2t1yltENWsTRX4aREKApJOctPHhrDOAG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BBmNKNX0; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 3E9661140123; Wed, 1 May 2024 20:47:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 01 May 2024 20:47:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714610822; x=1714697222; bh=x7TQftPd3+u6tHbbTYbf5pRgfpco MKlpeUB0ct1nLso=; b=BBmNKNX0IEhR+r+O54bY3ciLilxdugPDOLZy5UkPNXzv y7+KYe1xp88Zr+rwbcnfA5Zv6BI0JI7X2xjkzOVf/n2pUqmI+xD8rADax7Pv0JB8 UX6xh4nz/hSSoCIcY27eha27S8ek9SHOYlYW6wRko/TH1mSebV2gCP2/XMLsiGeq 5Lc4voNmV0tRIEvHe8jEJPXAqGcwBhsgJCmhWt+V+iYkm7Te5Y3B5ti7yAoNFr+f lgNry8xOMNwXWydevSc/4iXmiQnZ2ntSn14tORnri35tGXpHTzaiQhOyYaSfdLF+ QNMTJRk/cZU0FsctuPYXQw3D9Hf6x26/y87DmKZMkA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddujedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevufgjkfhfgggtsehttdertddttddvnecuhfhrohhmpefhihhnnhcu vfhhrghinhcuoehfthhhrghinheslhhinhhugidqmheikehkrdhorhhgqeenucggtffrrg htthgvrhhnpeelueehleehkefgueevtdevteejkefhffekfeffffdtgfejveekgeefvdeu heeuleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hfthhhrghinheslhhinhhugidqmheikehkrdhorhhg X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 1 May 2024 20:46:58 -0400 (EDT) Date: Thu, 2 May 2024 10:47:21 +1000 (AEST) From: Finn Thain To: James Bottomley cc: Kees Cook , "Martin K. Petersen" , Erick Archer , Bjorn Helgaas , Justin Stitt , "Gustavo A. R. Silva" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3] scsi: csiostor: Use kcalloc() instead of kzalloc() In-Reply-To: Message-ID: <66bca69a-0036-4108-5963-002cce69376a@linux-m68k.org> References: <202404291019.5AC903A@keescook> <202404291259.3A8EE11@keescook> 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 On Wed, 1 May 2024, James Bottomley wrote: > > The code itself is fine unless you have a 32-bit system with a > > malicious card, so yeah, near zero risk. > > Well, no actually zero: we assume plugged in hardware to operate > correctly (had this argument in the driver hardening thread a while > ago), but in this particular case you'd have to have a card with a very > high number of ports, which would cause kernel allocations to fail long > before anything could introduce an overflow of sizeof(struct csio_lnode > *) * hw->num_lns. > Then it should be safe to add an equivalent assertion. E.g. BUG_ON(hw->num_lns > X) where X was derived either from knowledge of the hardware or from some known-safe kalloc() limit. Though I wonder whether BUG_ON() is the best way to encode preconditions for the benfit of static checkers...