Skip to content

Commit 9a2f22d

Browse files
committed
Merge tag 'v2.35.4' into HEAD
Git 2.35.4 Signed-off-by: Johannes Schindelin <[email protected]>
2 parents e2854d5 + 359da65 commit 9a2f22d

File tree

13 files changed

+286
-14
lines changed

13 files changed

+286
-14
lines changed

Documentation/RelNotes/2.30.5.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Git v2.30.5 Release Notes
2+
=========================
3+
4+
This release contains minor fix-ups for the changes that went into
5+
Git 2.30.3 and 2.30.4, addressing CVE-2022-29187.
6+
7+
* The safety check that verifies a safe ownership of the Git
8+
worktree is now extended to also cover the ownership of the Git
9+
directory (and the `.git` file, if there is any).
10+
11+
Carlo Marcelo Arenas Belón (1):
12+
setup: tighten ownership checks post CVE-2022-24765

Documentation/RelNotes/2.31.4.txt

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

Documentation/RelNotes/2.32.3.txt

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

Documentation/RelNotes/2.33.4.txt

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

Documentation/RelNotes/2.34.4.txt

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

Documentation/RelNotes/2.35.4.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Git v2.35.4 Release Notes
2+
=========================
3+
4+
This release merges up the fixes that appear in v2.30.5,
5+
v2.31.4, v2.32.3, v2.33.4 and v2.34.4 to address the security
6+
issue CVE-2022-29187; see the release notes for these versions
7+
for details.

Documentation/config/safe.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ Unix' simpler permission model, it can be a bit tricky to figure out why
3232
a directory is considered unsafe. To help with this, Git will provide
3333
more detailed information when the environment variable
3434
`GIT_TEST_DEBUG_UNSAFE_DIRECTORIES` is set to `true`.
35+
+
36+
As explained, Git only allows you to access repositories owned by
37+
yourself, i.e. the user who is running Git, by default. When Git
38+
is running as 'root' in a non Windows platform that provides sudo,
39+
however, git checks the SUDO_UID environment variable that sudo creates
40+
and will allow access to the uid recorded as its value in addition to
41+
the id from 'root'.
42+
+
43+
This is to make it easy to perform a common sequence during installation
44+
"make && sudo make install". A git process running under 'sudo' runs as
45+
'root' but the 'sudo' command exports the environment variable to record
46+
which id the original user has.
47+
+
48+
If that is not what you would prefer and want git to only trust
49+
repositories that are owned by root instead, then you can remove
50+
the `SUDO_UID` variable from root's environment before invoking git.

GIT-VERSION-GEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=v2.35.3
4+
DEF_VER=v2.35.4
55

66
LF='
77
'

RelNotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Documentation/RelNotes/2.35.3.txt
1+
Documentation/RelNotes/2.35.4.txt

git-compat-util.h

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,68 @@ static inline int git_offset_1st_component(const char *path)
433433
#endif
434434

435435
#ifndef is_path_owned_by_current_user
436+
437+
#ifdef __TANDEM
438+
#define ROOT_UID 65535
439+
#else
440+
#define ROOT_UID 0
441+
#endif
442+
443+
/*
444+
* Do not use this function when
445+
* (1) geteuid() did not say we are running as 'root', or
446+
* (2) using this function will compromise the system.
447+
*
448+
* PORTABILITY WARNING:
449+
* This code assumes uid_t is unsigned because that is what sudo does.
450+
* If your uid_t type is signed and all your ids are positive then it
451+
* should all work fine.
452+
* If your version of sudo uses negative values for uid_t or it is
453+
* buggy and return an overflowed value in SUDO_UID, then git might
454+
* fail to grant access to your repository properly or even mistakenly
455+
* grant access to someone else.
456+
* In the unlikely scenario this happened to you, and that is how you
457+
* got to this message, we would like to know about it; so sent us an
458+
* email to [email protected] indicating which platform you are
459+
* using and which version of sudo, so we can improve this logic and
460+
* maybe provide you with a patch that would prevent this issue again
461+
* in the future.
462+
*/
463+
static inline void extract_id_from_env(const char *env, uid_t *id)
464+
{
465+
const char *real_uid = getenv(env);
466+
467+
/* discard anything empty to avoid a more complex check below */
468+
if (real_uid && *real_uid) {
469+
char *endptr = NULL;
470+
unsigned long env_id;
471+
472+
errno = 0;
473+
/* silent overflow errors could trigger a bug here */
474+
env_id = strtoul(real_uid, &endptr, 10);
475+
if (!*endptr && !errno)
476+
*id = env_id;
477+
}
478+
}
479+
436480
static inline int is_path_owned_by_current_uid(const char *path)
437481
{
438482
struct stat st;
483+
uid_t euid;
484+
439485
if (lstat(path, &st))
440486
return 0;
441-
return st.st_uid == geteuid();
487+
488+
euid = geteuid();
489+
if (euid == ROOT_UID)
490+
{
491+
if (st.st_uid == ROOT_UID)
492+
return 1;
493+
else
494+
extract_id_from_env("SUDO_UID", &euid);
495+
}
496+
497+
return st.st_uid == euid;
442498
}
443499

444500
#define is_path_owned_by_current_user is_path_owned_by_current_uid

0 commit comments

Comments
 (0)