函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:security\smack\smack_lsm.c Create Date:2022-07-27 20:50:40
首页 Copyright©Brick

1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
/**
 * smack_file_open - Smack dentry open processing
 * @file: the object
 *
 * Set the security blob in the file structure.
 * Allow the open only if the task has read access. There are
 * many read operations (e.g. fstat) that you can do with an
 * fd even if you have the file open write-only.
 *
 * Returns 0 if current has access, error code otherwise
 */
static int smack_file_open(struct file *file)
{
    struct task_smack *tsp = smack_cred(file->f_cred);
    struct inode *inode = file_inode(file);
    struct smk_audit_info ad;
    int rc;
 
    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(file->f_cred, file, MAY_READ, rc);
 
    return rc;
}