Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp319779rdb; Thu, 5 Oct 2023 07:02:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPkbC4USy6MkZ8pMq7wD6RV651UPfle1Z+qEHjCe3Fz9TJJM/Molt5guE9E+QUnt3lMMd9 X-Received: by 2002:a05:6a20:4423:b0:15e:71c9:7d47 with SMTP id ce35-20020a056a20442300b0015e71c97d47mr6784296pzb.26.1696514537891; Thu, 05 Oct 2023 07:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696514537; cv=none; d=google.com; s=arc-20160816; b=JumFfAIj7DXkdHpgJbnqUx3p9jecnEatMpjOh8/Zqd6sA7aSN434Vq6JinGfup3ltS a7C7Aihsml3IpEt27s0tXg/2KT1OqNkGPCHGu+wfe63jCnGqdjJktPOjuLhALznYaXJN 0GU5Lp2NQyrmCxSbbiNQ5csBQQOx/HrZdi7yLKdsqa4r0bIXLYB72CuhX07+Q935Ztr7 p2Yp1cCOqe+xyTzWbR64sqH/ZfVCKHTt2ypCz3nwIHLfVyWPhhWogy6Zr7bnH8z6JLNf gemSncfiIY4co8nYIkohrLN/x31IJAaOSEhWTfzpj6SIH8mvcn+KTc2u81/S5M3qOCI9 2xEw== 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=+qTkmLJbkNoH1DEt071Z4Lj6n0F0uZ101JE698BdGD4=; fh=QqTh9hOX8IwXqkUbGhvajwtXnjGlFDMGrHT1mt1b6oY=; b=KR+eoXqADUhINX6gg1ToW/e0liZ8360Athcj+VcOtdPFz/pus8/Vbwh/aY6IO3nmaZ i63v95ssiBYJlOg2eb+ZBgr6A8Yn4L3dIuUEVrWpEbDfeGowLtPNJd82AbnFRB0pja1l NbqdsqcTo+w6s6BJYGD0W3ZCahtwpQ+AVhElB8G3cWIjp5m6QQgWbT5onodvhZB9pzWM eTyLnZjXHpHrGLwZxCyQEOXvf0EdaofH7Dth5gM0TBfhzQSvLypy39Ovrpt7HunwtzH+ 9/gl3Ki6tsOi2ARQ6xMcQ4WVIK+OQYugSXc1BjuDeMXsGtdk2HSla1t6G0QFVMGMptI7 Wcpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WnudJe1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y17-20020a056a00191100b006901387b09bsi1476303pfi.344.2023.10.05.07.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WnudJe1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 6C9678073DE5; Thu, 5 Oct 2023 07:01:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbjJEN6V (ORCPT + 99 others); Thu, 5 Oct 2023 09:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbjJEN4T (ORCPT ); Thu, 5 Oct 2023 09:56:19 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B434693 for ; Wed, 4 Oct 2023 21:55:50 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3aec067556dso373438b6e.2 for ; Wed, 04 Oct 2023 21:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696481749; x=1697086549; 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=+qTkmLJbkNoH1DEt071Z4Lj6n0F0uZ101JE698BdGD4=; b=WnudJe1bYEmqh6BpAvVgjxOCcYYaNDC48bvl4Byn5OG7VzY1wDDFbdVqvBnGqTpuhF WYKtiSLBdwoIgYq3DAFJ6DETUj260vaG5bDR/pkhwhYGvWG/zFka+8jgI2lW40HI33V0 PlDmcbMs9G11G9G7y5FP2QcJXRBwgxWKUFu8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696481749; x=1697086549; 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=+qTkmLJbkNoH1DEt071Z4Lj6n0F0uZ101JE698BdGD4=; b=mrzEJlCybaeosBJh2sYqEMSDMMZQSJB4y5oZAv469j5rA0TAYd33zOdqwPjCPGXS2g WHDnnylbgyIXI0AU19iyM9FZzggX0A60U/9bPV2zl8eK6siqmlal0O90aPCujINFgQTD 1sERmVPwNQZrLNK7n9EjK9lse1EE1bsaJ4K/nyW/GD1Vus7d19WuwyVzvDQdPIQ9obkS Dgmw2f1R2o/+zxvSvELXmDiZlqkv5+4NrGqv5+oOckZ3vIxdWgZUO5QWM7g2AH1cpecZ S+F36Az6ZM7RmHqSbZdAY4cRUsZbBUPs5Ub2EF0Va0WHikmW1c/mC/5caZLbe5J+3cmk LOwQ== X-Gm-Message-State: AOJu0Yz0eqFvV+ixaI78eFaeX7Q2TkLbYWg0iHy1D5X5R8iL2iXyNe9h sEFFu22vJttcRO8R+JgGUdWTlA== X-Received: by 2002:a54:4e8c:0:b0:3ae:5e0e:1671 with SMTP id c12-20020a544e8c000000b003ae5e0e1671mr4451630oiy.4.1696481749435; Wed, 04 Oct 2023 21:55:49 -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 g12-20020a63be4c000000b00577e62e13c5sm369420pgo.32.2023.10.04.21.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 21:55:48 -0700 (PDT) Date: Wed, 4 Oct 2023 21:55:48 -0700 From: Kees Cook To: Justin Stitt Cc: =?utf-8?Q?=C5=81ukasz?= Stelmach , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] net: ax88796c: replace deprecated strncpy with strscpy Message-ID: <202310042155.BDF8674@keescook> References: <20231005-strncpy-drivers-net-ethernet-asix-ax88796c_ioctl-c-v1-1-6fafdc38b170@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231005-strncpy-drivers-net-ethernet-asix-ax88796c_ioctl-c-v1-1-6fafdc38b170@google.com> X-Spam-Status: No, score=-0.8 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:01:58 -0700 (PDT) On Thu, Oct 05, 2023 at 01:06:26AM +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. > > A suitable replacement is `strscpy` [2] due to the fact that it > guarantees NUL-termination on the destination buffer without > unnecessarily NUL-padding. > > It should be noted that there doesn't currently exist a bug here as > DRV_NAME is a small string literal which means no overread bugs are > present. > > Also to note, other ethernet drivers are using strscpy in a similar > pattern: > | dec/tulip/tulip_core.c > | 861: strscpy(info->driver, DRV_NAME, sizeof(info->driver)); > | > | 8390/ax88796.c > | 582: strscpy(info->driver, DRV_NAME, sizeof(info->driver)); > | > | dec/tulip/dmfe.c > | 1077: strscpy(info->driver, DRV_NAME, sizeof(info->driver)); > | > | 8390/etherh.c > | 558: strscpy(info->driver, DRV_NAME, sizeof(info->driver)); > > 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 Yeah, this looks like the others. Reviewed-by: Kees Cook -- Kees Cook