Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3978444rdb; Wed, 30 Aug 2023 11:34:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFH7Hm1x3Mfjl+px090abjV0FHw3XwR+bvxFopbifb5Zcqskp6NJWr2qqRB5dojGwfZ4qD X-Received: by 2002:a05:6a20:9146:b0:13a:43e8:3fb5 with SMTP id x6-20020a056a20914600b0013a43e83fb5mr3627931pzc.51.1693420475616; Wed, 30 Aug 2023 11:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693420475; cv=none; d=google.com; s=arc-20160816; b=uBt7XkPeo408R7WAgfnCvAUwGeap9yLnX7QlzjvwGbwnwwHkWljbPjZl84tbVFT054 06AxOCCP1IxuSjacka0C1NjpO7aIeBbmXpFFXbMT97t7GeI6ohdcsbViVTvm3UaGEg3w OBllZEZ/Rj13z867TGXujnM+LuNBzXkf+XuD00e+IseM9crZdPtEnxXuDgZGtUmF/Bl2 OEHij/Fm4t6Prhn1gZP/Bl9IpRYTd+5r8AFeVd+bm0YuGjyTeE9LeBs1vXqIQDQgttht Jp/HgBp4KBl+HMhdgKozGugBgfRDKxXDRc+kZI71yeGUKx6oyFNVxE7BhOHTt/gt2n26 10/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+CFHTRDewVdnK8OrD5TrZ50kQYQ3rXzCo0CKBhJFbdU=; fh=nOhpvWtzVmvTDhgdpCWra+nDWwohWfgPP8SWhm6gG50=; b=INB70VyNJl/t3xwEqRTeRpVRD80PePYx5eP6s3MAzleAfzotGWvydZLnRTShwyu0aa q/0CXkcbG3jPkwxDSzaT0cr1AYJcVf54heefnGYI/VNNEh2IPPIp4/CSIlOIUjljMpYI hsKqzln/hkbl4i5jcpjNFGK3SDD7ff93mJ4cZWGffrbdogTUU+ExS56eZA9QsSoa2/XU TvlFYMh8n1Y9XM0Q6l3TPu6A4Q7HgGR2rIXyM6cV/pWC0z7lwMhK1YXwmgv7RJI2Nq1f C5eXL7DOWdxnYNoFxiIO92zo19qpK7aMtv7GvOjBjrnEeEFwJTrGjLf0kUFBbsx2rWBb hEGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b="PP/NbdlY"; 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=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a056a00228200b0068bdb809b5fsi3061645pfe.163.2023.08.30.11.34.35; Wed, 30 Aug 2023 11:34:35 -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=@yandex.ru header.s=mail header.b="PP/NbdlY"; 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=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234905AbjH2Jov (ORCPT + 3 others); Tue, 29 Aug 2023 05:44:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbjH2JoZ (ORCPT ); Tue, 29 Aug 2023 05:44:25 -0400 Received: from forward102c.mail.yandex.net (forward102c.mail.yandex.net [178.154.239.213]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387DEE9 for ; Tue, 29 Aug 2023 02:44:22 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2a2:0:640:b6bd:0]) by forward102c.mail.yandex.net (Yandex) with ESMTP id 386596003A; Tue, 29 Aug 2023 12:44:19 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id HiMaKXADYqM0-H0VTu0gE; Tue, 29 Aug 2023 12:44:18 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1693302258; bh=+CFHTRDewVdnK8OrD5TrZ50kQYQ3rXzCo0CKBhJFbdU=; h=Message-ID:Date:Cc:Subject:To:From; b=PP/NbdlYmbCb8Gby8AoCKfBjnUg4CJGpxr/RsfFmppPkWEdIN+CSnvu45C6oygdzd V4lT3TTUa1lLxKyWfG/nqvgtbej3yTNKC75dSZV8ZxcmRmLUaLK80qJfQUicbHFsJ9 BsnIMBaIYjJhPBwrSfJo7VDp6mJ7FW79Qpq5aujs= Authentication-Results: mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Felix Fietkau Cc: Kalle Valo , linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: mt76: fix clang-specific fortify warnings Date: Tue, 29 Aug 2023 12:43:49 +0300 Message-ID: <20230829094353.234713-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS 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 When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following (somewhat confusing due to absence of an actual source code location): In file included from drivers/net/wireless/mediatek/mt76/mt792x_core.c:4: In file included from ./include/linux/module.h:13: In file included from ./include/linux/stat.h:19: In file included from ./include/linux/time.h:60: In file included from ./include/linux/time32.h:13: In file included from ./include/linux/timex.h:67: In file included from ./arch/x86/include/asm/timex.h:5: In file included from ./arch/x86/include/asm/processor.h:23: In file included from ./arch/x86/include/asm/msr.h:11: In file included from ./arch/x86/include/asm/cpumask.h:5: In file included from ./include/linux/cpumask.h:12: In file included from ./include/linux/bitmap.h:11: In file included from ./include/linux/string.h:254: ./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] __read_overflow2_field(q_size_field, size); In file included from drivers/net/wireless/mediatek/mt76/mt7915/main.c:4: In file included from ./include/linux/etherdevice.h:20: In file included from ./include/linux/if_ether.h:19: In file included from ./include/linux/skbuff.h:15: In file included from ./include/linux/time.h:60: In file included from ./include/linux/time32.h:13: In file included from ./include/linux/timex.h:67: In file included from ./arch/x86/include/asm/timex.h:5: In file included from ./arch/x86/include/asm/processor.h:23: In file included from ./arch/x86/include/asm/msr.h:11: In file included from ./arch/x86/include/asm/cpumask.h:5: In file included from ./include/linux/cpumask.h:12: In file included from ./include/linux/bitmap.h:11: In file included from ./include/linux/string.h:254: ./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] __read_overflow2_field(q_size_field, size); In file included from drivers/net/wireless/mediatek/mt76/mt7996/main.c:6: In file included from drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h:9: In file included from ./include/linux/interrupt.h:8: In file included from ./include/linux/cpumask.h:12: In file included from ./include/linux/bitmap.h:11: In file included from ./include/linux/string.h:254: ./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] __read_overflow2_field(q_size_field, size); The compiler actually complains on 'mt7915_get_et_strings()', 'mt792x_get_et_strings()' and 'mt7996_get_et_strings()' due to the same reason: fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole array from its first member and so issues an overread warning. These warnings may be silenced by passing an address of the whole array and not the first member to 'memcpy()'. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7996/main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 8ebbf186fab2..53348dd80c3b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1386,7 +1386,7 @@ void mt7915_get_et_strings(struct ieee80211_hw *hw, if (sset != ETH_SS_STATS) return; - memcpy(data, *mt7915_gstrings_stats, sizeof(mt7915_gstrings_stats)); + memcpy(data, mt7915_gstrings_stats, sizeof(mt7915_gstrings_stats)); data += sizeof(mt7915_gstrings_stats); page_pool_ethtool_stats_get_strings(data); } diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c index 46be7f996c7e..81f316ddc111 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c @@ -358,7 +358,7 @@ void mt792x_get_et_strings(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (sset != ETH_SS_STATS) return; - memcpy(data, *mt792x_gstrings_stats, sizeof(mt792x_gstrings_stats)); + memcpy(data, mt792x_gstrings_stats, sizeof(mt792x_gstrings_stats)); data += sizeof(mt792x_gstrings_stats); page_pool_ethtool_stats_get_strings(data); diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index c3a479dc3f53..2405ec1a663f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -1192,7 +1192,7 @@ void mt7996_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) { if (sset == ETH_SS_STATS) - memcpy(data, *mt7996_gstrings_stats, + memcpy(data, mt7996_gstrings_stats, sizeof(mt7996_gstrings_stats)); } -- 2.41.0