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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67450C433EF for ; Thu, 9 Dec 2021 17:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243002AbhLIRe5 (ORCPT ); Thu, 9 Dec 2021 12:34:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235532AbhLIRey (ORCPT ); Thu, 9 Dec 2021 12:34:54 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C607DC061746 for ; Thu, 9 Dec 2021 09:31:20 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id r25so21398699edq.7 for ; Thu, 09 Dec 2021 09:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iqExJZ9/DphBTKULUzi0rda5Ww/lFJEMJ0HrtECPjTI=; b=CEZX4drLnp80p9b9oVxK0f0qT2WA3YF+B1Tl8CQVWg2uGKK6+gQz0h/GPS2FyiNNJ9 gAKRuC48E81Hb/mGX0sY3phjIF/WMv16b9bipyIo+rIOFDAbKwrmyJ7HqNkTia2gkVbu /I1NAgDWldKvVVC+e1z0jNAfGMMlQioj2HEiU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iqExJZ9/DphBTKULUzi0rda5Ww/lFJEMJ0HrtECPjTI=; b=FvEabh9khU3i7twZchPwaNhdUuhMsrRw0014VEkVd/T69vyJ/AHL3mYp9JCaRIUXek 10s0gK0L956RI33soFgDLkK6AYeKJAI6pC3ejj+VSIYslSoTtfC5OklFXTYVUtcmf+hO 1JEMNr1NVKEh8wPGRePtA/DgWzuC0SsBEdluYaMgAkxtWS0kml8M3D7U9jRO+wOAR8Bc T3n89pvgye5O8Q4r/EAQeFs/OKkOHGLVKzapNVoo1j4KM7mbH8ApeRNewSQOd5O8hdxs Svu4B7T+S8pu25OTlvVrKjL0KD4zl0vk+C/GhGPf1AQUzHVJIRCn3UHY1NrlWFIGiLgs lh7w== X-Gm-Message-State: AOAM530fQdWeC5wwu644ZKRrV/cQl78BRUkbkhs0R4quATmSeCdV1WCM x1PAtGQab2AbNK6ExGf937tt/+DE5cGsNEMe X-Google-Smtp-Source: ABdhPJwKhD7I2tS2HN2Whtpv+YZj7w3dmcftWFLgsS7UmrrjK8kBs8Bc3dhDoOD+4522R6EfVLbHxg== X-Received: by 2002:a17:907:7f9e:: with SMTP id qk30mr17393581ejc.313.1639070886847; Thu, 09 Dec 2021 09:28:06 -0800 (PST) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com. [209.85.128.53]) by smtp.gmail.com with ESMTPSA id og14sm214994ejc.107.2021.12.09.09.28.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 09:28:06 -0800 (PST) Received: by mail-wm1-f53.google.com with SMTP id 77-20020a1c0450000000b0033123de3425so7172502wme.0 for ; Thu, 09 Dec 2021 09:28:06 -0800 (PST) X-Received: by 2002:a05:600c:22ce:: with SMTP id 14mr8659906wmg.152.1639070533785; Thu, 09 Dec 2021 09:22:13 -0800 (PST) MIME-Version: 1.0 References: <163906878733.143852.5604115678965006622.stgit@warthog.procyon.org.uk> <163906891983.143852.6219772337558577395.stgit@warthog.procyon.org.uk> In-Reply-To: <163906891983.143852.6219772337558577395.stgit@warthog.procyon.org.uk> From: Linus Torvalds Date: Thu, 9 Dec 2021 09:21:57 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 10/67] fscache: Implement cookie registration To: David Howells Cc: linux-cachefs@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , JeffleXu , linux-afs@lists.infradead.org, "open list:NFS, SUNRPC, AND..." , CIFS , ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 9, 2021 at 8:55 AM David Howells wrote: > > + buf = (u32 *)cookie->inline_key; > + } > + > + memcpy(buf, index_key, index_key_len); > + cookie->key_hash = fscache_hash(cookie->volume->key_hash, buf, bufs); This is actively wrong given the noise about "endianness independence" of the fscache_hash() function. There is absolutely nothing endianness-independent in the above. You're taking some random data, casting the pointer to a native word-order 32-bit entity, and then doing things in that native word order. The same data will give different results on different endiannesses. Maybe some other code has always munged stuff so that it's in some "native word format", but if so, the type system should have been made to match. And it's not. It explicitly casts what is clearly some other pointer type to "u32 *". There is no way in hell this is properly endianness-independent with each word in an array having some actual endianness-independent value when you write code like this. I'd suggest making endianness either explicit (make things explicitly "__le32" or whatever) and making sure that you don't just randomly cast pointers, you actually have the proper types. Or, alternatively, just say "nobody cares about BE any more, endianness isn't relevant, get over it". But don't have functions that claim to be endianness-independent and then randomly access data like this. Linus