Re: [RESEND Patch v2] allow file truncations when both suid andwrite permissions set

From: Andrew Morton
Date: Fri Jul 24 2009 - 17:35:44 EST


On Wed, 22 Jul 2009 05:17:02 -0400
Amerigo Wang <amwang@xxxxxxxxxx> wrote:

>
> V1 -> V2:
> Introduce dentry_remove_suid(), and use it in do_truncate().
> Thanks to Eric Paris.
>
>
> When suid is set and the non-owner user has write permission,
> any writing into this file should be allowed and suid should be
> removed after that.
>
> However, current kernel only allows writing without truncations,
> when we do truncations on that file, we get EPERM. This is a bug.
>
> Steps to reproduce this bug:
>
> % ls -l rootdir/file1
> -rwsrwsrwx 1 root root 3 Jun 25 15:42 rootdir/file1
> % echo h > rootdir/file1
> zsh: operation not permitted: rootdir/file1
> % ls -l rootdir/file1
> -rwsrwsrwx 1 root root 3 Jun 25 15:42 rootdir/file1
> % echo h >> rootdir/file1
> % ls -l rootdir/file1
> -rwxrwxrwx 1 root root 5 Jun 25 16:34 rootdir/file1
>
> This patch fixes it.

Thanks, I queued this up for Al's consideration.

> Signed-off-by: WANG Cong <amwang@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxx
> Cc: Eric Sandeen <esandeen@xxxxxxxxxx>
> Cc: Eric Paris <eparis@xxxxxxxxxx>
> Cc: Eugene Teo <eteo@xxxxxxxxxx>
> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

I removed the Cc:stable. I'm not really sure whether we want to
backport this.

In fact I'm not really sure that we want to merge it at all. It
introduces the risk that people will develope, test and ship
applications which malfunction when run on older kernels.

otoh we already have the risk that people's applications will run OK on
other OS's and will malfunction on Linux, and the patch fixes this.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/