]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ovl: get_write_access() in truncate
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 29 Jun 2016 14:03:55 +0000 (16:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 15:42:23 +0000 (08:42 -0700)
commita7ed367c5cf3d455b8c3b85b2f6c222f01dddea1
tree16bf871dfb8923ed8fb22775e96ca3d6fc6bd72a
parentd5af2e4f46114089298ecae619ba1dbcc04d0135
ovl: get_write_access() in truncate

commit 03bea60409328de54e4ff7ec41672e12a9cb0908 upstream.

When truncating a file we should check write access on the underlying
inode.  And we should do so on the lower file as well (before copy-up) for
consistency.

Original patch and test case by Aihua Zhang.

 - - >o >o - - test.c - - >o >o - -
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
int ret;

ret = truncate(argv[0], 4096);
if (ret != -1) {
fprintf(stderr, "truncate(argv[0]) should have failed\n");
return 1;
}
if (errno != ETXTBSY) {
perror("truncate(argv[0])");
return 1;
}

return 0;
}
 - - >o >o - - >o >o - - >o >o - -

Reported-by: Aihua Zhang <zhangaihua1@huawei.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/overlayfs/inode.c