From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 2394A15BE for ; Thu, 29 Feb 2024 00:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709164968; cv=none; b=JTJJ6Nqaqxpn/RmOrLT+9C58i0v41A5Wm1pA3rwhfmk2NPYypyTKFchaYNM8IGV6be/HFylr5BiTrYAhT2FOBx1M1erVMpOfSIC0aC6pElQ3Skwb58l1JFwuhOnKWmEcZLRXiq8MrhTbLJNNWV5ssjBa43Cb10I7FC3kZVxJV48= 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.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iQAAjyIW" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e4b34f2455so170047a34.2 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=c0fO0yhSNg6zEtOQ2afUXutZENwYrEjahzFO4f5JVS8r+gu1hCc6wp0CfcOOJRzSFX YteA+WnkzvFeYI18b87c5WCjEsyxnPyRUv1UA4KSS4qA8eRRgwupQ9IvPX+MTarEtgh3 WD1M32rNt21plsIYpuqLeDU7naq2alLCm8CIcY3TMtV1rW6mRXF1YhDVMedtY5coZBqa jYEybo3mKsq77PuUn0kcWrCxXr8AwLiwPKi/wDG/gAa/b85vvo72R+7NjcMq5BWqoM4T extOEXo4z+oyIH2HAg9HElipFmbodokpnN9L1zllNV7c+OzYbRa2TBhcq/VNnKyiR40v S96w== X-Forwarded-Encrypted: i=1; AJvYcCVapUzlYJLQDZSpjtN8DczlHSUGo4zbUGBiqibNGWg+mSHZmgqJYSzmunmVYoQwpRSS/MSGMjk5sSy2ElMmsoQt2HbgpIeEM2XupmQQo6Zt X-Gm-Message-State: AOJu0YwFuEX+krYoMQqUnJdcYBgEyaWcWxIfjEQDc4sRWnwJy9dN0lpK 8MV8whtCY7ExgxGT4jCinlkGVK8Tei7tbET7nmEq3E8Rl/Cmvkros3IqfBDrcQ== X-Google-Smtp-Source: AGHT+IHqJ/JwJcpPTP9TpL7Xpyx58Z+NNG0bN9Bpx1sjxaHowFIn1a95cgyKBfJKxJgwJgp15rh7Lw== 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-hardening@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