Commit c1280730 authored by Luis Henriques's avatar Luis Henriques

Revert "UBUNTU: SAUCE: (namespace) posix_acl: Export posix_acl_fix_xattr_userns() to modules"

BugLink: https://bugs.launchpad.net/bugs/1644165

This reverts commit 5a10b5bd.

The kernel fix for bug #1634964 breaks LXD userspace, in particular the
following commits:

ac7f3f73 (namespace) vfs: Don't modify inodes with a uid or gid unknown to the vfs
ca52383a (namespace) vfs: Don't create inodes with a uid or gid unknown to the vfs

LXD 2.0.6 will include changes to support these kernel changes, but it isn't
available yet on xenial, so for now we just revert these commits.
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 9bfdc2f8
......@@ -626,68 +626,58 @@ EXPORT_SYMBOL(posix_acl_update_mode);
/*
* Fix up the uids and gids in posix acl extended attributes in place.
*/
int posix_acl_fix_xattr_userns(
static void posix_acl_fix_xattr_userns(
struct user_namespace *to, struct user_namespace *from,
void *value, size_t size)
{
posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
int count;
kuid_t kuid;
kgid_t kgid;
uid_t uid;
gid_t gid;
int ret = 0;
kuid_t uid;
kgid_t gid;
if (to == from)
return 0;
if (!value)
return 0;
return;
if (size < sizeof(posix_acl_xattr_header))
return -EINVAL;
return;
if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
return -EINVAL;
return;
count = posix_acl_xattr_count(size);
if (count < 0)
return -EINVAL;
return;
if (count == 0)
return 0;
return;
for (end = entry + count; entry != end; entry++) {
switch(le16_to_cpu(entry->e_tag)) {
case ACL_USER:
kuid = make_kuid(from, le32_to_cpu(entry->e_id));
uid = from_kuid(to, kuid);
entry->e_id = cpu_to_le32(uid);
if (uid == (uid_t)-1)
ret = -EOVERFLOW;
uid = make_kuid(from, le32_to_cpu(entry->e_id));
entry->e_id = cpu_to_le32(from_kuid(to, uid));
break;
case ACL_GROUP:
kgid = make_kgid(from, le32_to_cpu(entry->e_id));
gid = from_kgid(to, kgid);
entry->e_id = cpu_to_le32(gid);
if (gid == (gid_t)-1)
ret = -EOVERFLOW;
gid = make_kgid(from, le32_to_cpu(entry->e_id));
entry->e_id = cpu_to_le32(from_kgid(to, gid));
break;
default:
break;
}
}
return ret;
}
EXPORT_SYMBOL(posix_acl_fix_xattr_userns);
void posix_acl_fix_xattr_from_user(void *value, size_t size)
{
struct user_namespace *user_ns = current_user_ns();
if (user_ns == &init_user_ns)
return;
posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
}
void posix_acl_fix_xattr_to_user(void *value, size_t size)
{
struct user_namespace *user_ns = current_user_ns();
if (user_ns == &init_user_ns)
return;
posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
}
......
......@@ -53,18 +53,9 @@ posix_acl_xattr_count(size_t size)
}
#ifdef CONFIG_FS_POSIX_ACL
int posix_acl_fix_xattr_userns(struct user_namespace *to,
struct user_namespace *from,
void *value, size_t size);
void posix_acl_fix_xattr_from_user(void *value, size_t size);
void posix_acl_fix_xattr_to_user(void *value, size_t size);
#else
static inline int posix_acl_fix_xattr_userns(struct user_namespace *to,
struct user_namespace *from,
void *value, size_t size)
{
return 0;
}
static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
{
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment