Skip to content

Commit a082c6f

Browse files
author
Miklos Szeredi
committed
ovl: filter trusted xattr for non-admin
Filesystems filter out extended attributes in the "trusted." domain for unprivlieged callers. Overlay calls underlying filesystem's method with elevated privs, so need to do the filtering in overlayfs too. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent f3a1568 commit a082c6f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎fs/overlayfs/inode.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ int ovl_xattr_get(struct dentry *dentry, const char *name,
240240
return res;
241241
}
242242

243+
static bool ovl_can_list(const char *s)
244+
{
245+
/* List all non-trusted xatts */
246+
if (strncmp(s, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) != 0)
247+
return true;
248+
249+
/* Never list trusted.overlay, list other trusted for superuser only */
250+
return !ovl_is_private_xattr(s) && capable(CAP_SYS_ADMIN);
251+
}
252+
243253
ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
244254
{
245255
struct dentry *realdentry = ovl_dentry_real(dentry);
@@ -263,7 +273,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
263273
return -EIO;
264274

265275
len -= slen;
266-
if (ovl_is_private_xattr(s)) {
276+
if (!ovl_can_list(s)) {
267277
res -= slen;
268278
memmove(s, s + slen, len);
269279
} else {

0 commit comments

Comments
 (0)