open.c (7f2da1e7d0330395e5e9e350b879b98a1ea495df) open.c (a110343f0d6d41f68b7cf8c00b57a3172c67f816)
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>

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

452 */
453#endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */
454 if (current->uid)
455 old_cap = cap_set_effective(__cap_empty_set);
456 else
457 old_cap = cap_set_effective(current->cap_permitted);
458 }
459
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>

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

452 */
453#endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */
454 if (current->uid)
455 old_cap = cap_set_effective(__cap_empty_set);
456 else
457 old_cap = cap_set_effective(current->cap_permitted);
458 }
459
460 res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
460 res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
461 if (res)
462 goto out;
463
461 if (res)
462 goto out;
463
464 res = vfs_permission(&nd, mode);
464 res = vfs_permission(&nd, mode | MAY_ACCESS);
465 /* SuS v2 requires we report a read only fs too */
466 if(res || !(mode & S_IWOTH) ||
467 special_file(nd.path.dentry->d_inode->i_mode))
468 goto out_path_release;
469 /*
470 * This is a rare case where using __mnt_is_readonly()
471 * is OK without a mnt_want/drop_write() pair. Since
472 * no actual write to the fs is performed here, we do

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

500{
501 struct nameidata nd;
502 int error;
503
504 error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
505 if (error)
506 goto out;
507
465 /* SuS v2 requires we report a read only fs too */
466 if(res || !(mode & S_IWOTH) ||
467 special_file(nd.path.dentry->d_inode->i_mode))
468 goto out_path_release;
469 /*
470 * This is a rare case where using __mnt_is_readonly()
471 * is OK without a mnt_want/drop_write() pair. Since
472 * no actual write to the fs is performed here, we do

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

500{
501 struct nameidata nd;
502 int error;
503
504 error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
505 if (error)
506 goto out;
507
508 error = vfs_permission(&nd, MAY_EXEC | MAY_CHDIR);
508 error = vfs_permission(&nd, MAY_EXEC | MAY_ACCESS);
509 if (error)
510 goto dput_and_out;
511
512 set_fs_pwd(current->fs, &nd.path);
513
514dput_and_out:
515 path_put(&nd.path);
516out:

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

529 goto out;
530
531 inode = file->f_path.dentry->d_inode;
532
533 error = -ENOTDIR;
534 if (!S_ISDIR(inode->i_mode))
535 goto out_putf;
536
509 if (error)
510 goto dput_and_out;
511
512 set_fs_pwd(current->fs, &nd.path);
513
514dput_and_out:
515 path_put(&nd.path);
516out:

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

529 goto out;
530
531 inode = file->f_path.dentry->d_inode;
532
533 error = -ENOTDIR;
534 if (!S_ISDIR(inode->i_mode))
535 goto out_putf;
536
537 error = file_permission(file, MAY_EXEC);
537 error = file_permission(file, MAY_EXEC | MAY_ACCESS);
538 if (!error)
539 set_fs_pwd(current->fs, &file->f_path);
540out_putf:
541 fput(file);
542out:
543 return error;
544}
545
546asmlinkage long sys_chroot(const char __user * filename)
547{
548 struct nameidata nd;
549 int error;
550
551 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd);
552 if (error)
553 goto out;
554
538 if (!error)
539 set_fs_pwd(current->fs, &file->f_path);
540out_putf:
541 fput(file);
542out:
543 return error;
544}
545
546asmlinkage long sys_chroot(const char __user * filename)
547{
548 struct nameidata nd;
549 int error;
550
551 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd);
552 if (error)
553 goto out;
554
555 error = vfs_permission(&nd, MAY_EXEC);
555 error = vfs_permission(&nd, MAY_EXEC | MAY_ACCESS);
556 if (error)
557 goto dput_and_out;
558
559 error = -EPERM;
560 if (!capable(CAP_SYS_CHROOT))
561 goto dput_and_out;
562
563 set_fs_root(current->fs, &nd.path);

--- 686 unchanged lines hidden ---
556 if (error)
557 goto dput_and_out;
558
559 error = -EPERM;
560 if (!capable(CAP_SYS_CHROOT))
561 goto dput_and_out;
562
563 set_fs_root(current->fs, &nd.path);

--- 686 unchanged lines hidden ---