summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAurelien Aptel <aaptel@suse.com>2021-04-21 16:22:15 +0200
committerPavel Shilovsky <pshilovsky@samba.org>2021-07-08 16:11:30 -0700
commit7f9711dd902a239c499682015d708f73ec884af2 (patch)
treea97904715a72e7d974fa846e8cb7716829487361 /contrib
parent02cd3aa7f19991bf194f7c17e412f1f9f9dfe4d5 (diff)
downloadcifs-utils-7f9711dd902a239c499682015d708f73ec884af2.tar.gz
cifs-utils-7f9711dd902a239c499682015d708f73ec884af2.tar.bz2
cifs-utils-7f9711dd902a239c499682015d708f73ec884af2.zip
cifs.upcall: fix regression in kerberos mount
The fix for CVE-2021-20208 in commit e461afd ("cifs.upcall: try to use container ipc/uts/net/pid/mnt/user namespaces") introduced a regression for kerberos mounts when cifs-utils is built with libcap-ng. It makes mount fail with ENOKEY "Required key not available". Current state: mount.cifs '---> mount() ---> kernel negprot, session setup (need security blob for krb) request_key("cifs.spnego", payload="pid=%d;username=...") upcall /sbin/request-key <--------------' reads /etc/request-keys.conf dispatch cifs.spnego request calls /usr/sbin/cifs.upcall <key id> - drop privileges (capabilities) - fetch keyid - parse payload - switch to mount.cifs namespaces - call krb5_xxx() funcs - generate security blob - set key value to security blob '-----------------------------------> kernel put blob in session setup packet continue auth open tcon get share root setup superblock mount.cifs mount() returns <-----------' By the time cifs.upcall tries to switch to namespaces, enough capabilities have dropped in trim_capabilities() that it makes setns() fail with EPERM. setns() requires CAP_SYS_ADMIN. With libcap trim_capabilities() is a no-op. This fix: - moves the namespace switch earlier so that operations like setgroups(), setgid(), scanning of pid environment, ... happens in the contained namespaces. - moves trim_capabilities() after the namespace switch - moves the string processing to decode the key request payload in a child process with minimum capabilities. the decoded data is shared with the parent process via shared memory obtained with mmap(). Fixes: e461afd ("cifs.upcall: try to use container ipc/uts/net/pid/mnt/user namespaces") Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Diffstat (limited to 'contrib')
0 files changed, 0 insertions, 0 deletions