git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Prevent git from rehashing 4GBi files

From
Jason Hatton <jhatton@globalfinishing.com>
Date
May 6, 2022, 17:08 UTC
Message-ID
<CY4PR16MB1655EE6CC2218AEA35B451E3AFC59@CY4PR16MB1655.namprd16.prod.outlook.com>
Show 7 quoted lines
>Philip Oakley <philipoakley@iee.email> writes:
>
>> This "Munge" above isn't telling the reader 'why'/'what' is going on.
>> The comment should in some way highlight that a zero size result is
>> special, and that we have the roll over issue when the stored in 32 bits
>> - the double duty of racy vs changed in the stat data heuristic.
>> Synonyms of 'munge' ?

mangle? hash?

Show 9 quoted lines
>>
>>
>>> + */
>>> +unsigned int munge_st_size(off_t st_size) {
>>> +    unsigned int sd_size = st_size;
>>> +
>>> +    if(!sd_size && st_size)
>
>Style.
Something like 1<<31?
Show 15 quoted lines
>
>>> +        return 0x80000000;
>>> +    else
>>> +        return sd_size;
>>> +}
>
>This may treat non-zero multiple of 4GiB as "not racy", but has
>anybody double checked the concern Réne brought up earlier that a
>4GiB file that was added and then got rewritten to 2GiB within the
>same second would suddenly start getting treated as not racy?
>
>The patch (the firnal version of it anyway) needs to be accompanied
>by a handful of test additions to tickle corner cases like that.
>
>Thanks, all, for working on this.

If the file size is changed by exactly 2GiB is a concern. This is an issue for files exactly a multiple of 4GiB. However, all files that are changed by a multiple of 4GiB are vulnerable. Say 4GiB + 42 and 8GiB + 42 would appear the same with the current version of git. I'm sure the true fix involves updating the index file format with 64 bit files sizes and an explicit racy flag. I'm hopeful the rehashing issue for 4GiB files can be mitigated until than.

I have a question about the coding style. Torsten indicated that there should be an explicit type cast. The original code did not use an explicit type cast, so I'm unsure what is going on. One of you experts may have to make the final patch. I hope my proof of concept gets the idea across.

Thanks -- Jason

Next: Junio C Hamano
Message 1 of 2 in “Re: [PATCH] Prevent git from rehashing 4GBi files”
  1. Jason HattonMay 6, 2022
  2. Junio C HamanoMay 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.