Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp615080rdh; Thu, 26 Oct 2023 10:45:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF13RMRYvvDAutxng0R+dQPc0/h8hEk4jJQWruwKK6/XTxiqSwlzMRvfHAj2PredWjJv7/6 X-Received: by 2002:a81:b643:0:b0:5a7:d997:cc7b with SMTP id h3-20020a81b643000000b005a7d997cc7bmr193329ywk.23.1698342354825; Thu, 26 Oct 2023 10:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698342354; cv=none; d=google.com; s=arc-20160816; b=ZBzjjcbu0JNOo4tBlQWv1yv7wAOXtogvq236Ed+pCpiQ41TntLxHe9kCmmTUAsx6/9 dD7JtAJGKN8Q94i7WnuTvq3nTFxzou4issGejyIjyxyZekBO9f++65qmIPgVcniVxZAX fIJXODP/lwxfk/9a/n0lT9FY3NXCQucA1fE1qyGGsF5OC7k5Y7CS5jHIVVfkhW3FxXIk 0MJuLvLqeybRRupks/3dFLiJ3gidWPfCFfwaZRvWx4UoL6WuNlnakcR2dZILVkl66s2X TJDGdwA/aPiR1NXfkXcWYJrpuBxvguZZDMMcB4UPlUaylktt5jwYVhbVGva0VrOiZdzM yxTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lAfQHwAPGilY5JFUvY07Iu65/aCmQBkbdIAGwWe4Mw4=; fh=GgAYElNIKQer/mJY09jWELTkaKNFoN5gIHS03BjZPhg=; b=JglNpXdndwuDFu/6HOrEmEviu3nGti9P09R4lgKw7gbCLuE1CeV3sdMkBQbROVCBTz IIRY9lrE3u0DeHFus1wURwu8lhherJcikh2ZxWz/cOyoBJob8NUkn+rvXx5HknoRsmRN f4Or7WKmruB0UXDvhWUkZAjcfKybS0asaNsRg4PYLziH/q/CWiOb3Af8BB1KU83vbsHf nw+gOxwYC4IEVPEGejBd25Pe2KVe02qTfD0mBnlXUFxOSO+okz7U7WyptIxdoQvRTvb4 ayx5uDenVGELuK9jSYtMJBsGoCm8hl+G/d11Vtbjl/HEUPmXG5YOHBn+JOnZhRNDm0cD qeoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="OOokzr/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id v188-20020a0dd3c5000000b005a7be928f8bsi13753447ywd.272.2023.10.26.10.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:45:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="OOokzr/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D3CD8805D57B; Thu, 26 Oct 2023 10:45:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjJZRpd (ORCPT + 99 others); Thu, 26 Oct 2023 13:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjJZRpc (ORCPT ); Thu, 26 Oct 2023 13:45:32 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F83B1A6 for ; Thu, 26 Oct 2023 10:45:30 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6b709048f32so1143413b3a.0 for ; Thu, 26 Oct 2023 10:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1698342329; x=1698947129; 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=lAfQHwAPGilY5JFUvY07Iu65/aCmQBkbdIAGwWe4Mw4=; b=OOokzr/xpQa586UCRy1xcsAo2JXtjXKK1A4AH0Mi0GigDWK5n5q4u1PR/MPf7y4mZx 6lfsYsgMkX3AgdzCDUoaVBEAyZ6mKBXXMfIbGM7AQzKUgVkEUaMNlphLER8SP3XX3QRD RJOB3ss9gxH8pBplRtLEDGjf1MqM7kQSLI8uA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698342329; x=1698947129; 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=lAfQHwAPGilY5JFUvY07Iu65/aCmQBkbdIAGwWe4Mw4=; b=cPgDqlsPOioRl0ecUfz04zLs9yRHj1KbIx8Mg6PjYOsrNa8NB8sF87WCCSuwYe86rg r6XO8/obCRv7ZVD9veQiZ2Ymj9cM3KS74bz3LRXTBWnXbXRtlG4NeCbRzbVx2uYFE+Ym HVVXa9+7HJo35/7DHNyHYOlySiI8el+ozwUATDMHrs7gNBNdqL2pCEDvUSWOY1uAqmBs 6bSc6Y9BJw51Atg507LNqHOwcpecEsH9X9uEYe17LTeK+s8DAv84k81K5+uMHhfq4Ue7 uezWbf47zkujb48m3Tubn5SVxwexFmQ9sXZuUs8PBv9BU0K1cmeYC+mTfjHS+Iwzofln wAOA== X-Gm-Message-State: AOJu0YwKzgDtW0XxxtWQY30JQrLFTpN6gAYzpbCrVhiu5aCdy4mTDZIQ Acl58afvkax7ccZZ/mG4htjhAA== X-Received: by 2002:a05:6a00:114c:b0:6bd:b7c5:f777 with SMTP id b12-20020a056a00114c00b006bdb7c5f777mr188412pfm.16.1698342329654; Thu, 26 Oct 2023 10:45:29 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id i3-20020aa787c3000000b006be047268d5sm11822297pfo.174.2023.10.26.10.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 10:45:29 -0700 (PDT) Date: Thu, 26 Oct 2023 10:45:28 -0700 From: Kees Cook To: Justin Stitt Cc: James Smart , Ram Vegesna , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] scsi: elx: libefc: replace deprecated strncpy with strscpy_pad/memcpy Message-ID: <202310261045.5D815BE@keescook> References: <20231026-strncpy-drivers-scsi-elx-libefc-efc_node-h-v2-1-5c083d0c13f4@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231026-strncpy-drivers-scsi-elx-libefc-efc_node-h-v2-1-5c083d0c13f4@google.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 26 Oct 2023 10:45:44 -0700 (PDT) On Thu, Oct 26, 2023 at 01:53:13AM +0000, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > To keep node->current_state_name and node->prev_state_name NUL-padded > and NUL-terminated let's use strscpy_pad() as this implicitly provides > both. > > For the swap between the two, a simple memcpy will suffice. > > 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 Thanks! I think this looks good now. Reviewed-by: Kees Cook -- Kees Cook