git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: non-cryptographic hash algorithms in git
Date: Wed, 31 Jul 2019 17:22:58 -0400	[thread overview]
Message-ID: <20190731212258.GB1207@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq5zniqg36.fsf@gitster-ct.c.googlers.com>

[breaking the thread since we're way off the original topic, and this
 subject might get more interesting attention]

On Wed, Jul 31, 2019 at 10:17:01AM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > And here it is for reference with the matching change in test-oidmap,
> > and the adjustments necessary for the test scripts (from master, not
> > from my earlier patch). I think I prefer the simpler "just sort it all"
> > version I posted with the commit message.
> 
> Yeah, let's go with that version.
> 
> I am wondering if we should follow suit to certain language's hash
> implementation to make sure the iteration order is unpredictable to
> catch bad scripts ;-)  Perhaps that is not worth it, either.

That would be a nice side effect, but the real benefit is that it makes
hash-collision denial-of-service attacks harder. I experimented with
this some when I looked at swapping out the xdiff hash algorithm[1] for
murmur, siphash, or similar, but I could never get the performance quite
on par with what we have now.

I haven't pursued randomization that much because git's diff engine is
a ready-made DoS machine in the first place. If you're diffing untrusted
input, you have to be ready to cut it off after using too much CPU and
say "nope, this one is too big". That may be less true for our general
purpose hashmap, though.

-Peff

[1] I didn't dig up the emails, but this was several years ago, when we
    realized that XDL_FAST_HASH didn't actually work well. I recently
    found out about xxhash:

      https://cyan4973.github.io/xxHash/

    which looks promising. But I haven't gotten around to plugging it in
    and timing the result. Anybody else is welcome to beat me to it. :)

    IIRC, one really tricky thing about our diff code is that it finds
    the newline for each line while it's hashing. That makes it hard to
    plug in an existing hash implementation without going over each line
    twice, and many of them perform poorly if you hand them a byte at a
    time.

  reply	other threads:[~2019-07-31 21:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:08 [ANNOUNCE] Git v2.23.0-rc0 - Initial test failures on NonStop Randall S. Becker
2019-07-30 17:31 ` Junio C Hamano
2019-07-30 18:09   ` Matheus Tavares Bernardino
2019-07-30 18:10   ` Randall S. Becker
2019-07-30 18:35     ` Junio C Hamano
2019-07-30 19:45 ` Jeff King
2019-07-30 20:25   ` Randall S. Becker
2019-07-30 19:49 ` Todd Zullinger
2019-07-30 20:02   ` Jeff King
2019-07-30 20:39     ` Junio C Hamano
2019-07-30 20:56     ` SZEDER Gábor
2019-07-31  0:59       ` Jeff King
2019-07-31  1:23         ` Jeff King
2019-07-31  1:27           ` Jeff King
2019-07-31  1:59           ` Todd Zullinger
2019-07-31  3:27             ` Jeff King
2019-07-31  3:53               ` Jeff King
2019-07-31 17:17                 ` Junio C Hamano
2019-07-31 21:22                   ` Jeff King [this message]
2019-07-31  4:06               ` René Scharfe
2019-07-31  4:30                 ` Jeff King
2019-07-31  6:04               ` Todd Zullinger
2019-07-31 16:57         ` Junio C Hamano
2019-07-30 20:27   ` Randall S. Becker

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20190731212258.GB1207@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).