Whamcloud - gitweb
LU-13119 osd-ldiskfs: set f_cred for app armour 84/37184/4
authorJames Simmons <jsimmons@infradead.org>
Fri, 10 Jan 2020 14:30:47 +0000 (09:30 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Jan 2020 05:32:07 +0000 (05:32 +0000)
The function interate_dir() interfaces with the security layer.
For some kernel versions on platforms that use app armour it
expects f_cred to be set. Currently osd-ldiskfs open codes the
creation of struct file so it is missing a cred. Fix this by
setting f_cred to the default current_cred().

Test-Parameters: testlist=sanity-lfsck serverdistro=sles12sp3

Change-Id: I38487e8ae99a0f70d6e430935b7d19523d414b4b
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/37184
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_scrub.c

index 466da64..1b71fc6 100644 (file)
@@ -1012,6 +1012,7 @@ again:
        filp->f_mapping = inode->i_mapping;
        filp->f_op = fops;
        filp->private_data = NULL;
        filp->f_mapping = inode->i_mapping;
        filp->f_op = fops;
        filp->private_data = NULL;
+       filp->f_cred = current_cred();
        set_file_inode(filp, inode);
        rc = osd_security_file_alloc(filp);
        if (rc)
        set_file_inode(filp, inode);
        rc = osd_security_file_alloc(filp);
        if (rc)
@@ -6621,6 +6622,7 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
                down_read(&obj->oo_ext_idx_sem);
        }
 
                down_read(&obj->oo_ext_idx_sem);
        }
 
+       filp->f_cred = current_cred();
        rc = osd_security_file_alloc(filp);
        if (rc)
                RETURN(rc);
        rc = osd_security_file_alloc(filp);
        if (rc)
                RETURN(rc);
index b692261..63c295b 100644 (file)
@@ -2263,6 +2263,7 @@ osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev,
        filp->f_mapping = inode->i_mapping;
        filp->f_op = fops;
        filp->private_data = NULL;
        filp->f_mapping = inode->i_mapping;
        filp->f_op = fops;
        filp->private_data = NULL;
+       filp->f_cred = current_cred();
        set_file_inode(filp, inode);
        rc = osd_security_file_alloc(filp);
        if (rc)
        set_file_inode(filp, inode);
        rc = osd_security_file_alloc(filp);
        if (rc)