From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF403C77B75 for ; Fri, 5 May 2023 16:02:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BBA36B007D; Fri, 5 May 2023 12:02:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 644416B007E; Fri, 5 May 2023 12:02:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50C486B0080; Fri, 5 May 2023 12:02:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by kanga.kvack.org (Postfix) with ESMTP id F16AA6B007D for ; Fri, 5 May 2023 12:02:21 -0400 (EDT) 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: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Michael Ellerman > Sent: 05 May 2023 04:51 >=20 > 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. >=20 > 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. >=20 > The compiler is smart enough to do the le64_to_cpu() at compile time, so > there is no runtime overhead. >=20 > Fixes: 1ba3cbf3ec3b ("mm: kfence: improve the performance of __kfence_all= oc() and __kfence_free()") > Signed-off-by: Michael Ellerman > --- > mm/kfence/kfence.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > 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)(0x070= 6050403020100)) > +#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. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)