From patchwork Mon Nov 13 19:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 164624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1431038vqg; Mon, 13 Nov 2023 11:36:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFo8XoaIZA3a8BC2IiRlG2R9+EWcIJyP9MiSCbJ+nRllbscCzJcSSw0rzyvCXWkuNI7N/UB X-Received: by 2002:a05:6a20:7487:b0:181:1fc8:c5de with SMTP id p7-20020a056a20748700b001811fc8c5demr6405571pzd.43.1699904176872; Mon, 13 Nov 2023 11:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699904176; cv=none; d=google.com; s=arc-20160816; b=JqZ3jhlzR4QJttgav9xvOn1szqUSjUO1Xb2ysEd7BQkvUZx0v5uWgkx75E6qq8d7v8 gQUdM3+w0jdQu9C/9/mcRoPsVeQ5U90lbWwGQbJzo6s0AWdEVBAsMlg/W34cYNY+FkKZ ZJL5xrGOU3BY9oarKuZV1skvoXClF8DDJpc5qsiXYhwLEB0aXI/qsyifNT4nUAy904nR 6mh6jYSo8vNfKuNz6hdwx22jEpLY5DZlti+C2HvWdhqgbJB0dWWwEkhEZhL8r3PISMRu 6+EdagUB0Sg2kcsp54LP0A3+9MM04EEScrDx0ZeqARsJG3ulmgJr5TTeN3MI/JYVPu0H iGrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=40hB+Vpn/6GpiVsyjtTjM01fhpeaLSfq6TbHSBYnzQk=; fh=SyouFAmwMigJeyK5YV45RVBGEGd70MmGOfGvhgpjxGU=; b=t2EmHrw219FbcjdqWbnJpkNunumM+sQ2UVfH8/jqhMIJbBBwxpmS7C+5YNkpQykDAR NWm3MrbAAUtimNWzUpQC8UA+dIZIz4dg2vAnixlPJ/qfZWIRcZYTF5M1PGDEU5yeUvI4 467qU5x4W4drObrJ7cBf2VLrXQ6ABIPbIlvkl0Fb4Tq0MBz5/Ld7sLA8n9hNgGuOVNcw 5WlsBP7jWl6S1Qs/ld0BjF6EVWohDKHl5SNd5vxcp/6NoCHexmG5vrMgRnRv5MzkTv8R a5E0eyZJkyQ7yi5UuCeeh9Gwuq5eKqY9q5fvMchHh/H7vg6JttEMEyUXkdkB0mUCEslg Hjig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EJ1+KQXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id m3-20020a056a00080300b006bf537ce976si6664077pfk.260.2023.11.13.11.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 11:36:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EJ1+KQXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-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 agentk.vger.email (Postfix) with ESMTP id 87E6A804C666; Mon, 13 Nov 2023 11:36:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231811AbjKMTf6 (ORCPT + 30 others); Mon, 13 Nov 2023 14:35:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjKMTf5 (ORCPT ); Mon, 13 Nov 2023 14:35:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A279D6E; Mon, 13 Nov 2023 11:35:53 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CA8EC433C7; Mon, 13 Nov 2023 19:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699904153; bh=JPhKLghvGw7StGSXf9vQqvISbNEZ2A3Ksd7jEA2P43c=; h=Date:From:To:Cc:Subject:From; b=EJ1+KQXzxNB13oEzr4f1dnR5SV6Q3UTECdIxoz9WkICpSJpIgrKPkhzr2IlCYHnrl ls21xmpHW6HgBsgZ6vsn/hIuWP8E2abKEU7PXKZTWPONhiUMIxTHVmU0fHTsdIIdz4 ZG4kN5xOngj/ORNWaxeM7KqfBDDB4XusRxMNntI6JxAyxLnQXen8W4uz5o20SEgKhu IzHB3IJaezfn8C+b1EeNgEcs2Lrs1a2i+P9zkC0ZaPDyjv6lGQobg9idKCMYHr+mJZ 11COhrXciddhSaH69A5JSSfpNzUvtTCma09sbn+669i7+aelA/kMEmcbuhF71Cfk5I M0nqlCewMnUzw== Date: Mon, 13 Nov 2023 13:35:49 -0600 From: "Gustavo A. R. Silva" To: Ping-Ke Shih , Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] wifi: rtw89: coex: Fix -Wstringop-overflow warnings in _append_tdma() Message-ID: MIME-Version: 1.0 Content-Disposition: inline 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 13 Nov 2023 11:36:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782478722326071556 X-GMAIL-MSGID: 1782478722326071556 Copy a couple of structures directly, instead of using `memcpy()`. This addesses the following -Wstringop-overflow warnings: drivers/net/wireless/realtek/rtw89/coex.c: In function ‘_append_tdma’: ./include/linux/fortify-string.h:57:33: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] 57 | #define __underlying_memcpy __builtin_memcpy | ^ ./include/linux/fortify-string.h:644:9: note: in expansion of macro ‘__underlying_memcpy’ 644 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ ./include/linux/fortify-string.h:689:26: note: in expansion of macro ‘__fortify_memcpy_chk’ 689 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c:1585:17: note: in expansion of macro ‘memcpy’ 1585 | memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma)); | ^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:2703:37: note: at offset [5714, 71249] into destination object ‘ver’ of size 8 2703 | const struct rtw89_btc_ver *ver; | ^~~ ./include/linux/fortify-string.h:57:33: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] 57 | #define __underlying_memcpy __builtin_memcpy | ^ ./include/linux/fortify-string.h:644:9: note: in expansion of macro ‘__underlying_memcpy’ 644 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ ./include/linux/fortify-string.h:689:26: note: in expansion of macro ‘__fortify_memcpy_chk’ 689 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c:1579:17: note: in expansion of macro ‘memcpy’ 1579 | memcpy(v, &dm->tdma, sizeof(*v)); | ^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:2703:37: note: at offset [5710, 71245] into destination object ‘ver’ of size 8 2703 | const struct rtw89_btc_ver *ver; | ^~~ This helps with the ongoing efforts to globally enable -Wstringop-overflow. Signed-off-by: Gustavo A. R. Silva --- drivers/net/wireless/realtek/rtw89/coex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c index bdcc172639e4..b842cd9a86f8 100644 --- a/drivers/net/wireless/realtek/rtw89/coex.c +++ b/drivers/net/wireless/realtek/rtw89/coex.c @@ -1576,13 +1576,13 @@ static void _append_tdma(struct rtw89_dev *rtwdev) if (ver->fcxtdma == 1) { v = (struct rtw89_btc_fbtc_tdma *)&tlv->val[0]; tlv->len = sizeof(*v); - memcpy(v, &dm->tdma, sizeof(*v)); + *v = dm->tdma; btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v); } else { tlv->len = sizeof(*v3); v3 = (struct rtw89_btc_fbtc_tdma_v3 *)&tlv->val[0]; v3->fver = ver->fcxtdma; - memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma)); + v3->tdma = dm->tdma; btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v3); }