Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp732101rwd; Thu, 15 Jun 2023 00:59:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eoJ80FYBdyT5CaNbu/Pe/XkTE6ntD2Ipo8yCzCI4uCLYx4fdSEm2CFM6da1MsXZnYry6/ X-Received: by 2002:a05:622a:40e:b0:3f9:d266:7be0 with SMTP id n14-20020a05622a040e00b003f9d2667be0mr4253655qtx.23.1686815991109; Thu, 15 Jun 2023 00:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686815991; cv=none; d=google.com; s=arc-20160816; b=wirquntXayl4HXmdEhmrzPA5p6X9xk6wSwwfcLKmd2AK0wBUb/WuYfubVVoV6PM2HJ jsmq0tBMl+dbwhGZtg42A7nIysqr/R3to3bCxEo4dRIxXy+qI9bgWgfpHjIXw7EwcUY/ EN+NuETsQDUsm18VtauoGAEtKFatn+F9BOAIina2uS71dZDw6VWoFAVILjrxz7UZde7Y /62COdSJcbrLbn3tvlQVvOc5EZGijVZhXlcD7oXgZdvmwf4V45/d/e49esN1BmX7zVpv bSePtzNHxESuyskGvV+/N+S1l78oHrDO7smUCYkmpfErzYI6PO/nigX5op/APajOCtVZ E1Fg== 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=C0rZhfnxtfh9HxBTmyIjc/7X97n7twa2L0IapXr0czk=; b=Kec83t/X5hc+ML1E+7QgC9DRW7jSFfV3MsaZ3yMwLY0xFTKvVoCvSse1/wr9vji/pj rc5LC3ZGexgioasKr8QTNTbo+dSP9The3hdppPT7sGWNpbq3cCe8vbGNaSxMbnzVRisv cW0teEsxZ3myh5oImzVHGlLVg1go7HHuts6KyYc3QlyRTb0SmLSo5dipHqTElrHHEeL+ Yz4ARDEs86dU6uehV9xtl3hm5HOLaK5gY6RllqLcUPXD0Yvl+C5BEVsihiMi6zwHHdOb xuZ1Im4bqH017LiOw7dvaMLtoiCyyAOhHj01zWChwrtr2sFPIyqGhYGziqGbmhoh8wMC jrCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u1V90meL; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t29-20020aa7947d000000b0066032c675dcsi1534389pfq.3.2023.06.15.00.59.43; Thu, 15 Jun 2023 00:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u1V90meL; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245139AbjFOHrE (ORCPT + 61 others); Thu, 15 Jun 2023 03:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245137AbjFOHq4 (ORCPT ); Thu, 15 Jun 2023 03:46:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1323910E9; Thu, 15 Jun 2023 00:46:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F0D8608D5; Thu, 15 Jun 2023 07:46:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB15C433C0; Thu, 15 Jun 2023 07:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686815212; bh=IYlGV4RSFt1d+yJKhbAG5tqp/00HgK+xkhxKb186tE0=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=u1V90meL+tFm5DgrOOqjff/GVRY8lAfJVHrtgcGEo5XQtqy/ZCHtQOYyWPE63jiuJ 9CNXltDmqldmCvhlH5x6+RmrMm6dDN7MLsKmSj4/yBFdOjR1uM8zlaVYXkJK6t62Qy rjAslRDTddXv05RVMtLk3Zjx4o4mkKsifBNiu9F72ey5saEm2Nx+CdE0nFcualSGwy rRFKTGhSnG40ptlAcczJshlIfErMUeXwsAAhWTQsHac9wEQRSDl3yDmwZ8Mzo1zJDY ZznhnEYIjjq6lvQ+QyGW6AvgSzK1asOeDEaS09cYninfqEB4cN3VAqQ7gbu7vO92e4 up/2YEOgDeIsg== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: wifi: mt7601u: replace strlcpy() with strscpy() From: Kalle Valo In-Reply-To: <20230613003458.3538812-1-azeemshaikh38@gmail.com> References: <20230613003458.3538812-1-azeemshaikh38@gmail.com> To: Azeem Shaikh Cc: Jakub Kicinski , linux-hardening@vger.kernel.org, Azeem Shaikh , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Matthias Brugger , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <168681520789.8111.6922167548842826655.kvalo@kernel.org> Date: Thu, 15 Jun 2023 07:46:49 +0000 (UTC) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-wireless@vger.kernel.org Azeem Shaikh wrote: > strlcpy() reads the entire source buffer first. > This read may exceed the destination size limit. > This is both inefficient and can lead to linear read > overflows if a source string is not NUL-terminated [1]. > In an effort to remove strlcpy() completely [2], replace > strlcpy() here with strscpy(). > > Direct replacement is safe here since DEV_ASSIGN is only used by > TRACE macros and the return values are ignored. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > [2] https://github.com/KSPP/linux/issues/89 > > Signed-off-by: Azeem Shaikh > Reviewed-by: Kees Cook Patch applied to wireless-next.git, thanks. 7edbd53a58a8 wifi: mt7601u: replace strlcpy() with strscpy() -- https://patchwork.kernel.org/project/linux-wireless/patch/20230613003458.3538812-1-azeemshaikh38@gmail.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches