]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/open.c
KVM: arm64: vgic-v3: Log which GICv3 system registers are trapped
[linux.git] / fs / open.c
index 4d23f729dcc6979e4d62ba9c7b3258b7adb37eb1..cd0c5be8d01247e8bab3f4e00e6f171803291881 100644 (file)
--- 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);
@@ -459,20 +460,17 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename)
 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:
@@ -900,6 +898,12 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
        int lookup_flags = 0;
        int acc_mode = ACC_MODE(flags);
 
+       /*
+        * Clear out all open flags we don't know about so that we don't report
+        * them in fcntl(F_GETFD) or similar interfaces.
+        */
+       flags &= VALID_OPEN_FLAGS;
+
        if (flags & (O_CREAT | __O_TMPFILE))
                op->mode = (mode & S_IALLUGO) | S_IFREG;
        else