Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp161211rbe; Wed, 28 Feb 2024 16:02:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0QEdNd4j1EzvFPXovpfgvME25XYoDPs594w8MguAt85gINpkro87YRNZ59Ae8DG1ZVOwt4dRYzkiYlDAVetcpP5DWM81swshGBCrFWw== X-Google-Smtp-Source: AGHT+IHsj5lKwapDvzQAihZJS7SJdtFQ/jdIcI5eBiZBilEa9gehqSzEusR+kF0LqUtnaPzu/TV+ X-Received: by 2002:a0c:e24c:0:b0:68f:e84b:9d8d with SMTP id x12-20020a0ce24c000000b0068fe84b9d8dmr595913qvl.42.1709164978960; Wed, 28 Feb 2024 16:02:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709164978; cv=pass; d=google.com; s=arc-20160816; b=PUmlVGlF0u7EySJ4KIbjIZtvKW0PcYUZ3x28ytvh0SI1m5TKXdEoUdhORjsVFueNkK BjHVGFkhSzRyC+6oRuGJOD2++uiQDg4wbAfZ4qPigICcxQoxf30vuwXG1+Z/vpgML0Yc N/Pf1xKoTbq+6kDXc/lB+HQdAqT3mN4SGZm4OdGbmHFCKnjNKcraoXZwiQgjoA5fP6zZ eZ5k9tE0AR317/tckTxxP4+CRYaZRXruPN09UOdHMO3r86UbRxjE9h9X4VqgYPjwN1Mz Ho3K3yTrEAUQxrl/dxpx1IXw/wZV54ylang1ik2Lz2FvnBzpsGTDPlCnyRl886SEyOSx Uqzg== 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=dzYFHNFtHHHpRZc8edEq8bHU8oqWM7vjNzOC9ZZj3Zw=; fh=86Kj6IaeYBgvhGsOSj5W/NXv4bNoj7UDC4JQoKl2Sx0=; b=vBoeica/IW2zMIlwjT2oSKFOnMStOGgTF9ZCY+mwpkhcfEOpSUZESS1S65hFW0h3I9 lTqtL+fGGcEzMeuJgG8N/RlE0tovBY30lflAhhJBImUQbyCBRQLfu1MTFosMV0SoKNJE bmKeeA2Y14+dp1W6Mf2NfT0lJgjcTzLBnJRopYoRnwbpyiQzfQT+Hj3DwrpQMGiVeram zUMRzWJlDM3JUMjOi2JmendpZWHuA84nFpObrHu1Iyx8womB258LL+J+3tOJMqA4ZP+n Y+gJBabJSrodPAP4NdjBmM/bwBmZpDb1OuEaGerp5YNKc2DSvviSNeYYGLs+ug0heTl+ aYiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iQAAjyIW; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-85863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id if6-20020a0562141c4600b0068f38e7283fsi227618qvb.7.2024.02.28.16.02.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:02:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iQAAjyIW; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-85863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 B2FFA1C2380D for ; Thu, 29 Feb 2024 00:02:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 742185226; Thu, 29 Feb 2024 00:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iQAAjyIW" Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FEA21106 for ; Thu, 29 Feb 2024 00:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709164968; cv=none; b=JxUvGVShpkOi0BZ4H4DeZPCytgLs0uC0e3+/jhkqRBlBGaN8Mr+CRGwFJF+GnYdvT4S5oKnsiAGNexU+//yd5WoWUTRV0EBsBOHvikEwGvcVqDoi4UyPmymbF6iZT0SeCf8RQoRcz1NKpEDBFLT92vY6vKPS1w/iMcof7wMJETA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709164968; c=relaxed/simple; bh=tH8Do06WsHG8uh7bIC0z1/jOfTEgMGtUd5RXQ5jyXwY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZqwWCVGALaYlv1F5EbU3VlGxTMQWvfj1a12DeSv5c30H526NgeJEPG06yviCsOcW69SBGrZTAsIz5i4vpsD8Kt5sQuTkTicU5wHnhi14tQskDLk0igZ59kqJXdokOIzXPwbP9YlE5uyLBFXIwN/1SUnbcvs3euR35HgW+EIGEMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=iQAAjyIW; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6e478057f1aso144767a34.3 for ; Wed, 28 Feb 2024 16:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709164966; x=1709769766; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dzYFHNFtHHHpRZc8edEq8bHU8oqWM7vjNzOC9ZZj3Zw=; b=iQAAjyIWjHzlp0w0zAz8XfTortXy50gEPPvXUInJQNpwa2nzLMHuBnYqRILTEpwNbi GJFm+FilgeG+XUGAHAtwkUM4M3sEMT87s0zsdaXbf3Vz/MGUO0LzDopdH4+CbDPkG6L9 MFTXQyqmObj1eNFTbtl8xAFTIGsl3UADpscxE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709164966; x=1709769766; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dzYFHNFtHHHpRZc8edEq8bHU8oqWM7vjNzOC9ZZj3Zw=; b=XFBB8S4YyfeG+NjHwDRjiq/EHnMaX28+rbVEzLEnHxJRb9GAiXJvBq6wENElKVJ5cn FCfbROm51KVmOHOwU4Y91XG2dY7zPlVusipBZpmhI4EDNmikINw3MqiOelH76dJnQlzW S74MNEO/ukjrvmxcqQUdeAean6AHir42qHo8HXmrcj2oyrrZsgulrZ8e36e1w53hWX2g 8oOtDeKbOAs353y5ODIPxC10k1D/C3+C+VugCefbeXlrIdBPQhDygyrdFrDdgrNV/Gi/ aSfjIQH3ihMfuYfzWM5A/237HfCeHaBRKBAFcAq2Pw1xsP40kZEwjGvciBtvKax4njgL v02g== X-Forwarded-Encrypted: i=1; AJvYcCWuH3dirRC3Y8s2AE3sOT5XJ476QUmRtCPeYcT3mdbxee5tFImtNRuOU+k04iORjugfiMRLZYEFU0z4f5sYgAUP5Ztn2wPU2EEeOoGq X-Gm-Message-State: AOJu0YxN8Mondd2tTLl63SKEEMiHSB3SeWuCoQzKxOti2U6BmeudzBNf IZARJ/R3+ZQsXW1stZsYCvtukrPiUw6aa7QNChfuoQG0yS68MX+mGcx+3vCwGw== X-Received: by 2002:a9d:7acd:0:b0:6e4:787a:9bc5 with SMTP id m13-20020a9d7acd000000b006e4787a9bc5mr461484otn.14.1709164966200; Wed, 28 Feb 2024 16:02:46 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id k3-20020a63d843000000b005dcbb855530sm61436pgj.76.2024.02.28.16.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:02:45 -0800 (PST) Date: Wed, 28 Feb 2024 16:02:45 -0800 From: Kees Cook To: Justin Stitt Cc: Sathya Prakash Veerichetty , Kashyap Desai , Sumit Saxena , Sreekanth Reddy , "James E.J. Bottomley" , "Martin K. Petersen" , Suganath Prabu Subramani , Ariel Elior , Manish Chopra , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saurav Kashyap , Javed Hasan , GR-QLogic-Storage-Upstream@marvell.com, Nilesh Javali , Manish Rangankar , Don Brace , mpi3mr-linuxdrv.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, MPT-FusionLinux.pdl@broadcom.com, netdev@vger.kernel.org, storagedev@microchip.com Subject: Re: [PATCH v2 1/7] scsi: mpi3mr: replace deprecated strncpy with assignments Message-ID: <202402281602.2750B1F2@keescook> References: <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-0-dacebd3fcfa0@google.com> <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-1-dacebd3fcfa0@google.com> 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: <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-1-dacebd3fcfa0@google.com> On Wed, Feb 28, 2024 at 10:59:01PM +0000, Justin Stitt wrote: > Really, there's no bug with the current code. Let's just ditch strncpy() > all together. > > We can just copy the const strings instead of reserving room on the > stack. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt Reviewed-by: Kees Cook -- Kees Cook