X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=security%2Fkeys%2Fcompat.c;h=338b510e90275b1da873ed83aa907c404997d353;hb=619297855aa16646246ea4b1f6e05f1b2455c808;hp=07a5f35e39705bef3856d9605c4f96c65670b3c9;hpb=1cc26bada9f6807814806db2f0d78792eecdac71;p=firefly-linux-kernel-4.4.55.git diff --git a/security/keys/compat.c b/security/keys/compat.c index 07a5f35e3970..338b510e9027 100644 --- a/security/keys/compat.c +++ b/security/keys/compat.c @@ -12,8 +12,51 @@ #include #include #include +#include #include "internal.h" +/* + * Instantiate a key with the specified compatibility multipart payload and + * link the key into the destination keyring if one is given. + * + * The caller must have the appropriate instantiation permit set for this to + * work (see keyctl_assume_authority). No other permissions are required. + * + * If successful, 0 will be returned. + */ +long compat_keyctl_instantiate_key_iov( + key_serial_t id, + const struct compat_iovec __user *_payload_iov, + unsigned ioc, + key_serial_t ringid) +{ + struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; + long ret; + + if (_payload_iov == 0 || ioc == 0) + goto no_payload; + + ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc, + ARRAY_SIZE(iovstack), + iovstack, &iov); + if (ret < 0) + return ret; + if (ret == 0) + goto no_payload_free; + + ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid); + + if (iov != iovstack) + kfree(iov); + return ret; + +no_payload_free: + if (iov != iovstack) + kfree(iov); +no_payload: + return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid); +} + /* * The key control system call, 32-bit compatibility version for 64-bit archs * @@ -85,6 +128,13 @@ asmlinkage long compat_sys_keyctl(u32 option, case KEYCTL_SESSION_TO_PARENT: return keyctl_session_to_parent(); + case KEYCTL_REJECT: + return keyctl_reject_key(arg2, arg3, arg4, arg5); + + case KEYCTL_INSTANTIATE_IOV: + return compat_keyctl_instantiate_key_iov( + arg2, compat_ptr(arg3), arg4, arg5); + default: return -EOPNOTSUPP; }