Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp453888rdg; Tue, 10 Oct 2023 15:51:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWzSjxWIxthUhq6qVQI/j0OjzG8IpdEmxAw5d3I28BbWqDJwYVOpVh6k9gzxj8PKR326ZU X-Received: by 2002:a17:903:2307:b0:1c6:21b4:30bb with SMTP id d7-20020a170903230700b001c621b430bbmr21525440plh.15.1696978319546; Tue, 10 Oct 2023 15:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696978319; cv=none; d=google.com; s=arc-20160816; b=ciW3mVgMFVXj2vBj5q1rciYU+SsbP+9lhZjDA3DRtGSDzU71p15jO0z9KwhwIBOoFG uYXM+0LBfny+BfdQAWdLRL4nbvwtQCvDkTqOVC0JCXH6DBqhWCTQrHa/rZ+YWAPlhB9t z4f1Ls5i9WQFnHHohZcERpYKv94JyQVJmZtqoShZ8t6ya6PAUvHHiVo4BZVgXftiTVf+ evs5LeQVO0sZXfqK0s9XIvRw9QXIYJItOECpI2TmACKhlduwYbHI74JIj3jsjFpY1SFS /S5ClB169MdFEretOh9HRacvZAjEsKJ+QHcJsBCZrVCVxgDfDJzuRdpj8Wldlbj5djxt vqSA== 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=ubmSWqN4/oZllpUx9ALydSh0+D44g/WNY6GMZGog46U=; fh=mqfmTQR4d2qsagPIu7w85CL6NV37Lg84uua/PQimBj4=; b=V4t1FdO3IDyts9BuXdFZ20gqRpCNmjKUlaZ2Azr8vd4t1dr+x/I4IxINN1mjxjgUjP AhZNXEdOW1LrbUpmCgvOg57ZqTaBzP6cm9R45bA4vnn/aREXMUUwroXWb+lUK4gIIkLx Ht3EPfTfuvxwlYLXIAv4H2LtL3DQAh1IKy8T8mWuFtmXAwGXllyALuXlOSajPvRssDxE iavmXV3SHCOVx4fby7v9pw+yOfofkUwzEF3Gw1R1FxqqHh4QdC6VZ3tieqNS//WF4HjJ f2BXqaueSlLDY6HRtSA174uGrmzu+eP1yprolaemFWHnxFP938zUPfOjVkAGl0XUTZbJ hmYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EBH9NEEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s12-20020a170902ea0c00b001c62e2ce6a8si420539plg.449.2023.10.10.15.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 15:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EBH9NEEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 50514803E5BF; Tue, 10 Oct 2023 15:51:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344107AbjJJWvi (ORCPT + 99 others); Tue, 10 Oct 2023 18:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344271AbjJJWv3 (ORCPT ); Tue, 10 Oct 2023 18:51:29 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB117B9 for ; Tue, 10 Oct 2023 15:51:27 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c871a095ceso46644145ad.2 for ; Tue, 10 Oct 2023 15:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696978287; x=1697583087; 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=ubmSWqN4/oZllpUx9ALydSh0+D44g/WNY6GMZGog46U=; b=EBH9NEEA8EE5LFojIFp3SBe11Rw4H5/IkJ3Ub+81fEPvHifX2B6Z52hZwmR3BedT0x rRqZYSerhF4YBiXmSLt6RF6a2GjRiUcmgBE995B/BaSGMeNbqr1cbns0UJndxMsr4eXh nUlpujl9q/oMlglA35FpUNHgWLQNTmGXkXtNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696978287; x=1697583087; 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=ubmSWqN4/oZllpUx9ALydSh0+D44g/WNY6GMZGog46U=; b=i0w8ZnnzKaJfIhWIMbY+c8bdnncfgVfh/B8s24mcbTdHKema1BEh894mtlQ9l42sWl eunaz7HsAcSwacdqqL66DJd2taWM+u5ADJ2o18ThQsnfin2AzIhX4YT28+u76MD4V29A RIEkB1FEhADrNt0PCwquziR3IqY3ahgmXeptNgUdTR0yXG7DR0MXtWH5uQFfpJZmgyj2 KXmSitzU3vb8pEC4ag2QcwA9GlfY14/1pW/swos2NOYCPpjJ6vttIiFi48YPm8XqkGvX irXyvVMH9iP5+7nbd2qMdiHsNtMoonwBd1GNZzYjIQrsIK2T+cRFfttiG1KCfc7l2rHu mhoQ== X-Gm-Message-State: AOJu0YyOCClbIRPQyaHaJBeTxZoetLBXj8hOcLEVnU2yJpjjlnxB5+K9 U9bwd30/XrwRWB7elS27Kmfn4g== X-Received: by 2002:a17:903:2445:b0:1c7:74a2:5b56 with SMTP id l5-20020a170903244500b001c774a25b56mr20177500pls.43.1696978287254; Tue, 10 Oct 2023 15:51:27 -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 c20-20020a170902c1d400b001c3be750900sm12325562plc.163.2023.10.10.15.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 15:51:26 -0700 (PDT) Date: Tue, 10 Oct 2023 15:51:23 -0700 From: Kees Cook To: Justin Stitt Cc: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Haren Myneni , Rick Lindsley , Nick Child , Dany Madden , Thomas Falcon , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] ibmvnic: replace deprecated strncpy with strscpy Message-ID: <202310101551.DAE933A@keescook> References: <20231009-strncpy-drivers-net-ethernet-ibm-ibmvnic-c-v1-1-712866f16754@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009-strncpy-drivers-net-ethernet-ibm-ibmvnic-c-v1-1-712866f16754@google.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 15:51:56 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 11:19:57PM +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. > > NUL-padding is not required as the buffer is already memset to 0: > | memset(adapter->fw_version, 0, 32); > > Note that another usage of strscpy exists on the same buffer: > | strscpy((char *)adapter->fw_version, "N/A", sizeof(adapter->fw_version)); > > Considering the above, a suitable replacement is `strscpy` [2] due to > the fact that it guarantees NUL-termination on the destination buffer > without unnecessarily NUL-padding. > > 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, this looks right to me. Reviewed-by: Kees Cook -- Kees Cook