提交 69de6a9f 编写于 作者: M Miklos Szeredi 提交者: Jialin Zhang

vfs: add rcu argument to ->get_acl() callback

mainline inclusion
from mainline-v5.15-rc1
commit 0cad6246
category: perf
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ZCW0
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cad6246621b5887d5b33fea84219d2a71f2f99a

--------------------------------

Add a rcu argument to the ->get_acl() callback to allow
get_cached_acl_rcu() to call the ->get_acl() method in the next patch.
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
[chengzhihao: rename get_acl to get_acl2 to prevent KABI changes, and
 only backport(realize) overlayfs]
Conflicts:
	fs/overlayfs/dir.c
	fs/overlayfs/inode.c
	fs/overlayfs/overlayfs.h
	fs/posix_acl.c
	include/linux/fs.h
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
上级 bdcf9ff5
...@@ -1303,6 +1303,6 @@ const struct inode_operations ovl_dir_inode_operations = { ...@@ -1303,6 +1303,6 @@ const struct inode_operations ovl_dir_inode_operations = {
.permission = ovl_permission, .permission = ovl_permission,
.getattr = ovl_getattr, .getattr = ovl_getattr,
.listxattr = ovl_listxattr, .listxattr = ovl_listxattr,
.get_acl = ovl_get_acl, .get_acl2 = ovl_get_acl,
.update_time = ovl_update_time, .update_time = ovl_update_time,
}; };
...@@ -441,12 +441,15 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) ...@@ -441,12 +441,15 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
return res; return res;
} }
struct posix_acl *ovl_get_acl(struct inode *inode, int type) struct posix_acl *ovl_get_acl(struct inode *inode, int type, bool rcu)
{ {
struct inode *realinode = ovl_inode_real(inode); struct inode *realinode = ovl_inode_real(inode);
const struct cred *old_cred; const struct cred *old_cred;
struct posix_acl *acl; struct posix_acl *acl;
if (rcu)
return ERR_PTR(-ECHILD);
if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode)) if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
return NULL; return NULL;
...@@ -496,7 +499,7 @@ static const struct inode_operations ovl_file_inode_operations = { ...@@ -496,7 +499,7 @@ static const struct inode_operations ovl_file_inode_operations = {
.permission = ovl_permission, .permission = ovl_permission,
.getattr = ovl_getattr, .getattr = ovl_getattr,
.listxattr = ovl_listxattr, .listxattr = ovl_listxattr,
.get_acl = ovl_get_acl, .get_acl2 = ovl_get_acl,
.update_time = ovl_update_time, .update_time = ovl_update_time,
.fiemap = ovl_fiemap, .fiemap = ovl_fiemap,
}; };
...@@ -514,7 +517,7 @@ static const struct inode_operations ovl_special_inode_operations = { ...@@ -514,7 +517,7 @@ static const struct inode_operations ovl_special_inode_operations = {
.permission = ovl_permission, .permission = ovl_permission,
.getattr = ovl_getattr, .getattr = ovl_getattr,
.listxattr = ovl_listxattr, .listxattr = ovl_listxattr,
.get_acl = ovl_get_acl, .get_acl2 = ovl_get_acl,
.update_time = ovl_update_time, .update_time = ovl_update_time,
}; };
......
...@@ -466,7 +466,7 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name, ...@@ -466,7 +466,7 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name,
int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name, int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
void *value, size_t size); void *value, size_t size);
ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
struct posix_acl *ovl_get_acl(struct inode *inode, int type); struct posix_acl *ovl_get_acl(struct inode *inode, int type, bool rcu);
int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags); int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags);
bool ovl_is_private_xattr(struct super_block *sb, const char *name); bool ovl_is_private_xattr(struct super_block *sb, const char *name);
......
...@@ -134,11 +134,14 @@ struct posix_acl *get_acl(struct inode *inode, int type) ...@@ -134,11 +134,14 @@ struct posix_acl *get_acl(struct inode *inode, int type)
* If the filesystem doesn't have a get_acl() function at all, we'll * If the filesystem doesn't have a get_acl() function at all, we'll
* just create the negative cache entry. * just create the negative cache entry.
*/ */
if (!inode->i_op->get_acl) { if (!inode->i_op->get_acl && !inode->i_op->get_acl2) {
set_cached_acl(inode, type, NULL); set_cached_acl(inode, type, NULL);
return NULL; return NULL;
} }
acl = inode->i_op->get_acl(inode, type); if (inode->i_op->get_acl)
acl = inode->i_op->get_acl(inode, type);
else
acl = inode->i_op->get_acl2(inode, type, false);
if (IS_ERR(acl)) { if (IS_ERR(acl)) {
/* /*
......
...@@ -1933,6 +1933,7 @@ struct inode_operations { ...@@ -1933,6 +1933,7 @@ struct inode_operations {
umode_t create_mode); umode_t create_mode);
int (*tmpfile) (struct inode *, struct dentry *, umode_t); int (*tmpfile) (struct inode *, struct dentry *, umode_t);
int (*set_acl)(struct inode *, struct posix_acl *, int); int (*set_acl)(struct inode *, struct posix_acl *, int);
struct posix_acl * (*get_acl2)(struct inode *, int, bool);
KABI_RESERVE(1) KABI_RESERVE(1)
KABI_RESERVE(2) KABI_RESERVE(2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册