linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pedro Falcato <pedro.falcato@gmail.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>, linux-ext4@vger.kernel.org
Subject: Re: Question regarding the use of CRC32c for checksumming
Date: Fri, 4 Aug 2023 22:08:13 +0100	[thread overview]
Message-ID: <CAKbZUD0ModY66yJ+ieAs=XYecMHc-X2=Sanxcv8wmSf0T=BSzQ@mail.gmail.com> (raw)
In-Reply-To: <20230703194850.GF1194@sol.localdomain>

On Mon, Jul 3, 2023 at 8:48 PM Eric Biggers <ebiggers@kernel.org> wrote:
>

Hi folks, really sorry for the big delay, this thread really slipped my mind :)

> IMO the best API for CRC's is like zlib's where you pass in 0 to start the CRC
> and it does both the pre and post inversions for you.  Note, "updates" still
> work as expected, since two inversions cancel each other out.

I agree, I did that when adding CRC32c to EFI. u32
calculate_crc32c(const void *buf, size_t len, u32 initial) with
inversions on initial and the result is pretty simple and effective.

> Unfortunately, many but not all of the CRC APIs in Linux decided to go with the
> other convention, which is to leave the inversions entirely to the caller.
>
> I think the kernel should also make the architecture-specific CRC
> implementations accessible directly via a library API, similar to what's done
> for Blake2s and ChaCha20.  There should be no need to go through shash at all...
>
> >
> > This misuse could be fixed, but you'd have to burn an incompat flag to
> > do it.  I'm less smart about crc32* than I was back in 2008, so I also
> > don't have the skills to figure out if the correction is worth the cost.
> >
> > --D
>
> No, it's not worth changing the ext4 on-disk format for this.

I don't think we'd need to change the on-disk format for this? Or for
any other hash algorithm change (as long as the resulting digest is
32-bit), right? Given we have s_checksum_type.
Or do existing tools dangerously assume CRC32c at the moment?

In any case, thank you both for the background on this, I'll try to
submit a patch to the docs to clarify this point.

-- 
Pedro

      reply	other threads:[~2023-08-04 21:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 20:17 Question regarding the use of CRC32c for checksumming Pedro Falcato
2023-06-28  4:52 ` Eric Biggers
2023-06-28 18:58   ` Darrick J. Wong
2023-07-03 19:48     ` Eric Biggers
2023-08-04 21:08       ` Pedro Falcato [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKbZUD0ModY66yJ+ieAs=XYecMHc-X2=Sanxcv8wmSf0T=BSzQ@mail.gmail.com' \
    --to=pedro.falcato@gmail.com \
    --cc=djwong@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).