FROMLIST: overlayfs: handle XATTR_NOSECURITY flag for get xattr method
__vfs_getxattr({dentry...XATTR_NOSECURITY}) -> handler->get({dentry...XATTR_NOSECURITY}) -> __vfs_getxattr({realdentry...XATTR_NOSECURITY}) -> lower_handler->get({realdentry...XATTR_NOSECURITY}) which would report back through the chain data and success as expected, the logging security layer at the top would have the data to determine the access permissions and report back to the logs and the caller that the target context was blocked. For selinux this would solve the cosmetic issue of the selinux log and allow audit2allow to correctly report the rule needed to address the access problem. Check impure, opaque, origin & meta xattr with no sepolicy audit (using __vfs_getxattr) since these operations are internal to overlayfs operations and do not disclose any data. This became an issue for credential override off since sys_admin would have been required by the caller; whereas would have been inherently present for the creator since it performed the mount. This is a change in operations since we do not check in the new ovl_do_getxattr function if the credential override is off or not. Reasoning is that the sepolicy check is unnecessary overhead, especially since the check can be expensive. Because for override credentials off, this affects _everyone_ that underneath performs private xattr calls without the appropriate sepolicy permissions and sys_admin capability. Providing blanket support for sys_admin would be bad for all possible callers. For the override credentials on, this will affect only the mounter, should it lack sepolicy permissions. Not considered a security problem since mounting by definition has sys_admin capabilities, but sepolicy contexts would still need to be crafted. It should be noted that there is precedence, __vfs_getxattr is used in other filesystems for their own internal trusted xattr management. Change-Id: I0b8fe9f1fe6c763fbd27a09c6de8209d1dc9d2f7 Signed-off-by: David Anderson <dvander@google.com> Signed-off-by: Mark Salyzyn <salyzyn@android.com> Link: https://lore.kernel.org/lkml/20211117015806.2192263-3-dvander@google.com Bug: 204981027
This commit is contained in:
parent
8c288004aa
commit
78626d4b82
|
@ -386,7 +386,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,
|
||||
void *value, size_t size)
|
||||
void *value, size_t size, int flags)
|
||||
{
|
||||
ssize_t res;
|
||||
const struct cred *old_cred;
|
||||
|
@ -394,7 +394,8 @@ int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
|
|||
ovl_i_dentry_upper(inode) ?: ovl_dentry_lower(dentry);
|
||||
|
||||
old_cred = ovl_override_creds(dentry->d_sb);
|
||||
res = vfs_getxattr(&init_user_ns, realdentry, name, value, size);
|
||||
res = __vfs_getxattr(&init_user_ns, realdentry, d_inode(realdentry),
|
||||
name, value, size, flags);
|
||||
revert_creds(old_cred);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -187,7 +187,9 @@ static inline ssize_t ovl_do_getxattr(struct ovl_fs *ofs, struct dentry *dentry,
|
|||
size_t size)
|
||||
{
|
||||
const char *name = ovl_xattr(ofs, ox);
|
||||
int err = vfs_getxattr(&init_user_ns, dentry, name, value, size);
|
||||
struct inode *ip = d_inode(dentry);
|
||||
int err = __vfs_getxattr(&init_user_ns, dentry, ip, name, value, size,
|
||||
XATTR_NOSECURITY);
|
||||
int len = (value && err > 0) ? err : 0;
|
||||
|
||||
pr_debug("getxattr(%pd2, \"%s\", \"%*pE\", %zu, 0) = %i\n",
|
||||
|
@ -496,7 +498,7 @@ int ovl_permission(struct user_namespace *mnt_userns, struct inode *inode,
|
|||
int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
|
||||
void *value, size_t size);
|
||||
void *value, size_t size, int flags);
|
||||
ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
|
||||
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);
|
||||
|
|
|
@ -1002,7 +1002,7 @@ ovl_posix_acl_xattr_get(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, struct inode *inode,
|
||||
const char *name, void *buffer, size_t size, int flags)
|
||||
{
|
||||
return ovl_xattr_get(dentry, inode, handler->name, buffer, size);
|
||||
return ovl_xattr_get(dentry, inode, handler->name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static int __maybe_unused
|
||||
|
@ -1083,7 +1083,7 @@ static int ovl_other_xattr_get(const struct xattr_handler *handler,
|
|||
const char *name, void *buffer, size_t size,
|
||||
int flags)
|
||||
{
|
||||
return ovl_xattr_get(dentry, inode, name, buffer, size);
|
||||
return ovl_xattr_get(dentry, inode, name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static int ovl_other_xattr_set(const struct xattr_handler *handler,
|
||||
|
|
Loading…
Reference in New Issue