Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3169981rdb; Tue, 29 Aug 2023 07:23:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0LkwT0lUgZzoe4U1j2xWsel1eRhRVocGD+ysSCsIr5H6GUF/DkpJtjIy3Wjn4Nz3yzeOO X-Received: by 2002:a05:6a20:7354:b0:13d:5b8e:db83 with SMTP id v20-20020a056a20735400b0013d5b8edb83mr27492308pzc.9.1693319036604; Tue, 29 Aug 2023 07:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693319036; cv=none; d=google.com; s=arc-20160816; b=p5RMyGqHvFLqyJHPbHbxPxslbjosWrO44cgiTPV+VGno4+HXseU/KDr/bC7YopOuOS HqQGZeWJDT2gSIjKPcwZowWuD23R+iQHV8EbDSDN/JS7yAejum2UEh1iO5R1IGyYGxFv hXefFFIM1NtRrYmBu9/5YDuh0ytGMsSQEddn1n7fOqopb9rhTSdQyJwL5TaumpeeAvrt ye4ar8Ap5yu2EYPCdn7cWPEVTM9nSEGH/FfYhJUzf0xSUVf5sUJtGewWuz3i7/Qkj9Gg JuM/wxM3BRrFH/OTS2rE/1GPg6Q7fgrrDfemwYxhX5y4xqsB1EYuDGRYPHWBDFRoVeeS LV4A== 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=TULFX7+Z7pUy03rtnDVb+NbWu23gozgR/MVsH8BFwVM=; fh=MpR+s/veo62KMZn34kt5DXWoYGMPXud+WhR8SDFmBA4=; b=yXnvV1B7iNVhGdlbwS9hQJhaJqwm3BdW8Enx1wAjPZxNoSuz5vvpqbd3VYnr/Rp8on 7JkYwcEyZGUM0kikFhUgD1+6hZ8LgzJmRPxAPQJ/BtOvjkGU9g4bgkQOfZxCir88MADd tGRiLJm59Rxtb5Dpr89R9Ax3HS9ysPCvB+SNi5ob9CUXES0/no2JPIiLraj3Brwgx7Pi 02VRkhHB5iecpimqDrHL4rUK4uwgexhLEt0t2I2tLm6/btUe2aNWWmcPJN0pztIVgTHf 0w7dttkM50wUIg8D6/xZAu6sXmdR2ZGtx5nZ6uY3CCMHxW4yFOl5hsJK5RGayDzh4kv2 w59A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=suGFk1xs; 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 u13-20020a056a00158d00b00687bf09ec3csi10430413pfk.250.2023.08.29.07.23.55; Tue, 29 Aug 2023 07:23:56 -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=suGFk1xs; 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 S234743AbjH2Jjb (ORCPT + 11 others); Tue, 29 Aug 2023 05:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234739AbjH2JjE (ORCPT ); Tue, 29 Aug 2023 05:39:04 -0400 Received: from forward103a.mail.yandex.net (forward103a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C829E for ; Tue, 29 Aug 2023 02:39:00 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:1182:0:640:88e4:0]) by forward103a.mail.yandex.net (Yandex) with ESMTP id 3CF90463C2; Tue, 29 Aug 2023 12:38:59 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id vcMDOGCDb8c0-awYUss8i; Tue, 29 Aug 2023 12:38:58 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1693301938; bh=TULFX7+Z7pUy03rtnDVb+NbWu23gozgR/MVsH8BFwVM=; h=Message-ID:Date:Cc:Subject:To:From; b=suGFk1xsZinzUa2a6h887rEv1fiOToCOKxEJ0rQyKgLki/+f2qACdE+EBVWjQ3Ej+ bcouPfunC4SPmgq/6X/PmXBzOIJM56G29glw4fXW92gvUGYzCyzcypkg3L1qjAqepB wAZWmpkUmHL06MDxxmsAyrsFs0og53JKHA3lfkjQ= Authentication-Results: mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Cc: Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: ath9k: fix clang-specific fortify warnings Date: Tue, 29 Aug 2023 12:38:12 +0300 Message-ID: <20230829093856.234584-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, RCVD_IN_DNSWL_BLOCKED,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/ath/ath9k/debug.c:17: In file included from ./include/linux/slab.h:16: In file included from ./include/linux/gfp.h:7: In file included from ./include/linux/mmzone.h:8: In file included from ./include/linux/spinlock.h:56: In file included from ./include/linux/preempt.h:79: In file included from ./arch/x86/include/asm/preempt.h:9: In file included from ./include/linux/thread_info.h:60: In file included from ./arch/x86/include/asm/thread_info.h:53: In file included from ./arch/x86/include/asm/cpufeature.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/ath/ath9k/htc_drv_debug.c:17: In file included from drivers/net/wireless/ath/ath9k/htc.h:20: 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); The compiler actually complains on 'ath9k_get_et_strings()' and 'ath9k_htc_get_et_strings()' due to the same reason: fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole array from it's 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/ath/ath9k/debug.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 9bc57c5a89bf..a0376a6787b8 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -1293,7 +1293,7 @@ void ath9k_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) { if (sset == ETH_SS_STATS) - memcpy(data, *ath9k_gstrings_stats, + memcpy(data, ath9k_gstrings_stats, sizeof(ath9k_gstrings_stats)); } diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c index c549ff3abcdc..278ddc713fdc 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c @@ -423,7 +423,7 @@ void ath9k_htc_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) { if (sset == ETH_SS_STATS) - memcpy(data, *ath9k_htc_gstrings_stats, + memcpy(data, ath9k_htc_gstrings_stats, sizeof(ath9k_htc_gstrings_stats)); } -- 2.41.0