Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1268049lqt; Tue, 19 Mar 2024 19:49:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUpbRSpy8V7rsqBDgBa21HAypzbDrD+TCH1whhBmmS9ahXLCdLCCfZZXBWWSjNEA5efPIRqQZ4y6lcc+hazbPaizssrhff6Jk0GYsKKJQ== X-Google-Smtp-Source: AGHT+IFOWCksLrmzcxL0cxXPBwlr007G+b5NHrbjoxE16IkztIAHBDw95GlLyR35qIRXmijTE9JH X-Received: by 2002:a05:620a:3d1:b0:78a:1c6f:3718 with SMTP id r17-20020a05620a03d100b0078a1c6f3718mr1819482qkm.76.1710902995653; Tue, 19 Mar 2024 19:49:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710902995; cv=pass; d=google.com; s=arc-20160816; b=mGRaPKnYfsAREiVrb0Q5GHHzutcZ203AkxNBPZd1hjWVT/06Ol9ZK722pYUWSe02SD N0eKBgOxfgqBtNF+OrxoXTKgis8v7jdaSYws6EpITKAdTM2eWCKQevX8jUPx4bgwYC1R 7KGj5p1O0TprVD6NJ02YnnoBgSn69JtHBBCyfzsxmWKQGb63b7nuJWnDJlKtk2hTd18P J5m4Wq6voPsTUjP2hgR0iItlS5xhhDvvRQKImLfxGMaknO16ge/CnKKh64ogH09SiQ34 VFdgA4wwGJ24XdoKY4yuErcfUBX9rcKyzIZAMMgGy47SsoIYuQHz62aoSyM393l2UoIo n4IA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=g6fFauTTG4W/mn5n1JHyH5xPf3JyfWAj7waGLeqk3zI=; fh=4gfq0dWWzkaCvxF4d5c+cd/6FWVBWerdg67FWNT/Nzs=; b=DO3B5EFN+nAudqvqq/3k37oTKwB9zVme90b/woTltmZVPrUP/U9HJVYx9ZxCZIM+By d/jmuaexTdVeSxG6OWvzUJ/XWK08/7xk3I60pNzxAFJnzBeNF7zqx562UH7bD+XSklr3 R/YZ4Vo7VmKNRtX56g+xGCpW0wpStjbj1sRDMaC5rM08K//JcYiJ8Bb3Dhvd0GxxjgqI VZcsSsE2Rea8jxww5cPnPfyOnrfxKJlTJxu40UCRLPooMOc3sXMIt1Nmqpm6+WsjENbn dHcXb+aY+MwOdID+CcVmRn+WU7Eac2zAs/+PmYi73RrvucUYcfSHkPbDxvE1dbFHIgjF Yzxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DNghZSKb; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-108389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v20-20020a05620a441400b00789ec874eb9si1488398qkp.267.2024.03.19.19.49.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:49:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DNghZSKb; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-108389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 636C41C22CFF for ; Wed, 20 Mar 2024 02:49:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 308D817577; Wed, 20 Mar 2024 02:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DNghZSKb" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 046E71755B for ; Wed, 20 Mar 2024 02:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710902617; cv=none; b=M4MITTnaPyEEHtzBqAW1FsnIWOfwqMc07b6rWJeN4CpgbA2145a0a2hz8gvtVpNcOqMpDZvK0Qm0ttoRizc8mq0fLqClb0gsaOzn8SbqHfxe4dWrq6b+6YcTD6rOwgXXF+KaJoeg2UOIi/0xshixnmjyIGLxbY61HjUzllgMc7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710902617; c=relaxed/simple; bh=BfvY3vyLR6lXc/XFMQ0qkGmpXmDZdpmrBKNycQGWXU0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aRPC7/3nYd+Ek8hFkYMl64D5QX8PKgpf9x7ZCcSPzMbTppBjSd/85kMd6feDv/HfOmd6W00XMHGTbzxtJl6NqKMoBzLKU/kW5ii9VdrJoot+9kjSmfhxgQJ3QuxM5XeNH0NVmfVTf1etxuRLm6+t6ZvzDda9Kj5K203lbIdLf24= 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=DNghZSKb; arc=none smtp.client-ip=209.85.214.181 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 Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1def142ae7bso43977185ad.3 for ; Tue, 19 Mar 2024 19:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710902615; x=1711507415; 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=g6fFauTTG4W/mn5n1JHyH5xPf3JyfWAj7waGLeqk3zI=; b=DNghZSKbb+nZ0jz0xHSDiD5ILl/k+Ymy5cPumn3vg3ENIJPXDjGM8oT2zqARxNpjpN BdeIiQLHOv6dwQS/xgbzEZWWW1X95qJ21PHWv9umLj0jFP+oGanOucQPpo8hKvtNv+uh mIhUqnPr89pk5Ytrk4+KXdQUGEJnBm/Ayj/E8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710902615; x=1711507415; 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=g6fFauTTG4W/mn5n1JHyH5xPf3JyfWAj7waGLeqk3zI=; b=xTLXXixBgkrTnRSnrpYlA6s7ZYGdu9O31/7cg/m87QfTAOXdZfnDsJAXxqKxUxS+s2 LTyXladjqEtCrF2Lz1Z9N9Rjn+AUYcjktS9STl8DMcw0fUSHzCbLAYMrtMPraaopQT90 9pqCk7izuXItGdTm7iM3UGsWzzLMF4wlgSlAoyep90p2Lnl+iMIS1rSyWPoD1yoFjyV+ SpMP+WvQRQbh25LMJLuixnNmR+m1xJO2NUn9whs/syA4pa0i7Bi9kKQca8Jinp9q7q2M aJGOh771/t2MS5TyNiwwraXvJvMtivbQ1VKNSnR6k4z9QD9OIM5eswHKaJowrAZTWTNa zrHQ== X-Forwarded-Encrypted: i=1; AJvYcCUZZLW/ohvcXCpyNZh6nzNYKmXgpbXQX1C6GSX7kBjGegocY62BRrA9Osy/UhL/vyiJJtUCUmlmErtGmn+0l3Szm+2T+Gi//8HFZKqC X-Gm-Message-State: AOJu0YywSaS/Uub+w/+pn+ykJSSNy1fEkT5ZmaXUvqas1pVg4tb2jR9X MNlRaCZVb25yPGB+LBygv6CRXpchvfMXyocU5zZuG4JDjmHYx2fCRFNUWMQBbQ== X-Received: by 2002:a17:902:7798:b0:1dd:ae5b:86f1 with SMTP id o24-20020a170902779800b001ddae5b86f1mr15575726pll.29.1710902615342; Tue, 19 Mar 2024 19:43:35 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id e12-20020a170902784c00b001e0501d3058sm1548080pln.63.2024.03.19.19.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:43:34 -0700 (PDT) Date: Tue, 19 Mar 2024 19:43:33 -0700 From: Kees Cook To: Justin Stitt Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] usb: gadget: mv_u3d: replace deprecated strncpy with strscpy Message-ID: <202403191943.942C08892@keescook> References: <20240318-strncpy-drivers-usb-gadget-udc-mv_u3d_core-c-v1-1-64f8dcdb7c07@google.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240318-strncpy-drivers-usb-gadget-udc-mv_u3d_core-c-v1-1-64f8dcdb7c07@google.com> On Mon, Mar 18, 2024 at 11:31:53PM +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. > > Let's opt for the new 2-argument version of strscpy() which guarantees > NUL-termination on the destination buffer and simplifies snytax. The > NUL-padding behavior that strncpy() provides is not required as u3d->eps > is already zero-allocated: > | u3d->eps = kzalloc(size, GFP_KERNEL); > > 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! Reviewed-by: Kees Cook -- Kees Cook