Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp135272rbe; Wed, 28 Feb 2024 15:00:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX1IJbEoopw2mNxLXgiDZ3mU/oIYH7s7CdjtehXxN6A75XVSKzze0467tp0nNWt5FjQa/tXGSI3+lXAFsvMuHaaTqoo1UOpEYt5Iti4Sw== X-Google-Smtp-Source: AGHT+IHycdseg9mQrSyRAJpeleOZ5kSBoujRAyeatftVRYjiOmJC57ju4PmfMjLUrdO32rZ2yzmk X-Received: by 2002:a05:6808:1510:b0:3c1:b35a:dc43 with SMTP id u16-20020a056808151000b003c1b35adc43mr479438oiw.24.1709161218475; Wed, 28 Feb 2024 15:00:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709161218; cv=pass; d=google.com; s=arc-20160816; b=QLBZiC6YfErm6ifAgyZkg5o6YGlZLoF5t3GUIQVjK1SeYz/PIVa4jVRpqVcErZC05s BAjqsTBZHiO1IAK6MqxVqgxHu+7xoGZNrRHlIvgqZRz2sEFhtngGcoMrI2n3C2WyVPjs Tjk9U4oSQ4Nsojgb8pTx2FbNXW+kAx/OMnpMekFVJHdiCrTRc7alY61H7slJj05WcdgV 24UFvf+3MCS+5mdQi1M+lwkZ91xcFrIrxo7wOFQYlTTqXqVK1FI2h4h2d7mel8vMu7DP 8TjqWJ2AexIFcetB7+OwZ00WwfAwc6lq8g8/9+ImWRt/XrK68YfyrBeyptR6d7hbouvN aHSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=bLU58cNsxIxmo5SOnpWD9TRuTE/p29tGp2T+p0X/qao=; fh=ASnGgH7RiT2AIz/dKdesW4ajsX+/yuy5CgaQ/iypUio=; b=E+kM5rumDDAnJywZqk5uOxjtzVHDfhqHu+3NbcgQEY7KAQ60aiGrZv7y+WPpkSupXW z6tY8OQnLJIPf5HLaCZt1ZhnLHl42XycnBafDbrfFdOcKALGNbYGUM3CgMmDpT2FE/+m oF753w1SkYujqGLcmqMKsqWZmAWWUDxgKEzXg9SLKIwBaxxmeHOfNQbBGlgbgajiOvHi 1gT0gXcHLYq4A+mk4UppLTqu+j2RB1ewX9M1bpegWG0GYwh68xsNnu3i8mxcBhqt1qcP j4+ba6aNn0KAYavardofvcV5R97v1Y43LFRqgjielKgVw8TCeIZT4dKVh8xkUZ1sjmyo 6ZpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Lfdc8E+d; arc=pass (i=1 spf=pass spfdomain=flex--justinstitt.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id hq18-20020a056a00681200b006e57a16d5ebsi363932pfb.303.2024.02.28.15.00.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 15:00:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Lfdc8E+d; arc=pass (i=1 spf=pass spfdomain=flex--justinstitt.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85817-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 21CF928B996 for ; Wed, 28 Feb 2024 23:00:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41D337D099; Wed, 28 Feb 2024 22:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Lfdc8E+d" Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) (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 2F7F176F00 for ; Wed, 28 Feb 2024 22:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709161155; cv=none; b=c5EEt3cN38vO+JXZm/VbeG7S+iffsWFSXTVO+21vuzkDa9pS9EvfnpZIoSjL1l/KAdrZgW1E2V2scupFq4CQOmKnLn5MC4gy5FBxju1IDrUdRjjjqpHsT8WA0fgDJlRiu1pu28jU9xMLf3AoVF+5zgAeGDqOQ7UM+1D+fynIJNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709161155; c=relaxed/simple; bh=Z4BBGV1hOFa3fzm1HmN99JMRiPAbNeMi55KlfreDQa8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Wq/dR/bRtVsJWXIacAzegh7hMTlY2f8h3X6Ef1QSboxbnmOQ/jj9kvNf1V3hRCayImniTbU8N6ibruGvvGACInk3P1+BUXowl1H+wbGwDUJFSxkGfOzwKzDddJ2nWKf/3npReQJ1hQRSnVYnt0RUScMK5U+0bf44SYAjbUDrLUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Lfdc8E+d; arc=none smtp.client-ip=209.85.166.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com Received: by mail-io1-f73.google.com with SMTP id ca18e2360f4ac-7c7e21711d0so22731139f.3 for ; Wed, 28 Feb 2024 14:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709161152; x=1709765952; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bLU58cNsxIxmo5SOnpWD9TRuTE/p29tGp2T+p0X/qao=; b=Lfdc8E+dQoKRZ7UHjmCxuuOCumZf+bKJYPFI7mWFMp8y5FPX5nCz/UWCRuj8Gsy7Gr BNA1IvYFd3bY77T0Z3nEf46fSrjzrlVajbo23836z4u9v5kCNMImaCvBcrlrqU6QM887 NX8ESr1CljoU4xv200pQ8AjyDHloSLdlOysohwNX20ovzauRXq/BeqOm1eurEgaGSaj2 Ot48kC+Qi9E8Ii8hQs4fdy8THRHkO3IgO4rKaRm7g+T/ClmKkCcHtRTw1QNAxV4xAolE v8CJrzUo2gJoehB+gRq9bCeuUW2NtaA/JrgCrbSfNuOcPU96a5llrYIcBl5nwqWj/UYx KvNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709161152; x=1709765952; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bLU58cNsxIxmo5SOnpWD9TRuTE/p29tGp2T+p0X/qao=; b=Qi2WWqqyghZF7siAJtUDllFNLwWdV6e2150FlVLCrncF+BowYOTLMRrYXLr2AVqAbO C2Sp/wNq63ZJsbhOlHLLNEEQ7Ahd1NMGBuZH+uUM/nLdcDGrRRefsungP8OA5WHnf8G9 YyBWTkMcarGe8e/dhJPLJJ1cu6FsOWa8qiG8h27ID31jU50HwptktaXR3kWu8t35jqU1 61uMNGJT+gizeywHUNq1hb5W/ECdYFeTUJnhO+vwKe9yEZErPLqnp8BVaTAW4Me6BYtF UFCVydwrRLtLvkTU3J0KKTAJRmSEldL9xNROZW7reMBaGS1RI4LQEkyssHokiRvBjkLg l4Ow== X-Forwarded-Encrypted: i=1; AJvYcCUAgQaiLRHyAflmgpzPfHzc1fnw/8i39NpV6JdW2xKsKocec+/N48FzmH/x7y20ObI/AyQqPItK2idHanX+iQNLiH123SeBbuyhe1Lk X-Gm-Message-State: AOJu0Yx9mrksAB8o4Vwfp5v2dYmuzXYI9UIXGMHVoZkgUSq6yPVj/1ee /3iFm5BqVxaOKaTRtq6Wl6uRAEQgX44msndwaxWYCAP/M55sBaSwVnD616cixU8SrH1ggp8I1NV bHIa13G8tKtAqFu1195jZRg== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a5e:8c15:0:b0:7c7:edf3:3c74 with SMTP id n21-20020a5e8c15000000b007c7edf33c74mr2714ioj.1.1709161152300; Wed, 28 Feb 2024 14:59:12 -0800 (PST) Date: Wed, 28 Feb 2024 22:59:02 +0000 In-Reply-To: <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-0-dacebd3fcfa0@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-0-dacebd3fcfa0@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1709161149; l=2731; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=Z4BBGV1hOFa3fzm1HmN99JMRiPAbNeMi55KlfreDQa8=; b=BOIy+NBZ13y8jyxOGBEgcwe8EF98T+FHbRweiZOnkmVQdW7WTrX+fu+j+rrLs66UCEio/Mkue H7xxvi3ZGOJBzQK3h6BnUCO4CthpnvTF1Ubw473+zhoe1wq7ZYz2lx/ X-Mailer: b4 0.12.3 Message-ID: <20240228-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v2-2-dacebd3fcfa0@google.com> Subject: [PATCH v2 2/7] scsi: mpt3sas: replace deprecated strncpy with strscpy From: Justin Stitt To: 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 Cc: mpi3mr-linuxdrv.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , MPT-FusionLinux.pdl@broadcom.com, netdev@vger.kernel.org, storagedev@microchip.com, Justin Stitt Content-Type: text/plain; charset="utf-8" The replacement in mpt3sas_base.c is a trivial one because desc is already zero-initialized meaning there is no functional change here. For mpt3sas_transport.c, we know edev is zero-initialized as well while manufacture_reply comes from dma_alloc_coherent(). No functional change here either. For all cases, use the more idiomatic strscpy() usage of: strscpy(dest, src, sizeof(dest)) Signed-off-by: Justin Stitt --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_transport.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 8761bc58d965..c1e421cb8533 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4774,7 +4774,7 @@ _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc) char desc[17] = {0}; u32 iounit_pg1_flags; - strncpy(desc, ioc->manu_pg0.ChipName, 16); + strscpy(desc, ioc->manu_pg0.ChipName, sizeof(desc)); ioc_info(ioc, "%s: FWVersion(%02d.%02d.%02d.%02d), ChipRevision(0x%02x)\n", desc, (ioc->facts.FWVersion.Word & 0xFF000000) >> 24, diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 421ea511b664..76f9a9177198 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -458,17 +458,17 @@ _transport_expander_report_manufacture(struct MPT3SAS_ADAPTER *ioc, goto out; manufacture_reply = data_out + sizeof(struct rep_manu_request); - strncpy(edev->vendor_id, manufacture_reply->vendor_id, - SAS_EXPANDER_VENDOR_ID_LEN); - strncpy(edev->product_id, manufacture_reply->product_id, - SAS_EXPANDER_PRODUCT_ID_LEN); - strncpy(edev->product_rev, manufacture_reply->product_rev, - SAS_EXPANDER_PRODUCT_REV_LEN); + strscpy(edev->vendor_id, manufacture_reply->vendor_id, + sizeof(edev->vendor_id)); + strscpy(edev->product_id, manufacture_reply->product_id, + sizeof(edev->product_id)); + strscpy(edev->product_rev, manufacture_reply->product_rev, + sizeof(edev->product_rev)); edev->level = manufacture_reply->sas_format & 1; if (edev->level) { - strncpy(edev->component_vendor_id, - manufacture_reply->component_vendor_id, - SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN); + strscpy(edev->component_vendor_id, + manufacture_reply->component_vendor_id, + sizeof(edev->component_vendor_id)); tmp = (u8 *)&manufacture_reply->component_id; edev->component_id = tmp[0] << 8 | tmp[1]; edev->component_revision_id = -- 2.44.0.rc1.240.g4c46232300-goog