Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1111471rwr; Fri, 5 May 2023 09:14:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6smPQdpF/AyQQWBo+MLvGa3Lv/a258W2QQCrY+i+QbWnFqXrMciyniGFZ+jjrCtXUwb1vs X-Received: by 2002:a17:90b:4b4d:b0:24d:ed47:5dfb with SMTP id mi13-20020a17090b4b4d00b0024ded475dfbmr7250526pjb.12.1683303280161; Fri, 05 May 2023 09:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683303280; cv=none; d=google.com; s=arc-20160816; b=Ki2sC5ySePQmSTDQVTjuwsHRt65t7cGWcQexL1N1PBJOBFFL0h5sylWiJ6CbEU7eeM g4aP7v/a4mCVuw9iYSFYr0Yx03reHQssx6BGyVxtDBs9CviNAC0bdYjgmGZzs1im1Gk1 e7MStOjJwQzZoNdicvPSUEEW9wqgpija7caAuqogewYpcptklfJBng0UMGP6NohXGRB8 NYQ5U0LAr2T9ZIYTU8QcysOVo6naZMksDCECvPy6uoM0NHoxztyohw+7QVdzpFp02Yt9 5s4oIA+atbrEgzveSS3Dvhfk6kU8HJ/AFr4IbOuKotulmk1JytHvGDmOwzLgR512Fyfl FjZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=TZnLc9SdHGGnjpAvmCgLj/v9V5PMrpMvBUCSYIUFmvE=; b=M29acP4YLpQoiumfZODc4ZJSmyVIlUwp3JoWk10LK6OO9P3A597dwSaotYWSCg14sX P9fr+si0SWhanI2AoPwm78ddaGtXp+oFumqTTmkkZsBIThvwJ5lX2cvuRylnAS/KfUAI BfEOQEcMRbk/AoashCfSq+ZCI9HT28l6tbgkEdzUzkEDJ8vkh9JO2istBV5jwobXL1k2 qHv/RjdoLcWclTdZ+jSF1J2mFFIpW/GVWXVSR1GY2BM/8UNJ3tXnwdjPpN6C4WWcbR1r KGJmiTbYk0LP9Va0Er3ltMJeMjNh2Ib1dtpAMAPnUD6toI6kCVD92ecbzz8Uzoj17F70 zEJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np2-20020a17090b4c4200b0024e2a51144esi7311694pjb.34.2023.05.05.09.14.27; Fri, 05 May 2023 09:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbjEEQCZ convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 May 2023 12:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbjEEQCX (ORCPT ); Fri, 5 May 2023 12:02:23 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFADD11D9F for ; Fri, 5 May 2023 09:02:22 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-313-b_0hsLUQOnitoawNGLcfRA-1; Fri, 05 May 2023 17:02:19 +0100 X-MC-Unique: b_0hsLUQOnitoawNGLcfRA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 5 May 2023 17:02:18 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 5 May 2023 17:02:18 +0100 From: David Laight To: 'Michael Ellerman' , "glider@google.com" , "elver@google.com" , "akpm@linux-foundation.org" , "zhangpeng.00@bytedance.com" CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linuxppc-dev@lists.ozlabs.org" Subject: RE: [PATCH] mm: kfence: Fix false positives on big endian Thread-Topic: [PATCH] mm: kfence: Fix false positives on big endian Thread-Index: AQHZfwT1fw2Bof1hQEOCEaNqiVuD7a9L1zDg Date: Fri, 5 May 2023 16:02:17 +0000 Message-ID: <826f836f41db41eeb0fc32061994ac39@AcuMS.aculab.com> References: <20230505035127.195387-1-mpe@ellerman.id.au> In-Reply-To: <20230505035127.195387-1-mpe@ellerman.id.au> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,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-kernel@vger.kernel.org From: Michael Ellerman > Sent: 05 May 2023 04:51 > > Since commit 1ba3cbf3ec3b ("mm: kfence: improve the performance of > __kfence_alloc() and __kfence_free()"), kfence reports failures in > random places at boot on big endian machines. > > The problem is that the new KFENCE_CANARY_PATTERN_U64 encodes the > address of each byte in its value, so it needs to be byte swapped on big > endian machines. > > The compiler is smart enough to do the le64_to_cpu() at compile time, so > there is no runtime overhead. > > Fixes: 1ba3cbf3ec3b ("mm: kfence: improve the performance of __kfence_alloc() and __kfence_free()") > Signed-off-by: Michael Ellerman > --- > mm/kfence/kfence.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kfence/kfence.h b/mm/kfence/kfence.h > index 2aafc46a4aaf..392fb273e7bd 100644 > --- a/mm/kfence/kfence.h > +++ b/mm/kfence/kfence.h > @@ -29,7 +29,7 @@ > * canary of every 8 bytes is the same. 64-bit memory can be filled and checked > * at a time instead of byte by byte to improve performance. > */ > -#define KFENCE_CANARY_PATTERN_U64 ((u64)0xaaaaaaaaaaaaaaaa ^ (u64)(0x0706050403020100)) > +#define KFENCE_CANARY_PATTERN_U64 ((u64)0xaaaaaaaaaaaaaaaa ^ (u64)(le64_to_cpu(0x0706050403020100))) What at the (u64) casts for? The constants should probably have a ul (or ull) suffix. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)