lkml.org 
[lkml]   [2015]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] namei: prevent sgid-hardlinks for unmapped gids
On Wed, Nov 04, 2015 at 10:17:06AM -0800, Andy Lutomirski wrote:
> > That said I never feel completely comfortable with changing a file's
> > permissions this way, I always fear it could break backup/restore
> > applications. Let's imagine for a minute that a restore does this :
> >
> > extract(const char *file_name, int file_perms) {
> > fd = open(".tmpfile", O_CREAT, file_perms);
> > mmap(fd);
> > /* actually write file */
> > close(fd);
> > unlink(real_file_name);
> > rename(".tmpfile", file_name);
> > }
> >
> > Yes I know it's not safe to do the chmod before writing to the file
> > but we could imagine some situations where it makes sense to be done
> > this way (eg: if the file is put into a protected directory), and
> > anyway this possibility is provided by open() and creat() so it is
> > legitimate to imagine these ones could exist.
> >
> > Such a change would slightly modify semantics and affect such use cases
> > *if they exist*, just like using write() instead of mmap() would fail.
> > We could imagine having a sysctl to disable this strengthening, but it
> > is probably not the best solution for the long term either.
>
> I'd say that this is an acceptable breakage risk.

Yes probably.

> In any event, the
> potential for data loss is limited to a bit of the file mode,

When this bit is the one sudo's setuid, it becomes one of the most important
bits on the whole system :-)

> and
> restore apps like that really don't deserve to work in the first
> place.

I absolutely agree for this specific case. I just wanted to raise this
case so that we're sure not to oversee anything related to other similar
but more justified use cases.

Willy



\
 
 \ /
  Last update: 2015-11-04 19:41    [W:0.082 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site