Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp410282rdb; Thu, 5 Oct 2023 09:17:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJUfiYWhsWAjV5B8tzegwDTOvjdeKldUeU8vk7rukW2ZVtNrz1qbdT+KktWr9yjj4/KU3W X-Received: by 2002:a05:6a20:3d85:b0:153:73ec:fe67 with SMTP id s5-20020a056a203d8500b0015373ecfe67mr6414266pzi.19.1696522659596; Thu, 05 Oct 2023 09:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696522659; cv=none; d=google.com; s=arc-20160816; b=MNVKmnk3xsDt7Wnk3gv8h2MHLtIUuKVjVC2VQbhMPNwPYmDffxRhSuh52CwaHCP/BL NQPdAku89ccUUraMFYvP3W2oCJerC8fqDwcwrizGHHPRTDm2uju4jblBgCZdZOXc+RBP sX4hnYMfJp4PxF/qJnIVFWHxcTp+k5qGcsFS01RKtuifJgj5lO+eSY2KQ6PpgtMDxe6o k4myyt0+09I4TMPzxQqNBxxPn+EWLPc4ePSQQYpyNXoWdIJ/nraviHpfFyxbcx+H4MVp z3MEj0J0+KP+mQF2pbX+VXqhFRAYHLmZcALJXJ2EujfCByeJSkzWrW9kpHVeitE0Ml3e BGfA== 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=0kNnoNX+VycKJxCFVsIPAbCtAe5boObmTDcjKlCDp2k=; fh=kdTJokG/wUOnM2MbmUtczmhsdVIcylAi5NhewChJzoQ=; b=kGgagqd+StNZLa5CEgL6G9RzeWa4up13h/bxJNYYjo9S5ttWLYQR40GXuz0VYzTgmJ l/uI+W29IqOfRd5nj8vXwXHv0vMzKgc9GF+BYYHTLAQFA0f0h/IdQWM3Nti06TlxGTwQ li1YRYQFSdf/NvvTV75VPVBrCcyxBycV//1lIIKPwrF9gXUw6raMj77ro0kFjZLi2aVK 5btGbfqmiMIUnFV1p/26GP54HJbG0hqCeGbbr/7Bizo+yrIv0WMhwkv8B54bXshZzld8 Oi5RMVewwZlb/kmWHp8r7xv3nHQ+vVo6ogKtfWQn1+LejUgkLNXhtsNdMmRWpt9JvtrE sZbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="i4L/3Aj8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l63-20020a639142000000b00584aa817597si1714153pge.101.2023.10.05.09.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="i4L/3Aj8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 3379080C2444; Thu, 5 Oct 2023 09:16:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbjJEQP6 (ORCPT + 99 others); Thu, 5 Oct 2023 12:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237601AbjJEQNJ (ORCPT ); Thu, 5 Oct 2023 12:13:09 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E4812A for ; Wed, 4 Oct 2023 19:58:43 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c737d61a00so3547075ad.3 for ; Wed, 04 Oct 2023 19:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696474723; x=1697079523; 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=0kNnoNX+VycKJxCFVsIPAbCtAe5boObmTDcjKlCDp2k=; b=i4L/3Aj8ygTjSUp9/p9XDWPSBBKIRjWIC5psTSo5nX3ZwidzXnhiCBlczgVVI2zjpZ 9XWh+QJWSXuMiPpDWrlgZpJl/Z8tuZxCXx3YMi3JB62A4zXJlhkRATn11k3SCHNFLDbf Tk89LjB5wR/1YdxTpbiNiRU0F/Rvj9JM4j2NY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696474723; x=1697079523; 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=0kNnoNX+VycKJxCFVsIPAbCtAe5boObmTDcjKlCDp2k=; b=W6XzE1yZIhRp44jPBIXFASlU1WycAAMg+VxZxeR9T5PLRPAyP0z/hntTVnGh4SZfSi 0VjhWXPuvGFSggKdh0WunLwNmoGOZgZgGFM7p41S0ch3uQlFkHYQFYrFCmQd/OHmSl2n LoW3sb63XBySfAIWuxy7nEcP1rJXRQXDnd83Hf95Hy899FAJ4mQDSr6bGDw6teXX50M+ GR3OURZ7Yd7fht6OjSiy8YwUCNrFjGOZeKNEnQ2VONX6yKbyxcIvuZ2UA8XBmw6f3zWX qK5OCuXt1kCvcznEehzWZrS9AH1/Cj6dfj4UhboPkgk6+gUD31yUXvn5adcKnxTHV1iL sgZQ== X-Gm-Message-State: AOJu0YxYGzNmggpcrYtNMBiPjJI64co/dKkkGI1aOPpoGLZL+Shn3e0X uOp14tUJoOELxRMpaOwI0DG2xA== X-Received: by 2002:a17:903:1cc:b0:1c7:2661:91e1 with SMTP id e12-20020a17090301cc00b001c7266191e1mr3864559plh.15.1696474722969; Wed, 04 Oct 2023 19:58:42 -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 p10-20020a170902eaca00b001b8a85489a3sm313410pld.262.2023.10.04.19.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 19:58:42 -0700 (PDT) Date: Wed, 4 Oct 2023 19:58:39 -0700 From: Kees Cook To: Justin Stitt Cc: Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] can: peak_pci: replace deprecated strncpy with strscpy Message-ID: <202310041958.12F8A261A@keescook> References: <20231005-strncpy-drivers-net-can-sja1000-peak_pci-c-v1-1-c36e1702cd56@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231005-strncpy-drivers-net-can-sja1000-peak_pci-c-v1-1-c36e1702cd56@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:16:33 -0700 (PDT) On Thu, Oct 05, 2023 at 12:05:35AM +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 since card is already zero-initialized: > | card = kzalloc(sizeof(*card), GFP_KERNEL); > > 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 Yup, this looks like a standard direct replacement. Reviewed-by: Kees Cook -- Kees Cook