1 /* 32-bit compatibility syscall for 64-bit systems
3 * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/syscalls.h>
13 #include <linux/keyctl.h>
14 #include <linux/compat.h>
15 #include <linux/slab.h>
19 * Instantiate a key with the specified compatibility multipart payload and
20 * link the key into the destination keyring if one is given.
22 * The caller must have the appropriate instantiation permit set for this to
23 * work (see keyctl_assume_authority). No other permissions are required.
25 * If successful, 0 will be returned.
27 static long compat_keyctl_instantiate_key_iov(
29 const struct compat_iovec __user
*_payload_iov
,
33 struct iovec iovstack
[UIO_FASTIOV
], *iov
= iovstack
;
40 ret
= compat_import_iovec(WRITE
, _payload_iov
, ioc
,
41 ARRAY_SIZE(iovstack
), &iov
,
46 ret
= keyctl_instantiate_key_common(id
, &from
, ringid
);
52 * The key control system call, 32-bit compatibility version for 64-bit archs
54 * This should only be called if the 64-bit arch uses weird pointers in 32-bit
55 * mode or doesn't guarantee that the top 32-bits of the argument registers on
56 * taking a 32-bit syscall are zero. If you can, you should call sys_keyctl()
59 COMPAT_SYSCALL_DEFINE5(keyctl
, u32
, option
,
60 u32
, arg2
, u32
, arg3
, u32
, arg4
, u32
, arg5
)
63 case KEYCTL_GET_KEYRING_ID
:
64 return keyctl_get_keyring_ID(arg2
, arg3
);
66 case KEYCTL_JOIN_SESSION_KEYRING
:
67 return keyctl_join_session_keyring(compat_ptr(arg2
));
70 return keyctl_update_key(arg2
, compat_ptr(arg3
), arg4
);
73 return keyctl_revoke_key(arg2
);
76 return keyctl_describe_key(arg2
, compat_ptr(arg3
), arg4
);
79 return keyctl_keyring_clear(arg2
);
82 return keyctl_keyring_link(arg2
, arg3
);
85 return keyctl_keyring_unlink(arg2
, arg3
);
88 return keyctl_keyring_search(arg2
, compat_ptr(arg3
),
89 compat_ptr(arg4
), arg5
);
92 return keyctl_read_key(arg2
, compat_ptr(arg3
), arg4
);
95 return keyctl_chown_key(arg2
, arg3
, arg4
);
98 return keyctl_setperm_key(arg2
, arg3
);
100 case KEYCTL_INSTANTIATE
:
101 return keyctl_instantiate_key(arg2
, compat_ptr(arg3
), arg4
,
105 return keyctl_negate_key(arg2
, arg3
, arg4
);
107 case KEYCTL_SET_REQKEY_KEYRING
:
108 return keyctl_set_reqkey_keyring(arg2
);
110 case KEYCTL_SET_TIMEOUT
:
111 return keyctl_set_timeout(arg2
, arg3
);
113 case KEYCTL_ASSUME_AUTHORITY
:
114 return keyctl_assume_authority(arg2
);
116 case KEYCTL_GET_SECURITY
:
117 return keyctl_get_security(arg2
, compat_ptr(arg3
), arg4
);
119 case KEYCTL_SESSION_TO_PARENT
:
120 return keyctl_session_to_parent();
123 return keyctl_reject_key(arg2
, arg3
, arg4
, arg5
);
125 case KEYCTL_INSTANTIATE_IOV
:
126 return compat_keyctl_instantiate_key_iov(
127 arg2
, compat_ptr(arg3
), arg4
, arg5
);
129 case KEYCTL_INVALIDATE
:
130 return keyctl_invalidate_key(arg2
);
132 case KEYCTL_GET_PERSISTENT
:
133 return keyctl_get_persistent(arg2
, arg3
);
135 case KEYCTL_DH_COMPUTE
:
136 return compat_keyctl_dh_compute(compat_ptr(arg2
),
138 arg4
, compat_ptr(arg5
));
140 case KEYCTL_RESTRICT_KEYRING
:
141 return keyctl_restrict_keyring(arg2
, compat_ptr(arg3
),
144 case KEYCTL_PKEY_QUERY
:
147 return keyctl_pkey_query(arg2
,
151 case KEYCTL_PKEY_ENCRYPT
:
152 case KEYCTL_PKEY_DECRYPT
:
153 case KEYCTL_PKEY_SIGN
:
154 return keyctl_pkey_e_d_s(option
,
155 compat_ptr(arg2
), compat_ptr(arg3
),
156 compat_ptr(arg4
), compat_ptr(arg5
));
158 case KEYCTL_PKEY_VERIFY
:
159 return keyctl_pkey_verify(compat_ptr(arg2
), compat_ptr(arg3
),
160 compat_ptr(arg4
), compat_ptr(arg5
));