All of lore.kernel.org
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>, git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, junio@pobox.com
Subject: Re: [PATCH v2] setup: tighten ownership checks post CVE-2022-24765
Date: Thu, 5 May 2022 09:58:57 -0400	[thread overview]
Message-ID: <281017cb-0078-0635-8a3b-fed430b5439a@github.com> (raw)
In-Reply-To: <0f9aaada-8e72-38b9-e58a-9b26ed7bc780@github.com>

On 5/5/2022 9:14 AM, Derrick Stolee wrote:
> On 5/4/2022 8:50 PM, Carlo Marcelo Arenas Belón wrote:
>> -static int ensure_valid_ownership(const char *path)
>> +static int ensure_valid_ownership(const char *worktree, const char *gitdir)
>>  {
>> -	struct safe_directory_data data = { .path = path };
>> +	struct safe_directory_data data = { .path = worktree };

This also seems a bit backwards to me. I think bare repos will have a NULL
worktree, but all repos will have a gitdir. I think what we really want
is this:

	.path = worktree ? worktree : gitdir

And that might affect the callers of this method allowing the worktree to
be NULL.

> I think you should remove check_path and instead do the following:
> 
> 	if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
> 	    is_path_owned_by_current_user(worktree) &&
> 	    (!gitdir || is_path_owned_by_current_user(gitdir)))
>  		return 1;

But that changes my logic here to instead be

 	if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
	    is_path_owned_by_current_user(gitdir) &&
	    (!worktree|| is_path_owned_by_current_user(worktree)))
  		return 1;

Thanks,
-Stolee

      reply	other threads:[~2022-05-05 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220504184401.17438-1-carenas@gmail.com>
2022-05-05  0:50 ` [PATCH v2] setup: tighten ownership checks post CVE-2022-24765 Carlo Marcelo Arenas Belón
2022-05-05  9:40   ` Phillip Wood
2022-05-05 12:04     ` Phillip Wood
2022-05-05 13:14   ` Derrick Stolee
2022-05-05 13:58     ` Derrick Stolee [this message]

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

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

  git send-email \
    --in-reply-to=281017cb-0078-0635-8a3b-fed430b5439a@github.com \
    --to=derrickstolee@github.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junio@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.