Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3978339rdb; Wed, 30 Aug 2023 11:34:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAOF/VvmRuMAaaM1m4ID+YWjK3d0mPFqX2J9RkdQHlyQhgYBKmgXFIvpVEpT6S28WRCf5i X-Received: by 2002:a17:907:a04c:b0:9a5:b630:a92a with SMTP id gz12-20020a170907a04c00b009a5b630a92amr2071324ejc.8.1693420465788; Wed, 30 Aug 2023 11:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693420465; cv=none; d=google.com; s=arc-20160816; b=oj96MduMGJ3ztBwKYd1JfcWQ43NcLicWElbOo2GOP0F5b5j9S+/fIoEKkgzHvrydm+ c/5C1OA+QhTHDIBzkT/JmJfZho4CDdLmSdyZVdu3Wv5IWG4bbEHAvqE62bywQEN/OtfV didL2FaYK3ekZNzeWp75KXbxT5pYjw8MYqu5e+ARaQ1fySNefftpJwIz2mQO8kREh+LZ Aczi/I0aEDIy4roqsnp2lq/A5pEg/GsTkhNqmPdft/K1VHSAF5JAZ8JlElc73ALCh0ME vu911F/lEnyvx2plUm0ezVMINa9gtX2B6EFF/BZq1wkHjBVpVHS6Ci+GAb2qcbtfaFXc gBCg== 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=iun8to3kLI2HhKyj5ymed280mCcD9zZY+oEF5+Zmcvg=; fh=bixGMbm+egYiDoN4jqyKKD+O/VFSH7t4BSlaO/rV0GE=; b=UgcoUM6k0nlCwE4RmIyRWHEdfxSmPMuLAqzUyZiLe7KxOq716gzO5w5632/k2lMQcy jOtUW7/WJwKi3mz+TEqeP6CYHW/lx/O+IMkjgvp1IZQLflWx/4YWY9mg6wasHBEL8jWB A89UMZ6x3tX0S95GLpd42Z8jl4kBYrzRWVpm1Sq6pDtHHpuo4HXqcnn0GMNZzAVJ7QOc LJuit1JE7NJQI1Y2x2hFgNCNGFP0wphO4P4yPuFzBSH3Kxw4JcHqoSpsutiO0qkyPLD9 WOc19HBGlzttiSbgO6xuadQVvAS/xUdy1A3hHQtXCLeBtGd82/sSup4OL/8zM8XqkRss 50kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=WmJ8vDap; 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 z5-20020a170906714500b0099bc62f3629si7788829ejj.567.2023.08.30.11.34.24; Wed, 30 Aug 2023 11:34:25 -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=WmJ8vDap; 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 S233380AbjH2JmM (ORCPT + 3 others); Tue, 29 Aug 2023 05:42:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbjH2Jlt (ORCPT ); Tue, 29 Aug 2023 05:41:49 -0400 Received: from forward101c.mail.yandex.net (forward101c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA6A9E for ; Tue, 29 Aug 2023 02:41:45 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2c91:0:640:dc79:0]) by forward101c.mail.yandex.net (Yandex) with ESMTP id 8A8BF60079; Tue, 29 Aug 2023 12:41:43 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id gfMqUWADeuQ0-ZRq6T4Ip; Tue, 29 Aug 2023 12:41:43 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1693302103; bh=iun8to3kLI2HhKyj5ymed280mCcD9zZY+oEF5+Zmcvg=; h=Message-ID:Date:Cc:Subject:To:From; b=WmJ8vDapkfwjk3FRDDBmRnIRcwhfjG/V0fjgyDyz9eTMktYTe/c2BPCrrGHd6YKiu 9ndvIGmlvWUAEQWoJXRXjlDowM76eXVLMeNWL5RrRxcz60Wd5pOmVXfOMdZ5MFPChV GGSCP1OFeLd17nHkA8Q/ni0MwjeLN0rmIMt4A4OY= Authentication-Results: mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Johannes Berg Cc: Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: mac80211_hwsim: fix clang-specific fortify warning Date: Tue, 29 Aug 2023 12:41:01 +0300 Message-ID: <20230829094140.234636-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/virtual/mac80211_hwsim.c:18: 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); The compiler actually complains on 'mac80211_hwsim_get_et_strings()' where fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole 'mac80211_hwsim_gstrings_stats' array from its first member and so issues an overread warning. This warning 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/virtual/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c index 1f524030b186..f5a0880da3fc 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim.c @@ -3170,7 +3170,7 @@ static void mac80211_hwsim_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) { if (sset == ETH_SS_STATS) - memcpy(data, *mac80211_hwsim_gstrings_stats, + memcpy(data, mac80211_hwsim_gstrings_stats, sizeof(mac80211_hwsim_gstrings_stats)); } -- 2.41.0