open.c (b8297cec2da30d3a5869597dbd7c8280d46a7dba) open.c (c7b96acf1456ef127fef461fcfedb54b81fecfbb)
1/*
2 * linux/fs/open.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <linux/string.h>
8#include <linux/mm.h>

--- 429 unchanged lines hidden (view full) ---

438 if (error)
439 goto out;
440
441 error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
442 if (error)
443 goto dput_and_out;
444
445 error = -EPERM;
1/*
2 * linux/fs/open.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <linux/string.h>
8#include <linux/mm.h>

--- 429 unchanged lines hidden (view full) ---

438 if (error)
439 goto out;
440
441 error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
442 if (error)
443 goto dput_and_out;
444
445 error = -EPERM;
446 if (!nsown_capable(CAP_SYS_CHROOT))
446 if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
447 goto dput_and_out;
448 error = security_path_chroot(&path);
449 if (error)
450 goto dput_and_out;
451
452 set_fs_root(current->fs, &path);
453 error = 0;
454dput_and_out:

--- 363 unchanged lines hidden (view full) ---

818}
819EXPORT_SYMBOL(dentry_open);
820
821static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
822{
823 int lookup_flags = 0;
824 int acc_mode;
825
447 goto dput_and_out;
448 error = security_path_chroot(&path);
449 if (error)
450 goto dput_and_out;
451
452 set_fs_root(current->fs, &path);
453 error = 0;
454dput_and_out:

--- 363 unchanged lines hidden (view full) ---

818}
819EXPORT_SYMBOL(dentry_open);
820
821static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
822{
823 int lookup_flags = 0;
824 int acc_mode;
825
826 if (flags & (O_CREAT | __O_TMPFILE))
826 if (flags & O_CREAT)
827 op->mode = (mode & S_IALLUGO) | S_IFREG;
828 else
829 op->mode = 0;
830
831 /* Must never be set by userspace */
832 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
833
834 /*

--- 4 unchanged lines hidden (view full) ---

839 */
840 if (flags & __O_SYNC)
841 flags |= O_DSYNC;
842
843 if (flags & __O_TMPFILE) {
844 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
845 return -EINVAL;
846 acc_mode = MAY_OPEN | ACC_MODE(flags);
827 op->mode = (mode & S_IALLUGO) | S_IFREG;
828 else
829 op->mode = 0;
830
831 /* Must never be set by userspace */
832 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
833
834 /*

--- 4 unchanged lines hidden (view full) ---

839 */
840 if (flags & __O_SYNC)
841 flags |= O_DSYNC;
842
843 if (flags & __O_TMPFILE) {
844 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
845 return -EINVAL;
846 acc_mode = MAY_OPEN | ACC_MODE(flags);
847 if (!(acc_mode & MAY_WRITE))
848 return -EINVAL;
849 } else if (flags & O_PATH) {
850 /*
851 * If we have O_PATH in the open flag. Then we
852 * cannot have anything other than the below set of flags
853 */
854 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
855 acc_mode = 0;
856 } else {

--- 229 unchanged lines hidden ---
847 } else if (flags & O_PATH) {
848 /*
849 * If we have O_PATH in the open flag. Then we
850 * cannot have anything other than the below set of flags
851 */
852 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
853 acc_mode = 0;
854 } else {

--- 229 unchanged lines hidden ---