Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2086994iof; Tue, 7 Jun 2022 19:16:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ8olEgJOm+Y3zD3oeiOizN5tQtO6RYitYLd+1QPYaly7jS9b65vp9ID2zf/lBfuz15OA/ X-Received: by 2002:a17:902:8503:b0:168:8fbf:61f7 with SMTP id bj3-20020a170902850300b001688fbf61f7mr2678177plb.87.1654654582607; Tue, 07 Jun 2022 19:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654654582; cv=none; d=google.com; s=arc-20160816; b=PVQ1KgIsVSchSEdYqhLODQ20y6I9E5pWp7iBgQRXPBRYmuC+bMa8jwy4ueg3F95JJr ky6zcSuEQ/RxwtOFa6xBmOO6Ox8OBcml9+xo4IhsUSZk/Uwl8gg9gZU6kGeAco8jOrwq Hf/skbI5t5IBrMqHzVP8tfceDzL1qB/wipliiUBjo6UXLV74CHhQYHNSkj2hgahXi6aw A2xJ1NohB6cQQ+bUKWaCZFyWhQ64YSvfkddoYL30VPz9d5gBke1WLP6qTqoSNCZSovGy Mu9M6TUaPsTEs9bYJxu7kk0u59xhSR7O4t+kkyEuBKrM22KKhz8iv5P9vVMLhzB4Oarl OU5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hsTGdaJfCWTSNmpJsjja9acho7svN5yyAOm6L46kzCU=; b=vImMQJ/wCYrCMjq9badHF4t/DN+Gpx+CqV3WKvH2j7gL5BXaumfuuniKRw+IT7/TPx 07XRm6Cqt/YfwrpDrPbplEayU0/989j6w9GjZYbs5xUgBM+wa/SLpf9pqpqSlD2b84tG 9AYKO455IP4Vclx+vm5gbUT5aNovR0ZVaB5BWYDABD5qBfpmyUmV5nZv5hAS3fHAEc9o RuScdLyFQuGXRqaQfGdOlPfKTaxmMPRKQoZdvfj/2k3xAvFU+iEly5rFJrt9YJEHU0ZP U3yGPTvtEf1xwjaY4xZQZ+eO4cVdp4UaWbnT+tFvnwIQ3gO1E+2nIOu+CV0f2Rhblbzu xD1A== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t17-20020a170902e1d100b0015cf4f37e4bsi22843697pla.610.2022.06.07.19.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 19:16:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92C4938A29C; Tue, 7 Jun 2022 18:59:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344004AbiFGPXN (ORCPT + 99 others); Tue, 7 Jun 2022 11:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343998AbiFGPXL (ORCPT ); Tue, 7 Jun 2022 11:23:11 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB2EA3B57E for ; Tue, 7 Jun 2022 08:23:09 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 257FFidN003178; Tue, 7 Jun 2022 10:15:44 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 257FFfLo003176; Tue, 7 Jun 2022 10:15:41 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 7 Jun 2022 10:15:41 -0500 From: Segher Boessenkool To: David Laight Cc: "'Michael Ellerman'" , Bagas Sanjaya , "linuxppc-dev@lists.ozlabs.org" , Anders Roxell , Arnd Bergmann , "linux-kernel@vger.kernel.org" , Nicholas Piggin , Paul Mackerras , Yang Li Subject: Re: outside array bounds error on ppc64_defconfig, GCC 12.1.0 Message-ID: <20220607151541.GG25951@gate.crashing.org> References: <87mtepns81.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,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-kernel@vger.kernel.org On Tue, Jun 07, 2022 at 02:23:25PM +0000, David Laight wrote: > > I don't see a really simple fix. I tried clamping the size parameter to > > do_byte_reverse() with max(), but that didn't work :/ > > I had a quick look at the code - it is somewhat horrid! > Not really surprising the compiler is confused. > Although it shouldn't be outputting that error message > unless it is certain. No. It is a warning message, and the compiler should output it for all code it finds suspicious. The conditions for this could be improved for sure, but it is and will remain a heuristic affair, so using -Werror with is is akin to self-flagellation. It is not an error, it is a warning. The correct response to it when you determine it is not an error, or even you do not want to deal with it now, is to ignore it. Which -Werror prevents, one of the ways that that warning flag is counterproductive to use. > Could it be re-written to read the data into an __u128 > (or whatever the compiler type is). > Optionally byteswap the entire thing (swap the words and > then byteswap each word). > The do a put_user_8/16/32/64() to write out the value. > > I think that would remove all the memory accesses and make > it a lot faster as well. Yes, the warning sometimes fires for correct code that is "merely" next to impossible to read. It may well improve even the performance of the code if the code is rewritten. But it also may introduce new bugs, or anything else detrimental. It is yakshaving extraordinaire to do this every time a compiler warning points out something doesn't smell quite right :-) Segher