mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
Merge branch 'work.open3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs open-related updates from Al Viro:
- "do we need fput() or put_filp()" rules are gone - it's always fput()
now. We keep track of that state where it belongs - in ->f_mode.
- int *opened mess killed - in finish_open(), in ->atomic_open()
instances and in fs/namei.c code around do_last()/lookup_open()/atomic_open().
- alloc_file() wrappers with saner calling conventions are introduced
(alloc_file_clone() and alloc_file_pseudo()); callers converted, with
much simplification.
- while we are at it, saner calling conventions for path_init() and
link_path_walk(), simplifying things inside fs/namei.c (both on
open-related paths and elsewhere).
* 'work.open3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits)
few more cleanups of link_path_walk() callers
allow link_path_walk() to take ERR_PTR()
make path_init() unconditionally paired with terminate_walk()
document alloc_file() changes
make alloc_file() static
do_shmat(): grab shp->shm_file earlier, switch to alloc_file_clone()
new helper: alloc_file_clone()
create_pipe_files(): switch the first allocation to alloc_file_pseudo()
anon_inode_getfile(): switch to alloc_file_pseudo()
hugetlb_file_setup(): switch to alloc_file_pseudo()
ocxlflash_getfile(): switch to alloc_file_pseudo()
cxl_getfile(): switch to alloc_file_pseudo()
... and switch shmem_file_setup() to alloc_file_pseudo()
__shmem_file_setup(): reorder allocations
new wrapper: alloc_file_pseudo()
kill FILE_{CREATED,OPENED}
switch atomic_open() and lookup_open() to returning 0 in all success cases
document ->atomic_open() changes
->atomic_open(): return 0 in all success cases
get rid of 'opened' in path_openat() and the helpers downstream
...
This commit is contained in:
commit
a66b4cd1e7
45 changed files with 371 additions and 576 deletions
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ int ima_appraise_measurement(enum ima_hooks func,
|
|||
struct integrity_iint_cache *iint,
|
||||
struct file *file, const unsigned char *filename,
|
||||
struct evm_ima_xattr_data *xattr_value,
|
||||
int xattr_len, int opened);
|
||||
int xattr_len);
|
||||
int ima_must_appraise(struct inode *inode, int mask, enum ima_hooks func);
|
||||
void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file);
|
||||
enum integrity_status ima_get_cache_status(struct integrity_iint_cache *iint,
|
||||
|
|
@ -254,7 +254,7 @@ static inline int ima_appraise_measurement(enum ima_hooks func,
|
|||
struct file *file,
|
||||
const unsigned char *filename,
|
||||
struct evm_ima_xattr_data *xattr_value,
|
||||
int xattr_len, int opened)
|
||||
int xattr_len)
|
||||
{
|
||||
return INTEGRITY_UNKNOWN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ int ima_appraise_measurement(enum ima_hooks func,
|
|||
struct integrity_iint_cache *iint,
|
||||
struct file *file, const unsigned char *filename,
|
||||
struct evm_ima_xattr_data *xattr_value,
|
||||
int xattr_len, int opened)
|
||||
int xattr_len)
|
||||
{
|
||||
static const char op[] = "appraise_data";
|
||||
const char *cause = "unknown";
|
||||
|
|
@ -231,7 +231,7 @@ int ima_appraise_measurement(enum ima_hooks func,
|
|||
cause = iint->flags & IMA_DIGSIG_REQUIRED ?
|
||||
"IMA-signature-required" : "missing-hash";
|
||||
status = INTEGRITY_NOLABEL;
|
||||
if (opened & FILE_CREATED)
|
||||
if (file->f_mode & FMODE_CREATED)
|
||||
iint->flags |= IMA_NEW_FILE;
|
||||
if ((iint->flags & IMA_NEW_FILE) &&
|
||||
(!(iint->flags & IMA_DIGSIG_REQUIRED) ||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ void ima_file_free(struct file *file)
|
|||
|
||||
static int process_measurement(struct file *file, const struct cred *cred,
|
||||
u32 secid, char *buf, loff_t size, int mask,
|
||||
enum ima_hooks func, int opened)
|
||||
enum ima_hooks func)
|
||||
{
|
||||
struct inode *inode = file_inode(file);
|
||||
struct integrity_iint_cache *iint = NULL;
|
||||
|
|
@ -294,7 +294,7 @@ static int process_measurement(struct file *file, const struct cred *cred,
|
|||
if (rc == 0 && (action & IMA_APPRAISE_SUBMASK)) {
|
||||
inode_lock(inode);
|
||||
rc = ima_appraise_measurement(func, iint, file, pathname,
|
||||
xattr_value, xattr_len, opened);
|
||||
xattr_value, xattr_len);
|
||||
inode_unlock(inode);
|
||||
}
|
||||
if (action & IMA_AUDIT)
|
||||
|
|
@ -338,7 +338,7 @@ int ima_file_mmap(struct file *file, unsigned long prot)
|
|||
if (file && (prot & PROT_EXEC)) {
|
||||
security_task_getsecid(current, &secid);
|
||||
return process_measurement(file, current_cred(), secid, NULL,
|
||||
0, MAY_EXEC, MMAP_CHECK, 0);
|
||||
0, MAY_EXEC, MMAP_CHECK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -364,13 +364,13 @@ int ima_bprm_check(struct linux_binprm *bprm)
|
|||
|
||||
security_task_getsecid(current, &secid);
|
||||
ret = process_measurement(bprm->file, current_cred(), secid, NULL, 0,
|
||||
MAY_EXEC, BPRM_CHECK, 0);
|
||||
MAY_EXEC, BPRM_CHECK);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
security_cred_getsecid(bprm->cred, &secid);
|
||||
return process_measurement(bprm->file, bprm->cred, secid, NULL, 0,
|
||||
MAY_EXEC, CREDS_CHECK, 0);
|
||||
MAY_EXEC, CREDS_CHECK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -383,14 +383,14 @@ int ima_bprm_check(struct linux_binprm *bprm)
|
|||
* On success return 0. On integrity appraisal error, assuming the file
|
||||
* is in policy and IMA-appraisal is in enforcing mode, return -EACCES.
|
||||
*/
|
||||
int ima_file_check(struct file *file, int mask, int opened)
|
||||
int ima_file_check(struct file *file, int mask)
|
||||
{
|
||||
u32 secid;
|
||||
|
||||
security_task_getsecid(current, &secid);
|
||||
return process_measurement(file, current_cred(), secid, NULL, 0,
|
||||
mask & (MAY_READ | MAY_WRITE | MAY_EXEC |
|
||||
MAY_APPEND), FILE_CHECK, opened);
|
||||
MAY_APPEND), FILE_CHECK);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ima_file_check);
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ int ima_post_read_file(struct file *file, void *buf, loff_t size,
|
|||
func = read_idmap[read_id] ?: FILE_CHECK;
|
||||
security_task_getsecid(current, &secid);
|
||||
return process_measurement(file, current_cred(), secid, buf, size,
|
||||
MAY_READ, func, 0);
|
||||
MAY_READ, func);
|
||||
}
|
||||
|
||||
static int __init init_ima(void)
|
||||
|
|
|
|||
|
|
@ -970,11 +970,11 @@ int security_file_receive(struct file *file)
|
|||
return call_int_hook(file_receive, 0, file);
|
||||
}
|
||||
|
||||
int security_file_open(struct file *file, const struct cred *cred)
|
||||
int security_file_open(struct file *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = call_int_hook(file_open, 0, file, cred);
|
||||
ret = call_int_hook(file_open, 0, file);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(). */
|
||||
|
|
|
|||
Loading…
Reference in a new issue