提交 6d125529 编写于 作者: A Al Viro

Fix ACC_MODE() for real

commit 5300990c had stepped on a rather
nasty mess: definitions of ACC_MODE used to be different.  Fixed the
resulting breakage, converting them to variant that takes O_... value;
all callers have that and it actually simplifies life (see tomoyo part
of changes).
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 4ecf09fd
...@@ -1620,7 +1620,7 @@ struct file *do_filp_open(int dfd, const char *pathname, ...@@ -1620,7 +1620,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
open_flag |= O_DSYNC; open_flag |= O_DSYNC;
if (!acc_mode) if (!acc_mode)
acc_mode = MAY_OPEN | ACC_MODE(flag); acc_mode = MAY_OPEN | ACC_MODE(open_flag);
/* O_TRUNC implies we need access checks for write permissions */ /* O_TRUNC implies we need access checks for write permissions */
if (flag & O_TRUNC) if (flag & O_TRUNC)
......
...@@ -2463,7 +2463,7 @@ int proc_nr_files(struct ctl_table *table, int write, ...@@ -2463,7 +2463,7 @@ int proc_nr_files(struct ctl_table *table, int write,
int __init get_filesystem_list(char *buf); int __init get_filesystem_list(char *buf);
#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
#define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE)) #define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE))
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -80,9 +80,8 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm) ...@@ -80,9 +80,8 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
return tomoyo_find_next_domain(bprm); return tomoyo_find_next_domain(bprm);
/* /*
* Read permission is checked against interpreters using next domain. * Read permission is checked against interpreters using next domain.
* '1' is the result of open_to_namei_flags(O_RDONLY).
*/ */
return tomoyo_check_open_permission(domain, &bprm->file->f_path, 1); return tomoyo_check_open_permission(domain, &bprm->file->f_path, O_RDONLY);
} }
static int tomoyo_path_truncate(struct path *path, loff_t length, static int tomoyo_path_truncate(struct path *path, loff_t length,
...@@ -184,10 +183,6 @@ static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, ...@@ -184,10 +183,6 @@ static int tomoyo_file_fcntl(struct file *file, unsigned int cmd,
static int tomoyo_dentry_open(struct file *f, const struct cred *cred) static int tomoyo_dentry_open(struct file *f, const struct cred *cred)
{ {
int flags = f->f_flags; int flags = f->f_flags;
if ((flags + 1) & O_ACCMODE)
flags++;
flags |= f->f_flags & (O_APPEND | O_TRUNC);
/* Don't check read permission here if called from do_execve(). */ /* Don't check read permission here if called from do_execve(). */
if (current->in_execve) if (current->in_execve)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册