2006-09-13 05:34:19

by David Wagner

[permalink] [raw]
Subject: Re: R: Linux kernel source archive vulnerable

Willy Tarreau wrote:
>The initial reason is that Linus now uses the "git-tar-tree" command
>which creates the full tar archive from the tree. It does not use tar,
>it know how to produce the tar format itself. The command has to set
>permissions on the files, and by default, it sets full permissions to
>the files.

Ahh, thanks for the explanation. That's helpful.

So it sounds like git-tar-tree has a bug; its default isn't setting
meaningful permissions on the files that it puts into the tar archive.
I hope the maintainers of git-tar-tree will consider fixing this bug.


2006-09-13 06:17:36

by Kyle Moffett

[permalink] [raw]
Subject: Re: R: Linux kernel source archive vulnerable

On Sep 13, 2006, at 01:34:01, David Wagner wrote:
> Willy Tarreau wrote:
>> The initial reason is that Linus now uses the "git-tar-tree" command
>> which creates the full tar archive from the tree. It does not use
>> tar,
>> it know how to produce the tar format itself. The command has to set
>> permissions on the files, and by default, it sets full permissions to
>> the files.
>
> Ahh, thanks for the explanation. That's helpful.
>
> So it sounds like git-tar-tree has a bug; its default isn't setting
> meaningful permissions on the files that it puts into the tar archive.
> I hope the maintainers of git-tar-tree will consider fixing this bug.

Let me reiterate: This is not a bug!

Here are a few facts:

1) When I run "touch foo", the "touch" command uses permissions
0666, which are modified by my umask before hitting the FS. (same
behavior for all UIDs)

2) When I run "gcc -c foo.c -o foo.o", the "gcc" command uses
permissions 0666, which are modified by my umask before hitting the
FS. (same behavior for all UIDs)

3) When I run "vim foo.c", the "vim" command uses permissions 0666
for new files, which are modified by my umask before hitting the FS.
(same behavior for all UIDs)

4) When I run "tar -xvf foo.tar" as a normal user, the "tar" command
uses permissions from the archive for new files, which are modified
by my umask before hitting the FS.

5) Do you see the pattern here?


Now when I run that tar command as root, for some reason they assume
that just because my UID is 0 I want to try to ignore my umask while
extracting my j_random.tar file. How does this follow from the
behavior of any other programs mentioned above?

The program "git-tar-tree" has no bug. It creates the tar archive
such that when extracted as a normal user the users' umask is applied
exactly as for every other standard program. If anything the "bug"
is in tar assuming that every archive file extracted as UID 0 is a
backup, or in the admin assuming that tar doesn't behave differently
when run as UID 0.

Cheers,
Kyle Moffett

2006-09-13 06:27:48

by Jan Engelhardt

[permalink] [raw]
Subject: Re: R: Linux kernel source archive vulnerable

>>
>> Ahh, thanks for the explanation. That's helpful.
>>
>> So it sounds like git-tar-tree has a bug; its default isn't setting
>> meaningful permissions on the files that it puts into the tar archive.
>> I hope the maintainers of git-tar-tree will consider fixing this bug.
>
> Let me reiterate: This is not a bug!
>
> Here are a few facts:
>
> 4) When I run "tar -xvf foo.tar" as a normal user, the "tar" command uses
> permissions from the archive for new files, which are modified by my umask
> before hitting the FS.
>
> 5) Do you see the pattern here?
>
> Now when I run that tar command as root, for some reason they assume that just
> because my UID is 0 I want to try to ignore my umask while extracting my
> j_random.tar file. How does this follow from the behavior of any other
> programs mentioned above?

> The program "git-tar-tree" has no bug. It creates the tar archive such that
> when extracted as a normal user the users' umask is applied exactly as for
> every other standard program. If anything the "bug" is in tar assuming that
> every archive file extracted as UID 0 is a backup, or in the admin assuming
> that tar doesn't behave differently when run as UID 0.

The 'complaint' made is that while the tar archive is created, 0666 gets
written into it. However, most software projects out there always make sure
that files are 0644 before tar -cvf'ing their tree.


Jan Engelhardt
--

2006-09-13 19:58:20

by Willy Tarreau

[permalink] [raw]
Subject: Re: R: Linux kernel source archive vulnerable

On Wed, Sep 13, 2006 at 08:26:57AM +0200, Jan Engelhardt wrote:
> >>
> >> Ahh, thanks for the explanation. That's helpful.
> >>
> >> So it sounds like git-tar-tree has a bug; its default isn't setting
> >> meaningful permissions on the files that it puts into the tar archive.
> >> I hope the maintainers of git-tar-tree will consider fixing this bug.
> >
> > Let me reiterate: This is not a bug!
> >
> > Here are a few facts:
> >
> > 4) When I run "tar -xvf foo.tar" as a normal user, the "tar" command uses
> > permissions from the archive for new files, which are modified by my umask
> > before hitting the FS.
> >
> > 5) Do you see the pattern here?
> >
> > Now when I run that tar command as root, for some reason they assume that just
> > because my UID is 0 I want to try to ignore my umask while extracting my
> > j_random.tar file. How does this follow from the behavior of any other
> > programs mentioned above?
>
> > The program "git-tar-tree" has no bug. It creates the tar archive such that
> > when extracted as a normal user the users' umask is applied exactly as for
> > every other standard program. If anything the "bug" is in tar assuming that
> > every archive file extracted as UID 0 is a backup, or in the admin assuming
> > that tar doesn't behave differently when run as UID 0.
>
> The 'complaint' made is that while the tar archive is created, 0666 gets
> written into it.

Let me repeat it : git-tar-tree can use a umask to set something different.

> However, most software projects out there always make sure
> that files are 0644 before tar -cvf'ing their tree.

The real problem IMHO is that many people got used for 10 years to receive
kernels packaged by user 'linus' with perms 0644, and suddenly their
(discutable) habits are considerably upset because of what initially was
a limitation in the tool, which was argumented as a feature and might not
change anytime now.

Moral of the story : do not ever try to convince Linus he's wrong
when you disagree with him, because the argument he will give you
will quickly become desired features :-)

> Jan Engelhardt

Regards,
Willy