Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1267948lqt; Tue, 19 Mar 2024 19:49:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhLtjQWN9KFDmQ9YS0B4Bau3QXdu3/xyiyXHmvsxCAjyjJvNbbID5hudAMbjmvRSBRYf/yPvKDdu3yjled0/G7/hRm4UzibTSFn/6rsw== X-Google-Smtp-Source: AGHT+IEd6jP0t2TGMXoMGuFv7Vji/l2MV04gP+8DHlQQqSpjHbe2PQG+Tduj1Vwmzrs3mhHm2uYe X-Received: by 2002:a0d:d795:0:b0:610:f83e:1f67 with SMTP id z143-20020a0dd795000000b00610f83e1f67mr74708ywd.36.1710902968918; Tue, 19 Mar 2024 19:49:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710902968; cv=pass; d=google.com; s=arc-20160816; b=qeIXbvFNIeiMW5McdQ0fJ7WP5z+hGm7bBC2x9WSCUwTqTPiPQ3XxY5n5238o1pgAVH IxFctDvXeCOknjILdDtjrmNcIfJJWycTDZXmE3HoQtC/bGFkmZ+EOh4JhWnFhLufpXpP 6rKVRrTH6aUHHIrmSqXQ2kj3PBXyfRKkD4APHfkKdVDvATwoyJ2rDzffa/rYDK+Es5kF C9K9oT6nT869nbz5sFa+2FtVuYXZE3v/rx+70/Pq/Oj8nNOinYPmoFTlyXZZ8hKtn5R6 5s6M36IiVITkcTBf8Fvvx7uSNlVla36spDhref08/iaWZY143d8ySJuQu+y9wROgj2OP i77Q== 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=Gl3MfsEQolD8Nt3URRB4l+12pLmNtTMn/BYm+Iehbxw=; fh=sTOCqVBnJazyN2SC+Y+kh3cFk4t/TmAxbSWDujhdqII=; b=sxTgI2F1wa3T5M5iFU9q11EurUdAx/d6vOAMPaox4NO8W/Y890jSwVTR22H3hYfnj6 SP6rTBTuYKmGr+gSDQKfjMSp8jcwnvlep3H5pjKug30E12yVe4soyQ4gte6ocYjPyYGh P7mvVo6IPSCBHpX7Zsm4d5INgsO9Wy/ROSsg+P3bjmpf3VoRl3kCqM9fG6q84X8f5vuz hsgMYYt5kvPjkMAbeXok0mOv8Qd9TgZhLBseT05GBYzjSGgyhR5t/Nn1HJ58LnNmb+Sg V+rDiEZCbCzs9aDPIYjirN+3B+sVBabkXm1Vmatq5Y0HcTe0Xf02QM8RkQZE+7rnhG7x 9k7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nkgsiLel; 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-108388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108388-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 d6-20020ac85d86000000b0042e64683096si12904196qtx.699.2024.03.19.19.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108388-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=nkgsiLel; 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-108388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108388-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 8052E1C22CC6 for ; Wed, 20 Mar 2024 02:49:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8BB613AE8; Wed, 20 Mar 2024 02:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nkgsiLel" Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 9D839125B2 for ; Wed, 20 Mar 2024 02:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710902597; cv=none; b=T0mFE/0RbfQs9aKrNgE4jHYwz/iv3GCqpmgKOsw+sTWjn0SFMHWvIST9S3gXXHxsHJewAg1AcYDaYkpr7t4v20EIoWOJuVFR8wn+g8V+4Y3FiX4vCucWmN9YasBK8doBakdqTGHG3v/DcPYkOO9RtkJjEqWTcUBKW85jdeswa1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710902597; c=relaxed/simple; bh=78eAdLWYs8wwvbK9BciCfjdMEEABSf7QMrNnx8TDQLE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bdao2IzZuPCU2CoQTM3TPa3Dz7EkbWyKnJ7oXFOaiYheDmLsiFSX/T1BrdP6BlIR1lLYnKzK/yg9dgfSoXvKCF3PNRvs8q9qLhoVj5EvIV6Q9l+77ZKRO/aJPwPgKDKsrPbVOG6CnQB+dU2HnuQk7HGzfYXJsI1qCkFKS0h/DTA= 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=nkgsiLel; arc=none smtp.client-ip=209.85.216.49 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-pj1-f49.google.com with SMTP id 98e67ed59e1d1-29f6f8614c8so2654824a91.0 for ; Tue, 19 Mar 2024 19:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1710902595; x=1711507395; 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=Gl3MfsEQolD8Nt3URRB4l+12pLmNtTMn/BYm+Iehbxw=; b=nkgsiLelw4DZ2MxSXVM4r6LHpFDe8V6cKCPp10ab6I/n2/F5fzdoy7s9bSKDSScqu1 eua2yOKwjTc+nkBRKUK3GGB6Anv/LiOxDzbE4/EBzZW9eILuXDhH6kRdp7n+/lq3F9BW KUs1/6BOGjRfmaDQ9PPWka9IiG6CqzXMRLDIs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710902595; x=1711507395; 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=Gl3MfsEQolD8Nt3URRB4l+12pLmNtTMn/BYm+Iehbxw=; b=IzE2/zgKACF67mrsSXpjVja7wZh8jfxskF8LoQZdUNasIchZ/DthDi8X6nDc7k4Byk LJ3lcJDREgDfg2RdBBCXV0gw/qhux88uooSoG3+xiQ6HCOewZl72VLFMuAOUrCFs6bbM nnJTRprb948etg85HNE/34D6rYm/UwrDwueBYgIKcC7GrzEjRaqfaTu9NdMF1DQsN3lu RNURjjOsGeEP6RdFgVkM7NDAzZLvHWS7ek+CVuvCvkRyqDrhpRN5dOPKYngZDZL3SXsQ OFHB2khEWjr42vW3f9MxZFxQvh2yhLV1kpXQ0m01JauaatW9v7x7ZuufjQEcjmpgLRf7 5M+w== X-Forwarded-Encrypted: i=1; AJvYcCUj7Y4K/zWRN/QONgbFhHvth/s5AfEJG85Ati2iTnpGbuVPhYbpvfM99Q5UOX1HQsPQKkJxS/jLSXMfKGzYVyTTN5M80ZpwARjxULlR X-Gm-Message-State: AOJu0YwXvgeaS+wZznqxZBP3Z2VR0Rbe0AEirCkLykksbfERKgyMEawK 95D/wUfFzvvl4c8sOGhe4v3D9McXRwrZzfRjkh0vhmxJgIpiQC2Fo8tFp9EBEg== X-Received: by 2002:a17:90a:430b:b0:29c:6c79:7e92 with SMTP id q11-20020a17090a430b00b0029c6c797e92mr4024106pjg.19.1710902594823; Tue, 19 Mar 2024 19:43:14 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id x8-20020a17090a164800b0029de1e54bcesm364496pje.18.2024.03.19.19.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:43:14 -0700 (PDT) Date: Tue, 19 Mar 2024 19:43:13 -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: u_ether: replace deprecated strncpy with strscpy Message-ID: <202403191943.3F041A01CB@keescook> References: <20240318-strncpy-drivers-usb-gadget-function-u_ether-c-v1-1-e8543a1db24a@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-function-u_ether-c-v1-1-e8543a1db24a@google.com> On Mon, Mar 18, 2024 at 11:10:34PM +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 use the new 2-argument strscpy() as this guarantees > NUL-termination on the destination buffer and also uses the destination > buffer's size to bound the operation. > > 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 Looks correct. Thanks! Reviewed-by: Kees Cook -- Kees Cook