From 78757af6518a35bdc22b4e7f660ff9dbbeba35d7 Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Sat, 8 Apr 2017 14:49:06 +0300 Subject: vfs: ftruncate check IS_APPEND() on real upper inode ftruncate an overlayfs inode was checking IS_APPEND() on overlay inode, but overlay inode does not have the S_APPEND flag. Check IS_APPEND() on real upper inode instead. Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/open.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/open.c') diff --git a/fs/open.c b/fs/open.c index 949cef29c3bb..993a91d20cc7 100644 --- a/fs/open.c +++ b/fs/open.c @@ -193,7 +193,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small) goto out_putf; error = -EPERM; - if (IS_APPEND(inode)) + /* Check IS_APPEND on real upper inode */ + if (IS_APPEND(file_inode(f.file))) goto out_putf; sb_start_write(inode->i_sb); -- cgit v1.2.3 From 159b095628851966b5fbf2637b0c40709911ca88 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 15 Apr 2017 15:58:56 -0400 Subject: make sure that fchdir() won't accept referral points, etc. Signed-off-by: Al Viro --- fs/open.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'fs/open.c') diff --git a/fs/open.c b/fs/open.c index 949cef29c3bb..9f4bbd7cc51a 100644 --- a/fs/open.c +++ b/fs/open.c @@ -459,20 +459,17 @@ out: SYSCALL_DEFINE1(fchdir, unsigned int, fd) { struct fd f = fdget_raw(fd); - struct inode *inode; - int error = -EBADF; + int error; error = -EBADF; if (!f.file) goto out; - inode = file_inode(f.file); - error = -ENOTDIR; - if (!S_ISDIR(inode->i_mode)) + if (!d_can_lookup(f.file->f_path.dentry)) goto out_putf; - error = inode_permission(inode, MAY_EXEC | MAY_CHDIR); + error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR); if (!error) set_fs_pwd(current->fs, &f.file->f_path); out_putf: -- cgit v1.2.3