Where are the ACL permissions being checked when a file is about to be opened in EXT2?
-
03-06-2021 - |
Question
In the EXT2 file.c
the open file operation (.open)
is being pointed to dquot_file_open
which furthur points to generic_file_open
which is present in fs/open.c
.
The generic_file_open
looks like it just has the below code
int generic_file_open(struct inode * inode, struct file * filp)
{
if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EOVERFLOW;
return 0;
}
Where are the ACL permissions being checked when a file is about to be opened?
When is I googled and went through the code using LXR I found the below path.
do_sys_open -> do_filp_open -> path_openat -> do_last -> may_open -> inode_permission -> do_inode_permission -> generic_permission -> acl_permission_check -> check_acl -> posix_acl_permission
but I could not understand how the .open of EXT2 is linked to do_sys_open.
Any help in letting me know the path to checking the acl permissions during a file open would be greatly appreciated.
Solution
You're looking at it from the wrong end: names like do_sys_open
are system call entry points, and will ultimately go through the VFS layer to find the ext2 open
routine after validating permissions.
OTHER TIPS
I think you got sidetracked by the ACL code; once the permission has been granted, follow nameidata_to_filp
to __dentry_open
:
Within __dentry_open()
:
f->f_op = fops_get(inode->i_fop);
/* ... */
if (!open && f->f_op)
open = f->f_op->open;
if (open) {
error = open(inode, f);
if (error)
goto cleanup_all;
}
This saves the inode->i_fop->open
function pointer to the autovariable open
, then proceeds to call it on the inode
and f
.