Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15725104rwd; Sun, 25 Jun 2023 23:57:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7X0/0oZd+AJXip7LCE1tWLY80v7JThxXR4YDb/g7Z8EpqkEU+xA3AQwSlgiPwqe5LM3Jo1 X-Received: by 2002:a17:902:c40a:b0:1a9:b8c3:c2c2 with SMTP id k10-20020a170902c40a00b001a9b8c3c2c2mr10055426plk.37.1687762635327; Sun, 25 Jun 2023 23:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687762635; cv=none; d=google.com; s=arc-20160816; b=YF5rMrF8wOpUC5VPk1vuakTfPKYFjMWUZRcO4WrI/eGWAPVHrbUoqfcLtLntRDiIDp 7m/tSBCrzSYXPt+NSnRiHXh6+n+L3lziH7j11+vCcjDvq86rUvfbeVONp66S/ilo24/5 /U/kkdcxkTWF2WHbETJMG79Cf2LMvPmditjYjfnMW3yTE5xJEM/fUa2Nw3v5zwoUzyBh K8DLIlm5jT7IttPWho9qeKcAUfX9VCcFPfSK6a9VATpxNnE4dY6azPWGhXycfaDiHV8i gREiivSZVzLi5j8BGatWKgtLHLmbR4OtTTjUSZXM71fgkZ1K6gdTqd+ISyAxONEP7FEm hy2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=KjqDZn3lJ7Kgt+uw5GaBXsy3/mcmdXSrFa1NBqXg2gw=; fh=Htuv7hREpoUqw8ckOABdrhLwufI0YKj6Bb9oGtHt0cw=; b=AKxn1bBRbdTZ8C3aWp+ZTwXY2vv0NVWkJH3HHFw4JVtTXE2V7lU2OCrywVnh7+6j7f 28iLf1RTwfjSLUDGKJZX3eHGyRtn6xCjHnCAABqRhZ53bWlIGTGs07ThKIisMId5Nvkc aOTHYEwv2Jp7rzTJfDifOxoCJody4DjfXZf55WOPDYH90uk/8dX4og7hf+M0G6pbeZaN TScRfa/3I7HR561VVarkzGneuH0Y4kNiFFlcanaYZlZuoIYVCJ5OKUmzKSXr7m+ZB5fH P+UyxSvZ0sfaco74aHOG+9L5rCE39Zu8ICD25DAG00ZQd/KfUhfZ9HRDMwrMpBqOfUQf cktg== ARC-Authentication-Results: i=1; mx.google.com; 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 t13-20020a170902e1cd00b001b66810a96asi4190371pla.176.2023.06.25.23.57.04; Sun, 25 Jun 2023 23:57:15 -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; 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 S229671AbjFZGvw (ORCPT + 58 others); Mon, 26 Jun 2023 02:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbjFZGvr (ORCPT ); Mon, 26 Jun 2023 02:51:47 -0400 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF897E7D; Sun, 25 Jun 2023 23:51:42 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-9891c73e0fbso538417866b.1; Sun, 25 Jun 2023 23:51:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687762301; x=1690354301; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KjqDZn3lJ7Kgt+uw5GaBXsy3/mcmdXSrFa1NBqXg2gw=; b=fNY3rk2rI+y7KhNmyEEZoKPGKzy3gGh4ZQYRPP0b+vpQ5jwyxIc10D9i+Rm71dXTyH z9f1gjNpCEw80BBrC1TzSTTPtsMT6D+Kkls7YX+oJOVW75XWABkZcHy5sWEtDbKPQW5d /9N1mouapMqFfaG8jb8t8eaesPJ7/Tc8PBxqKXct4ACoVPSLMfg0g4xGSXSUsNja0YjZ /kEpoAbv51RhWZSLli2jP2pSJcaAE//NVsQzqbKPrq0rOYDjIZCpYxAhGkHMv+3+7RMQ gfp1IP1nrzopk4awpnYltMKcm8AR46HwepdItY+mXBvXgBpf4Ug0NYGRPfz67gGN7zLP 617A== X-Gm-Message-State: AC+VfDzwR7yGVj/S870jahKNlya48uQ57M23ZFZDbv7nzy7AQo0vzGEU i6jQyjuJD65W0nILzz7mUuk= X-Received: by 2002:a17:907:3f87:b0:977:d660:c5aa with SMTP id hr7-20020a1709073f8700b00977d660c5aamr26059155ejc.31.1687762301096; Sun, 25 Jun 2023 23:51:41 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id k19-20020a1709061c1300b00988b6d05f33sm2846673ejg.223.2023.06.25.23.51.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Jun 2023 23:51:40 -0700 (PDT) Message-ID: Date: Mon, 26 Jun 2023 08:51:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/2] carl9170: re-fix fortified-memset warning Content-Language: en-US To: Christian Lamparter , Arnd Bergmann , Arnd Bergmann , Kalle Valo , Kees Cook , Johannes Berg , Shiji Yang , Nick Kossifidis , Christian Marangi Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230623152443.2296825-1-arnd@kernel.org> <7c4622e7-d7a8-ae5d-e381-f726cb511228@gmail.com> <24986b5e-5cd1-4cd5-aff3-b5eab2c0fdde@app.fastmail.com> <3bb839fe-1dfd-57f5-a5b0-be5adac57a4c@gmail.com> From: Jiri Slaby In-Reply-To: <3bb839fe-1dfd-57f5-a5b0-be5adac57a4c@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 23. 06. 23, 19:15, Christian Lamparter wrote: > On 6/23/23 18:05, Arnd Bergmann wrote: >> On Fri, Jun 23, 2023, at 17:38, Christian Lamparter wrote: >>> On 6/23/23 17:23, Arnd Bergmann wrote: >>> >>> Wait! I want to point out this funny thing is happening in ath too! >>> >>> https://lore.kernel.org/linux-wireless/TYAP286MB03154F9AAFD4C35BEEDE4A99BC4CA@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM/T/#mf1b8919a000fe661803c17073f48b3c410888541 >>> >>> And that patch got NACK by Jiri Slaby because like me he suspects that >>> this is a compiler bug. >> >> FWIW, that is one I don't see with clang-17 or gcc-13. The one I'm >> addressing >> here is the only thing I see in ath wireless with the default set of >> warning options, though this driver does have a couple of others that >> are unrelated, when you enable the source data check in memcpy() by >> building with W=1. >> >>   In file included from  drivers/net/wireless/ath/ath9k/xmit.c:17: >> In file included from  include/linux/dma-mapping.h:7: >> In file included from include/linux/string.h:254: >> /home/arnd/arm-soc/include/linux/fortify-string.h:592:4: error: call >> to '__read_overflow2_field' declared with 'warning' attribute: >> detected read beyond size of field (2nd parameter); maybe use >> struct_group()? [-Werror,-Wattribute-warning] >>                          __read_overflow2_field(q_size_field, size); >>                          ^ >> include/linux/fortify-string.h:592:4: error: call to >> '__read_overflow2_field' declared with 'warning' attribute: detected >> read beyond size of field (2nd parameter); maybe use struct_group()? >> [-Werror,-Wattribute-warning] >> 2 errors generated. >> /home/arnd/arm-soc/include/linux/fortify-string.h:592:4: error: call >> to '__read_overflow2_field' declared with 'warning' attribute: >> detected read beyond size of field (2nd parameter); maybe use >> struct_group()? [-Werror,-Wattribute-warning] >>                          __read_overflow2_field(q_size_field, size); >> >>> so, what's going wrong with fortified there? >> >> Kees might have a better answer to that, my best guess is that >> the one I'm addressing stems from the confusion between different >> union members. >> >> Doing the randconfig builds with the latest compilers, carl9170 is the >> only one I see with fortified-string warnings, and there are a few >> dozen other drivers that I see with W=1, including one that affects >> all wireless drivers. > > Hm, question here (to Jiri as well). Do you think that a workaround patch > for these > sort-of-obvious-but-compiler-bug-but-failed-to-make-a-simple-reproducer > would be OK to get NACKed? In my case, I fiddled around with it and > replaced the > the cc_ani memset in the following way: > > |        memset(&common->cc_survey, 0, sizeof(common->cc_survey)); > |-       memset(&common->cc_ani, 0, sizeof(common->cc_ani)); > |+       common->cc_ani.cycles = common->cc_ani.rx_busy = > common->cc_ani.rx_frame = common->cc_ani.tx_frame = 0; Nah, you are still changing the code for the compiler. And espectially this one calls for troubles later -- when cc_ani changes. Again, work also with compiler guys, they are usually helpful. Both in helping to understand the issue (from the compiler POV) and provide a fix/workaround. Even this carl9170 change looks very bad to me. While "memset_after(&txinfo->status, 0, rates);" means exactly what it does, those two memsets barely. It took me a while to understand what is going on and that it is the same. Don't do this. Perhaps we need memset_no_check()? thanks, -- js suse labs