Browse code

auto spec version bump up: git

- git: bump up to 2.31.1

Change-Id: I8ecb445ee2cf1640a7e5e472074f5d0cb201b7df
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/12884
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Michelle Wang <michellew@vmware.com>

gerrit-photon authored on 2021/04/13 16:20:59
Showing 4 changed files
1 1
deleted file mode 100644
... ...
@@ -1,311 +0,0 @@
1
-From 684dd4c2b414bcf648505e74498a608f28de4592 Mon Sep 17 00:00:00 2001
2
-From: Matheus Tavares <matheus.bernardino@usp.br>
3
-Date: Thu, 10 Dec 2020 10:27:55 -0300
4
-Subject: [PATCH] checkout: fix bug that makes checkout follow symlinks in
5
- leading path
6
-
7
-Before checking out a file, we have to confirm that all of its leading
8
-components are real existing directories. And to reduce the number of
9
-lstat() calls in this process, we cache the last leading path known to
10
-contain only directories. However, when a path collision occurs (e.g.
11
-when checking out case-sensitive files in case-insensitive file
12
-systems), a cached path might have its file type changed on disk,
13
-leaving the cache on an invalid state. Normally, this doesn't bring
14
-any bad consequences as we usually check out files in index order, and
15
-therefore, by the time the cached path becomes outdated, we no longer
16
-need it anyway (because all files in that directory would have already
17
-been written).
18
-
19
-But, there are some users of the checkout machinery that do not always
20
-follow the index order. In particular: checkout-index writes the paths
21
-in the same order that they appear on the CLI (or stdin); and the
22
-delayed checkout feature -- used when a long-running filter process
23
-replies with "status=delayed" -- postpones the checkout of some entries,
24
-thus modifying the checkout order.
25
-
26
-When we have to check out an out-of-order entry and the lstat() cache is
27
-invalid (due to a previous path collision), checkout_entry() may end up
28
-using the invalid data and thrusting that the leading components are
29
-real directories when, in reality, they are not. In the best case
30
-scenario, where the directory was replaced by a regular file, the user
31
-will get an error: "fatal: unable to create file 'foo/bar': Not a
32
-directory". But if the directory was replaced by a symlink, checkout
33
-could actually end up following the symlink and writing the file at a
34
-wrong place, even outside the repository. Since delayed checkout is
35
-affected by this bug, it could be used by an attacker to write
36
-arbitrary files during the clone of a maliciously crafted repository.
37
-
38
-Some candidate solutions considered were to disable the lstat() cache
39
-during unordered checkouts or sort the entries before passing them to
40
-the checkout machinery. But both ideas include some performance penalty
41
-and they don't future-proof the code against new unordered use cases.
42
-
43
-Instead, we now manually reset the lstat cache whenever we successfully
44
-remove a directory. Note: We are not even checking whether the directory
45
-was the same as the lstat cache points to because we might face a
46
-scenario where the paths refer to the same location but differ due to
47
-case folding, precomposed UTF-8 issues, or the presence of `..`
48
-components in the path. Two regression tests, with case-collisions and
49
-utf8-collisions, are also added for both checkout-index and delayed
50
-checkout.
51
-
52
-Note: to make the previously mentioned clone attack unfeasible, it would
53
-be sufficient to reset the lstat cache only after the remove_subtree()
54
-call inside checkout_entry(). This is the place where we would remove a
55
-directory whose path collides with the path of another entry that we are
56
-currently trying to check out (possibly a symlink). However, in the
57
-interest of a thorough fix that does not leave Git open to
58
-similar-but-not-identical attack vectors, we decided to intercept
59
-all `rmdir()` calls in one fell swoop.
60
-
61
-This addresses CVE-2021-21300.
62
-
63
-Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>
64
-Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
65
- cache.h                         |  1 +
66
- compat/mingw.c                  |  2 ++
67
- git-compat-util.h               |  5 ++++
68
- symlinks.c                      | 24 +++++++++++++++++
69
- t/t0021-conversion.sh           | 45 ++++++++++++++++++++++++++++++++
70
- t/t0021/rot13-filter.pl         | 21 ++++++++++++---
71
- t/t2006-checkout-index-basic.sh | 46 +++++++++++++++++++++++++++++++++
72
- 7 files changed, 141 insertions(+), 3 deletions(-)
73
-
74
-diff --git a/cache.h b/cache.h
75
-index 0323853c99..c530593971 100644
76
-+++ b/cache.h
77
-@@ -1631,6 +1631,7 @@ int has_symlink_leading_path(const char *name, int len);
78
- int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
79
- int check_leading_path(const char *name, int len);
80
- int has_dirs_only_path(const char *name, int len, int prefix_len);
81
-+void invalidate_lstat_cache(void);
82
- void schedule_dir_for_removal(const char *name, int len);
83
- void remove_scheduled_dirs(void);
84
- 
85
-diff --git a/compat/mingw.c b/compat/mingw.c
86
-index b047e2166096f..0c414d08b69aa 100644
87
-+++ b/compat/mingw.c
88
-@@ -340,6 +340,8 @@ int mingw_rmdir(const char *pathname)
89
- 	       ask_yes_no_if_possible("Deletion of directory '%s' failed. "
90
- 			"Should I try again?", pathname))
91
- 	       ret = _wrmdir(wpathname);
92
-+	if (!ret)
93
-+		invalidate_lstat_cache();
94
- 	return ret;
95
- }
96
- 
97
-diff --git a/git-compat-util.h b/git-compat-util.h
98
-index 37277494f9..6230f9aaf3 100644
99
-+++ b/git-compat-util.h
100
-@@ -364,6 +364,11 @@ static inline int noop_core_config(const char *var, const char *value, void *cb)
101
- #define platform_core_config noop_core_config
102
- #endif
103
- 
104
-+int lstat_cache_aware_rmdir(const char *path);
105
-+#if !defined(__MINGW32__) && !defined(_MSC_VER)
106
-+#define rmdir lstat_cache_aware_rmdir
107
-+#endif
108
-+
109
- #ifndef has_dos_drive_prefix
110
- static inline int git_has_dos_drive_prefix(const char *path)
111
- {
112
-diff --git a/symlinks.c b/symlinks.c
113
-index 5261e8cf49..53b770be08 100644
114
-+++ b/symlinks.c
115
-@@ -267,6 +267,13 @@ int has_dirs_only_path(const char *name, int len, int prefix_len)
116
-  */
117
- static int threaded_has_dirs_only_path(struct cache_def *cache, const char *name, int len, int prefix_len)
118
- {
119
-+	/*
120
-+	 * Note: this function is used by the checkout machinery, which also
121
-+	 * takes care to properly reset the cache when it performs an operation
122
-+	 * that would leave the cache outdated. If this function starts caching
123
-+	 * anything else besides FL_DIR, remember to also invalidate the cache
124
-+	 * when creating or deleting paths that might be in the cache.
125
-+	 */
126
- 	return lstat_cache(cache, name, len,
127
- 			   FL_DIR|FL_FULLPATH, prefix_len) &
128
- 		FL_DIR;
129
-@@ -321,3 +328,20 @@ void remove_scheduled_dirs(void)
130
- {
131
- 	do_remove_scheduled_dirs(0);
132
- }
133
-+
134
-+void invalidate_lstat_cache(void)
135
-+{
136
-+	reset_lstat_cache(&default_cache);
137
-+}
138
-+
139
-+#undef rmdir
140
-+int lstat_cache_aware_rmdir(const char *path)
141
-+{
142
-+	/* Any change in this function must be made also in `mingw_rmdir()` */
143
-+	int ret = rmdir(path);
144
-+
145
-+	if (!ret)
146
-+		invalidate_lstat_cache();
147
-+
148
-+	return ret;
149
-+}
150
-diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
151
-index 46f8e583c37da..8ff917fca6d9f 100755
152
-+++ b/t/t0021-conversion.sh
153
-@@ -817,4 +817,49 @@ test_expect_success PERL 'invalid file in delayed checkout' '
154
- 	grep "error: external filter .* signaled that .unfiltered. is now available although it has not been delayed earlier" git-stderr.log
155
- '
156
- 
157
-+for mode in 'case' 'utf-8'
158
-+do
159
-+	case "$mode" in
160
-+	case)	dir='A' symlink='a' mode_prereq='CASE_INSENSITIVE_FS' ;;
161
-+	utf-8)
162
-+		dir=$(printf "\141\314\210") symlink=$(printf "\303\244")
163
-+		mode_prereq='UTF8_NFD_TO_NFC' ;;
164
-+	esac
165
-+
166
-+	test_expect_success PERL,SYMLINKS,$mode_prereq \
167
-+	"delayed checkout with $mode-collision don't write to the wrong place" '
168
-+		test_config_global filter.delay.process \
169
-+			"\"$TEST_ROOT/rot13-filter.pl\" --always-delay delayed.log clean smudge delay" &&
170
-+		test_config_global filter.delay.required true &&
171
-+
172
-+		git init $mode-collision &&
173
-+		(
174
-+			cd $mode-collision &&
175
-+			mkdir target-dir &&
176
-+
177
-+			empty_oid=$(printf "" | git hash-object -w --stdin) &&
178
-+			symlink_oid=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
179
-+			attr_oid=$(echo "$dir/z filter=delay" | git hash-object -w --stdin) &&
180
-+
181
-+			cat >objs <<-EOF &&
182
-+			100644 blob $empty_oid	$dir/x
183
-+			100644 blob $empty_oid	$dir/y
184
-+			100644 blob $empty_oid	$dir/z
185
-+			120000 blob $symlink_oid	$symlink
186
-+			100644 blob $attr_oid	.gitattributes
187
-+			EOF
188
-+
189
-+			git update-index --index-info <objs &&
190
-+			git commit -m "test commit"
191
-+		) &&
192
-+
193
-+		git clone $mode-collision $mode-collision-cloned &&
194
-+		# Make sure z was really delayed
195
-+		grep "IN: smudge $dir/z .* \\[DELAYED\\]" $mode-collision-cloned/delayed.log &&
196
-+
197
-+		# Should not create $dir/z at $symlink/z
198
-+		test_path_is_missing $mode-collision/target-dir/z
199
-+	'
200
-+done
201
-+
202
- test_done
203
-diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl
204
-index 470107248eb16..007f2d78ea5b0 100644
205
-+++ b/t/t0021/rot13-filter.pl
206
-@@ -2,9 +2,15 @@
207
- # Example implementation for the Git filter protocol version 2
208
- # See Documentation/gitattributes.txt, section "Filter Protocol"
209
- #
210
--# The first argument defines a debug log file that the script write to.
211
--# All remaining arguments define a list of supported protocol
212
--# capabilities ("clean", "smudge", etc).
213
-+# Usage: rot13-filter.pl [--always-delay] <log path> <capabilities>
214
-+#
215
-+# Log path defines a debug log file that the script writes to. The
216
-+# subsequent arguments define a list of supported protocol capabilities
217
-+# ("clean", "smudge", etc).
218
-+#
219
-+# When --always-delay is given all pathnames with the "can-delay" flag
220
-+# that don't appear on the list bellow are delayed with a count of 1
221
-+# (see more below).
222
- #
223
- # This implementation supports special test cases:
224
- # (1) If data with the pathname "clean-write-fail.r" is processed with
225
-@@ -53,6 +59,13 @@ sub gitperllib {
226
- use Git::Packet;
227
- 
228
- my $MAX_PACKET_CONTENT_SIZE = 65516;
229
-+
230
-+my $always_delay = 0;
231
-+if ( $ARGV[0] eq '--always-delay' ) {
232
-+	$always_delay = 1;
233
-+	shift @ARGV;
234
-+}
235
-+
236
- my $log_file                = shift @ARGV;
237
- my @capabilities            = @ARGV;
238
- 
239
-@@ -134,6 +147,8 @@ sub rot13 {
240
- 			if ( $buffer eq "can-delay=1" ) {
241
- 				if ( exists $DELAY{$pathname} and $DELAY{$pathname}{"requested"} == 0 ) {
242
- 					$DELAY{$pathname}{"requested"} = 1;
243
-+				} elsif ( !exists $DELAY{$pathname} and $always_delay ) {
244
-+					$DELAY{$pathname} = { "requested" => 1, "count" => 1 };
245
- 				}
246
- 			} elsif ($buffer =~ /^(ref|treeish|blob)=/) {
247
- 				print $debug " $buffer";
248
-diff --git a/t/t2006-checkout-index-basic.sh b/t/t2006-checkout-index-basic.sh
249
-index 8e181db..a95dcf3 100755
250
-+++ b/t/t2006-checkout-index-basic.sh
251
-@@ -21,6 +21,52 @@ test_expect_success 'checkout-index -h in broken repository' '
252
- 	test_i18ngrep "[Uu]sage" broken/usage
253
- '
254
- 
255
-+for mode in 'case' 'utf-8'
256
-+do
257
-+	case "$mode" in
258
-+	case)	dir='A' symlink='a' mode_prereq='CASE_INSENSITIVE_FS' ;;
259
-+	utf-8)
260
-+		dir=$(printf "\141\314\210") symlink=$(printf "\303\244")
261
-+		mode_prereq='UTF8_NFD_TO_NFC' ;;
262
-+	esac
263
-+
264
-+	test_expect_success SYMLINKS,$mode_prereq \
265
-+	"checkout-index with $mode-collision don't write to the wrong place" '
266
-+		git init $mode-collision &&
267
-+		(
268
-+			cd $mode-collision &&
269
-+			mkdir target-dir &&
270
-+
271
-+			empty_obj_hex=$(git hash-object -w --stdin </dev/null) &&
272
-+			symlink_hex=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
273
-+
274
-+			cat >objs <<-EOF &&
275
-+			100644 blob ${empty_obj_hex}	${dir}/x
276
-+			100644 blob ${empty_obj_hex}	${dir}/y
277
-+			100644 blob ${empty_obj_hex}	${dir}/z
278
-+			120000 blob ${symlink_hex}	${symlink}
279
-+			EOF
280
-+
281
-+			git update-index --index-info <objs &&
282
-+
283
-+			# Note: the order is important here to exercise the
284
-+			# case where the file at ${dir} has its type changed by
285
-+			# the time Git tries to check out ${dir}/z.
286
-+			#
287
-+			# Also, we use core.precomposeUnicode=false because we
288
-+			# want Git to treat the UTF-8 paths transparently on
289
-+			# Mac OS, matching what is in the index.
290
-+			#
291
-+			git -c core.precomposeUnicode=false checkout-index -f \
292
-+				${dir}/x ${dir}/y ${symlink} ${dir}/z &&
293
-+
294
-+			# Should not create ${dir}/z at ${symlink}/z
295
-+			test_path_is_missing target-dir/z
296
-+
297
-+		)
298
-+	'
299
-+done
300
-+
301
- test_expect_success 'checkout-index reports errors (cmdline)' '
302
- 	test_must_fail git checkout-index -- does-not-exist 2>stderr &&
303
- 	test_i18ngrep not.in.the.cache stderr
304 1
deleted file mode 100644
... ...
@@ -1,106 +0,0 @@
1
-From 0d58fef58a6f382ba1d35f47a01cb55d8976335f Mon Sep 17 00:00:00 2001
2
-From: Johannes Schindelin <johannes.schindelin@gmx.de>
3
-Date: Tue, 2 Feb 2021 22:09:52 +0100
4
-Subject: [PATCH] run-command: invalidate lstat cache after a command finished
5
-
6
-In the previous commit, we intercepted calls to `rmdir()` to invalidate
7
-the lstat cache in the successful case, so that the lstat cache could
8
-not have the idea that a directory exists where there is none.
9
-
10
-The same situation can arise, of course, when a separate process is
11
-spawned (most notably, this is the case in `submodule_move_head()`).
12
-Obviously, we cannot know whether a directory was removed in that
13
-process, therefore we must invalidate the lstat cache afterwards.
14
-
15
-Note: in contrast to `lstat_cache_aware_rmdir()`, we invalidate the
16
-lstat cache even in case of an error: the process might have removed a
17
-directory and still have failed afterwards.
18
-
19
-Co-authored-by: Matheus Tavares <matheus.bernardino@usp.br>
20
-Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
21
- run-command.c         |  9 ++++++++-
22
- t/t0021-conversion.sh | 36 ++++++++++++++++++++++++++++++++++++
23
- 2 files changed, 44 insertions(+), 1 deletion(-)
24
-
25
-diff --git a/run-command.c b/run-command.c
26
-index a483d5904a..c5c4d36671 100644
27
-+++ b/run-command.c
28
-@@ -989,6 +989,7 @@ int finish_command(struct child_process *cmd)
29
- 	int ret = wait_or_whine(cmd->pid, cmd->argv[0], 0);
30
- 	trace2_child_exit(cmd, ret);
31
- 	child_process_clear(cmd);
32
-+	invalidate_lstat_cache();
33
- 	return ret;
34
- }
35
- 
36
-@@ -1239,13 +1240,19 @@ int start_async(struct async *async)
37
- int finish_async(struct async *async)
38
- {
39
- #ifdef NO_PTHREADS
40
--	return wait_or_whine(async->pid, "child process", 0);
41
-+	int ret = wait_or_whine(async->pid, "child process", 0);
42
-+
43
-+	invalidate_lstat_cache();
44
-+
45
-+	return ret;
46
- #else
47
- 	void *ret = (void *)(intptr_t)(-1);
48
- 
49
- 	if (pthread_join(async->tid, &ret))
50
- 		error("pthread_join failed");
51
-+	invalidate_lstat_cache();
52
- 	return (int)(intptr_t)ret;
53
-+
54
- #endif
55
- }
56
- 
57
-diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
58
-index 8ff917fca6..a714d376a3 100755
59
-+++ b/t/t0021-conversion.sh
60
-@@ -862,4 +862,40 @@ do
61
- 	'
62
- done
63
- 
64
-+test_expect_success PERL,SYMLINKS,CASE_INSENSITIVE_FS \
65
-+"delayed checkout with submodule collision don't write to the wrong place" '
66
-+	git init collision-with-submodule &&
67
-+	(
68
-+		cd collision-with-submodule &&
69
-+		git config filter.delay.process "\"$TEST_ROOT/rot13-filter.pl\" --always-delay delayed.log clean smudge delay" &&
70
-+		git config filter.delay.required true &&
71
-+
72
-+		# We need Git to treat the submodule "a" and the
73
-+		# leading dir "A" as different paths in the index.
74
-+		git config --local core.ignoreCase false &&
75
-+
76
-+		empty_oid=$(printf "" | git hash-object -w --stdin) &&
77
-+		attr_oid=$(echo "A/B/y filter=delay" | git hash-object -w --stdin) &&
78
-+		cat >objs <<-EOF &&
79
-+		100644 blob $empty_oid	A/B/x
80
-+		100644 blob $empty_oid	A/B/y
81
-+		100644 blob $attr_oid	.gitattributes
82
-+		EOF
83
-+		git update-index --index-info <objs &&
84
-+
85
-+		git init a &&
86
-+		mkdir target-dir &&
87
-+		symlink_oid=$(printf "%s" "$PWD/target-dir" | git -C a hash-object -w --stdin) &&
88
-+		echo "120000 blob $symlink_oid	b" >objs &&
89
-+		git -C a update-index --index-info <objs &&
90
-+		git -C a commit -m sub &&
91
-+		git submodule add ./a &&
92
-+		git commit -m super &&
93
-+
94
-+		git checkout --recurse-submodules . &&
95
-+		grep "IN: smudge A/B/y .* \\[DELAYED\\]" delayed.log &&
96
-+		test_path_is_missing target-dir/y
97
-+	)
98
-+'
99
-+
100
- test_done
101
-2.30.0
102
-
103 1
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
1
-From 22539ec3b5e678c054ab361a37a7cdcc64ca1228 Mon Sep 17 00:00:00 2001
2
-From: Matheus Tavares <matheus.bernardino@usp.br>
3
-Date: Tue, 2 Feb 2021 22:37:10 +0100
4
-Subject: [PATCH] unpack_trees(): start with a fresh lstat cache
5
-
6
-We really want to avoid relying on stale information.
7
-
8
-Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
9
-Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
10
- unpack-trees.c | 3 +++
11
- 1 file changed, 3 insertions(+)
12
-
13
-diff --git a/unpack-trees.c b/unpack-trees.c
14
-index 323280d..2344b5e 100644
15
-+++ b/unpack-trees.c
16
-@@ -417,6 +417,9 @@ static int check_updates(struct unpack_trees_options *o,
17
- 
18
- 	progress = get_progress(o, index);
19
- 
20
-+	/* Start with clean cache to avoid using any possibly outdated info. */
21
-+	invalidate_lstat_cache();
22
-+
23
- 	git_attr_set_direction(GIT_ATTR_CHECKOUT);
24
- 
25
- 	if (should_update_submodules())
... ...
@@ -1,17 +1,14 @@
1 1
 Summary:        Fast distributed version control system
2 2
 Name:           git
3
-Version:        2.30.0
4
-Release:        3%{?dist}
3
+Version:        2.31.1
4
+Release:        1%{?dist}
5 5
 License:        GPLv2
6 6
 URL:            http://git-scm.com/
7 7
 Group:          System Environment/Programming
8 8
 Vendor:         VMware, Inc.
9 9
 Distribution:   Photon
10 10
 Source0:        https://www.kernel.org/pub/software/scm/git/%{name}-%{version}.tar.xz
11
-%define sha1    git=6be02a878d08227d85f0cf4d5646b19c60a242e4
12
-Patch0:         CVE-2021-21300-1.patch
13
-Patch1:         CVE-2021-21300-2.patch
14
-Patch2:         CVE-2021-21300-3.patch
11
+%define sha1    git=a66f98f88bf7734f8463446ac0735cee190da1dc
15 12
 BuildRequires:  curl-devel
16 13
 BuildRequires:  python3
17 14
 BuildRequires:  python3-devel
... ...
@@ -47,9 +44,7 @@ These are the additional language files of git.
47 47
 
48 48
 %prep
49 49
 %setup -q
50
-%patch0 -p1
51
-%patch1 -p1
52
-%patch2 -p1
50
+
53 51
 %build
54 52
 %configure \
55 53
     CFLAGS="%{optflags}" \
... ...
@@ -57,6 +52,7 @@ These are the additional language files of git.
57 57
     --libexec=%{_libexecdir} \
58 58
     --with-gitconfig=/etc/gitconfig
59 59
 make %{?_smp_mflags} CFLAGS="%{optflags}" CXXFLAGS="%{optflags}"
60
+
60 61
 %install
61 62
 [ %{buildroot} != "/"] && rm -rf %{buildroot}/*
62 63
 make DESTDIR=%{buildroot} install
... ...
@@ -80,6 +76,7 @@ fi
80 80
 
81 81
 %clean
82 82
 rm -rf %{buildroot}/*
83
+
83 84
 %files
84 85
 %defattr(-,root,root)
85 86
 %{_bindir}/*
... ...
@@ -100,6 +97,8 @@ rm -rf %{buildroot}/*
100 100
 %defattr(-,root,root)
101 101
 
102 102
 %changelog
103
+*   Tue Apr 13 2021 Gerrit Photon <photon-checkins@vmware.com> 2.31.1-1
104
+-   Automatic Version Bump
103 105
 *   Tue Mar 09 2021 Prashant S Chauhan <psinghchauha@vmware.com> 2.30.0-3
104 106
 -   Fix CVE-2021-21300
105 107
 *   Mon Feb 01 2021 Shreenidhi Shedi <sshedi@vmware.com> 2.30.0-2