Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1374973rda; Mon, 23 Oct 2023 10:32:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1iGVAKqFrrpUS/FNMBSzBGXza5SZaC5f4A0Nxqn2V+mfNezGlNj2VVkt1pOGrfT+z7Qwc X-Received: by 2002:a17:90b:1d09:b0:27d:48e1:d1e8 with SMTP id on9-20020a17090b1d0900b0027d48e1d1e8mr9012150pjb.13.1698082330691; Mon, 23 Oct 2023 10:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698082330; cv=none; d=google.com; s=arc-20160816; b=c2mGHaqZZwVSkaF/kYq/f8NdakEmk5PbkoXLudhICt6Ek04aRWCmyOJwnY2VK2NaoU vskf93lzCFxKphHY2qo8qRIxa3lQHjsdxTOeguP9KbtfPjdw0GDJvosyeqDVfBgfYfjy 29DdZfAn1pd8aAGTukvglwHHKtfPjcsfR4hD2wjxiZac/ZZ3ZI8H4G4cW727QXiHxXJf DGFfSjZiKX4qMHr7OYqtZJYTFsjoPKjzLmG3PeD2iuh51IeFLJPqcNQXRZWm4Y4Dk++W d3Cb3Cyz3zl20yW/74UCALDPVXrMwwFVGgsgLrdbzBBo+LM/bfgvIJXFBarSMHK6ipUx EVRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=Vqi+/lMC0al5Iu33/ZSoH1lcQM+f6R/GvYeHK6gxMec=; fh=/5Ctfx2ilDt7yiT0kTR9x2aGarm1cw3mbdZUCnlD9Bk=; b=I2r7xRAydLwdkVh4M8PwUVHriKFpIGVRuMz4EAe2amPzSvkQ7k5dmYguUvJPlnhSys 8gY7zBGC7ZiVxGm5t5GaYv6Xjzak/DbJHdpq8XachSs7KsJv7oNSCwD33JKcksfocIJe KSma8rseABfP8eyuD1f0fmq1eH/KizNCdMSyQehsT0bMaN4rvCxd1PdgOtTDOfnMyKYs woP0ZbiusvkFsGxpuqB03Cr4PJUqpRPWjTUT3nxr5l8DpSI/LkDSdduawm3JOXe+eCt6 7Vj7KUcLdnuOBIYp6Ih0uTsaMr2TrSrLQbEJY4wMEab90swdRo7UNn7WXeRbMbc+El7x oVEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MPUoyZa3; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ds18-20020a17090b08d200b002683f507990si9263757pjb.109.2023.10.23.10.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:32:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MPUoyZa3; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ED5908074699; Mon, 23 Oct 2023 10:32:03 -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 S233879AbjJWRcC (ORCPT + 52 others); Mon, 23 Oct 2023 13:32:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjJWRbv (ORCPT ); Mon, 23 Oct 2023 13:31:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8905F2D60; Mon, 23 Oct 2023 10:30:59 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B0E0C433C7; Mon, 23 Oct 2023 17:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698082258; bh=3TVGdnVGcjFnlnGB5RwJ0L+ZqBdcRdweUO0HpE0MTFs=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=MPUoyZa3Qp5zScMi+2cX7NuMz9mMUZRZJ6YnI8kshNRcjLzGrLVfnxG0zObPo5iBQ lhsEJHd4UCNHKEkKR5t46wMvgZPBusQ4wh19yE+52Jk8fW9gShWzRw43upFRILdJmR pDhRs2nB5OCFyWJPdEsYy+wdOPNxgAW2WhyxppYEMklYIUKLivoNWrXqkzrMcJTQXJ +4zzVbIpqgv0lMDhDMTmuBCtEUJUGgizvdx8IC8ijEH/rgKK3q58y9Xh+N7jcBlW1r CZDb6dvQtpg+hKll0ZkyuBfK6n8f67891ab8cOZ8Oqi3/9rsOt4zaaXABP3xsJCM9+ UsQrWo/p5F23Q== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [v2] wifi: atmel: replace deprecated strncpy with strscpy From: Kalle Valo In-Reply-To: <20231019-strncpy-drivers-net-wireless-atmel-atmel-c-v2-1-52e46fbea083@google.com> References: <20231019-strncpy-drivers-net-wireless-atmel-atmel-c-v2-1-52e46fbea083@google.com> To: Justin Stitt Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Justin Stitt User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <169808225560.695306.1625165630823500076.kvalo@kernel.org> Date: Mon, 23 Oct 2023 17:30:57 +0000 (UTC) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 10:32:04 -0700 (PDT) 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. > > We expect priv->firmware_id to be NUL-terminated based on its usage > with seq_printf() and strlen() in atmel.c: > 1420 | seq_printf(m, "%s loaded by host\n", priv->firmware_id); > ... > 3884 | if (strlen(priv->firmware_id) == 0) { > > NUL-padding is not required, which is evident by the usage of a plain > strcpy(): > 3891 | strcpy(priv->firmware_id, "atmel_at76c502.bin"); > > 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. > > Let's also replace hard-coded lengths to be `sizeof(...)` for buffers > that the compiler can detect the size for as this is less error prone. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [2] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [3] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt > Reviewed-by: Kees Cook Failed to apply: Recorded preimage for 'drivers/net/wireless/atmel/atmel.c' error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Applying: wifi: atmel: replace deprecated strncpy with strscpy Using index info to reconstruct a base tree... M drivers/net/wireless/atmel/atmel.c Falling back to patching base and 3-way merge... Auto-merging drivers/net/wireless/atmel/atmel.c CONFLICT (content): Merge conflict in drivers/net/wireless/atmel/atmel.c Patch failed at 0001 wifi: atmel: replace deprecated strncpy with strscpy Patch set to Changes Requested. -- https://patchwork.kernel.org/project/linux-wireless/patch/20231019-strncpy-drivers-net-wireless-atmel-atmel-c-v2-1-52e46fbea083@google.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches