Skip to content

Commit bcf08f3

Browse files
committed
Sync with 2.21.4
* maint-2.21: Git 2.21.4 Git 2.20.5 Git 2.19.6 Git 2.18.5 Git 2.17.6 unpack_trees(): start with a fresh lstat cache run-command: invalidate lstat cache after a command finished checkout: fix bug that makes checkout follow symlinks in leading path
2 parents c9808fa + c735d74 commit bcf08f3

File tree

14 files changed

+228
-4
lines changed

14 files changed

+228
-4
lines changed

Documentation/RelNotes/2.17.6.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Git v2.17.6 Release Notes
2+
=========================
3+
4+
This release addresses the security issues CVE-2021-21300.
5+
6+
Fixes since v2.17.5
7+
-------------------
8+
9+
* CVE-2021-21300:
10+
On case-insensitive file systems with support for symbolic links,
11+
if Git is configured globally to apply delay-capable clean/smudge
12+
filters (such as Git LFS), Git could be fooled into running
13+
remote code during a clone.
14+
15+
Credit for finding and fixing this vulnerability goes to Matheus
16+
Tavares, helped by Johannes Schindelin.

Documentation/RelNotes/2.18.5.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.18.5 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.17.6 to address
5+
the security issue CVE-2021-21300; see the release notes for that
6+
version for details.

Documentation/RelNotes/2.19.6.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.19.6 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.17.6 and
5+
v2.18.5 to address the security issue CVE-2021-21300; see the
6+
release notes for these versions for details.

Documentation/RelNotes/2.20.5.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.20.5 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.17.6, v2.18.5
5+
and v2.19.6 to address the security issue CVE-2021-21300; see
6+
the release notes for these versions for details.

Documentation/RelNotes/2.21.4.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Git v2.21.4 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.17.6, v2.18.5,
5+
v2.19.6 and v2.20.5 to address the security issue CVE-2021-21300;
6+
see the release notes for these versions for details.

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,7 @@ int has_symlink_leading_path(const char *name, int len);
16541654
int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
16551655
int check_leading_path(const char *name, int len);
16561656
int has_dirs_only_path(const char *name, int len, int prefix_len);
1657+
void invalidate_lstat_cache(void);
16571658
void schedule_dir_for_removal(const char *name, int len);
16581659
void remove_scheduled_dirs(void);
16591660

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ int mingw_rmdir(const char *pathname)
340340
ask_yes_no_if_possible("Deletion of directory '%s' failed. "
341341
"Should I try again?", pathname))
342342
ret = _wrmdir(wpathname);
343+
if (!ret)
344+
invalidate_lstat_cache();
343345
return ret;
344346
}
345347

git-compat-util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ static inline int noop_core_config(const char *var, const char *value, void *cb)
355355
#define platform_core_config noop_core_config
356356
#endif
357357

358+
int lstat_cache_aware_rmdir(const char *path);
359+
#if !defined(__MINGW32__) && !defined(_MSC_VER)
360+
#define rmdir lstat_cache_aware_rmdir
361+
#endif
362+
358363
#ifndef has_dos_drive_prefix
359364
static inline int git_has_dos_drive_prefix(const char *path)
360365
{

run-command.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ int finish_command(struct child_process *cmd)
989989
int ret = wait_or_whine(cmd->pid, cmd->argv[0], 0);
990990
trace2_child_exit(cmd, ret);
991991
child_process_clear(cmd);
992+
invalidate_lstat_cache();
992993
return ret;
993994
}
994995

@@ -1289,13 +1290,19 @@ int start_async(struct async *async)
12891290
int finish_async(struct async *async)
12901291
{
12911292
#ifdef NO_PTHREADS
1292-
return wait_or_whine(async->pid, "child process", 0);
1293+
int ret = wait_or_whine(async->pid, "child process", 0);
1294+
1295+
invalidate_lstat_cache();
1296+
1297+
return ret;
12931298
#else
12941299
void *ret = (void *)(intptr_t)(-1);
12951300

12961301
if (pthread_join(async->tid, &ret))
12971302
error("pthread_join failed");
1303+
invalidate_lstat_cache();
12981304
return (int)(intptr_t)ret;
1305+
12991306
#endif
13001307
}
13011308

symlinks.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ int has_dirs_only_path(const char *name, int len, int prefix_len)
267267
*/
268268
static int threaded_has_dirs_only_path(struct cache_def *cache, const char *name, int len, int prefix_len)
269269
{
270+
/*
271+
* Note: this function is used by the checkout machinery, which also
272+
* takes care to properly reset the cache when it performs an operation
273+
* that would leave the cache outdated. If this function starts caching
274+
* anything else besides FL_DIR, remember to also invalidate the cache
275+
* when creating or deleting paths that might be in the cache.
276+
*/
270277
return lstat_cache(cache, name, len,
271278
FL_DIR|FL_FULLPATH, prefix_len) &
272279
FL_DIR;
@@ -321,3 +328,20 @@ void remove_scheduled_dirs(void)
321328
{
322329
do_remove_scheduled_dirs(0);
323330
}
331+
332+
void invalidate_lstat_cache(void)
333+
{
334+
reset_lstat_cache(&default_cache);
335+
}
336+
337+
#undef rmdir
338+
int lstat_cache_aware_rmdir(const char *path)
339+
{
340+
/* Any change in this function must be made also in `mingw_rmdir()` */
341+
int ret = rmdir(path);
342+
343+
if (!ret)
344+
invalidate_lstat_cache();
345+
346+
return ret;
347+
}

0 commit comments

Comments
 (0)