->file_open(): lose cred argument
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Jul 2018 18:13:18 +0000 (14:13 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 12 Jul 2018 14:04:15 +0000 (10:04 -0400)
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
include/linux/lsm_hooks.h
security/apparmor/lsm.c
security/security.c
security/selinux/hooks.c
security/smack/smack_lsm.c
security/tomoyo/tomoyo.c

index 8f1131c..a8ee106 100644 (file)
@@ -1569,7 +1569,7 @@ union security_list_options {
        int (*file_send_sigiotask)(struct task_struct *tsk,
                                        struct fown_struct *fown, int sig);
        int (*file_receive)(struct file *file);
-       int (*file_open)(struct file *file, const struct cred *cred);
+       int (*file_open)(struct file *file);
 
        int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
        void (*task_free)(struct task_struct *task);
index 74f1737..8b8b706 100644 (file)
@@ -395,7 +395,7 @@ static int apparmor_inode_getattr(const struct path *path)
        return common_perm_cond(OP_GETATTR, path, AA_MAY_GETATTR);
 }
 
-static int apparmor_file_open(struct file *file, const struct cred *cred)
+static int apparmor_file_open(struct file *file)
 {
        struct aa_file_ctx *fctx = file_ctx(file);
        struct aa_label *label;
@@ -414,7 +414,7 @@ static int apparmor_file_open(struct file *file, const struct cred *cred)
                return 0;
        }
 
-       label = aa_get_newest_cred_label(cred);
+       label = aa_get_newest_cred_label(file->f_cred);
        if (!unconfined(label)) {
                struct inode *inode = file_inode(file);
                struct path_cond cond = { inode->i_uid, inode->i_mode };
index 235b35f..5dce670 100644 (file)
@@ -974,7 +974,7 @@ int security_file_open(struct file *file)
 {
        int ret;
 
-       ret = call_int_hook(file_open, 0, file, file->f_cred);
+       ret = call_int_hook(file_open, 0, file);
        if (ret)
                return ret;
 
index 2b5ee5f..18006be 100644 (file)
@@ -3862,7 +3862,7 @@ static int selinux_file_receive(struct file *file)
        return file_has_perm(cred, file, file_to_av(file));
 }
 
-static int selinux_file_open(struct file *file, const struct cred *cred)
+static int selinux_file_open(struct file *file)
 {
        struct file_security_struct *fsec;
        struct inode_security_struct *isec;
@@ -3886,7 +3886,7 @@ static int selinux_file_open(struct file *file, const struct cred *cred)
         * new inode label or new policy.
         * This check is not redundant - do not remove.
         */
-       return file_path_has_perm(cred, file, open_file_to_av(file));
+       return file_path_has_perm(file->f_cred, file, open_file_to_av(file));
 }
 
 /* task security operations */
index 7ad2260..e7b6c01 100644 (file)
@@ -1927,9 +1927,9 @@ static int smack_file_receive(struct file *file)
  *
  * Returns 0
  */
-static int smack_file_open(struct file *file, const struct cred *cred)
+static int smack_file_open(struct file *file)
 {
-       struct task_smack *tsp = cred->security;
+       struct task_smack *tsp = file->f_cred->security;
        struct inode *inode = file_inode(file);
        struct smk_audit_info ad;
        int rc;
@@ -1937,7 +1937,7 @@ static int smack_file_open(struct file *file, const struct cred *cred)
        smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
        smk_ad_setfield_u_fs_path(&ad, file->f_path);
        rc = smk_tskacc(tsp, smk_of_inode(inode), MAY_READ, &ad);
-       rc = smk_bu_credfile(cred, file, MAY_READ, rc);
+       rc = smk_bu_credfile(file->f_cred, file, MAY_READ, rc);
 
        return rc;
 }
index 213b8c5..9f932e2 100644 (file)
@@ -320,7 +320,7 @@ static int tomoyo_file_fcntl(struct file *file, unsigned int cmd,
  *
  * Returns 0 on success, negative value otherwise.
  */
-static int tomoyo_file_open(struct file *f, const struct cred *cred)
+static int tomoyo_file_open(struct file *f)
 {
        int flags = f->f_flags;
        /* Don't check read permission here if called from do_execve(). */