]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
UBUNTU: SAUCE: (namespace) fs: Allow superblock owner to change ownership of inodes
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 2 Jul 2016 14:54:25 +0000 (09:54 -0500)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 29 Jan 2018 13:44:55 +0000 (07:44 -0600)
commit5e13dab975a68f0a4e5e9a39a2eed5938416a43c
tree8f24b0edc8e30e34b2cf8ecb905febc1995ac5a8
parent459f5e1dbb36cdbd0d6f45cd369850de27a736d9
UBUNTU: SAUCE: (namespace) fs: Allow superblock owner to change ownership of inodes

Allow users with CAP_SYS_CHOWN over the superblock of a filesystem to
chown files.  Ordinarily the capable_wrt_inode_uidgid check is
sufficient to allow access to files but when the underlying filesystem
has uids or gids that don't map to the current user namespace it is
not enough, so the chown permission checks need to be extended to
allow this case.

Calling chown on filesystem nodes whose uid or gid don't map is
necessary if those nodes are going to be modified as writing back
inodes which contain uids or gids that don't map is likely to cause
filesystem corruption of the uid or gid fields.

Once chown has been called the existing capable_wrt_inode_uidgid
checks are sufficient, to allow the owner of a superblock to do anything
the global root user can do with an appropriate set of capabilities.

For the proc filesystem this relaxation of permissions is not safe, as
some files are owned by users (particularly GLOBAL_ROOT_UID) outside
of the control of the mounter of the proc and that would be unsafe to
grant chown access to.  So update setattr on proc to disallow changing
files whose uids or gids are outside of proc's s_user_ns.

The original version of this patch was written by: Seth Forshee.  I
have rewritten and rethought this patch enough so it's really not the
same thing (certainly it needs a different description), but he
deserves credit for getting out there and getting the conversation
started, and finding the potential gotcha's and putting up with my
semi-paranoid feedback.

Inspired-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
[saf: Resolve conflicts caused by s/inode_change_ok/setattr_prepare/]
fs/attr.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/proc_sysctl.c