Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 2 | /* 32-bit compatibility syscall for 64-bit systems |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 4 | * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Written by David Howells (dhowells@redhat.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/syscalls.h> |
| 9 | #include <linux/keyctl.h> |
| 10 | #include <linux/compat.h> |
David Howells | ee009e4a0 | 2011-03-07 15:06:20 +0000 | [diff] [blame] | 11 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include "internal.h" |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* |
David Howells | 973c9f4 | 2011-01-20 16:38:33 +0000 | [diff] [blame] | 15 | * The key control system call, 32-bit compatibility version for 64-bit archs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
Heiko Carstens | 875ec3d | 2014-03-03 16:34:41 +0100 | [diff] [blame] | 17 | COMPAT_SYSCALL_DEFINE5(keyctl, u32, option, |
| 18 | u32, arg2, u32, arg3, u32, arg4, u32, arg5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { |
| 20 | switch (option) { |
| 21 | case KEYCTL_GET_KEYRING_ID: |
| 22 | return keyctl_get_keyring_ID(arg2, arg3); |
| 23 | |
| 24 | case KEYCTL_JOIN_SESSION_KEYRING: |
| 25 | return keyctl_join_session_keyring(compat_ptr(arg2)); |
| 26 | |
| 27 | case KEYCTL_UPDATE: |
| 28 | return keyctl_update_key(arg2, compat_ptr(arg3), arg4); |
| 29 | |
| 30 | case KEYCTL_REVOKE: |
| 31 | return keyctl_revoke_key(arg2); |
| 32 | |
| 33 | case KEYCTL_DESCRIBE: |
| 34 | return keyctl_describe_key(arg2, compat_ptr(arg3), arg4); |
| 35 | |
| 36 | case KEYCTL_CLEAR: |
| 37 | return keyctl_keyring_clear(arg2); |
| 38 | |
| 39 | case KEYCTL_LINK: |
| 40 | return keyctl_keyring_link(arg2, arg3); |
| 41 | |
| 42 | case KEYCTL_UNLINK: |
| 43 | return keyctl_keyring_unlink(arg2, arg3); |
| 44 | |
| 45 | case KEYCTL_SEARCH: |
| 46 | return keyctl_keyring_search(arg2, compat_ptr(arg3), |
| 47 | compat_ptr(arg4), arg5); |
| 48 | |
| 49 | case KEYCTL_READ: |
| 50 | return keyctl_read_key(arg2, compat_ptr(arg3), arg4); |
| 51 | |
| 52 | case KEYCTL_CHOWN: |
| 53 | return keyctl_chown_key(arg2, arg3, arg4); |
| 54 | |
| 55 | case KEYCTL_SETPERM: |
| 56 | return keyctl_setperm_key(arg2, arg3); |
| 57 | |
| 58 | case KEYCTL_INSTANTIATE: |
| 59 | return keyctl_instantiate_key(arg2, compat_ptr(arg3), arg4, |
| 60 | arg5); |
| 61 | |
| 62 | case KEYCTL_NEGATE: |
| 63 | return keyctl_negate_key(arg2, arg3, arg4); |
| 64 | |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 65 | case KEYCTL_SET_REQKEY_KEYRING: |
| 66 | return keyctl_set_reqkey_keyring(arg2); |
| 67 | |
David Howells | 017679c | 2006-01-08 01:02:43 -0800 | [diff] [blame] | 68 | case KEYCTL_SET_TIMEOUT: |
| 69 | return keyctl_set_timeout(arg2, arg3); |
| 70 | |
David Howells | b5f545c | 2006-01-08 01:02:47 -0800 | [diff] [blame] | 71 | case KEYCTL_ASSUME_AUTHORITY: |
| 72 | return keyctl_assume_authority(arg2); |
| 73 | |
David Howells | 70a5bb7 | 2008-04-29 01:01:26 -0700 | [diff] [blame] | 74 | case KEYCTL_GET_SECURITY: |
| 75 | return keyctl_get_security(arg2, compat_ptr(arg3), arg4); |
| 76 | |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 77 | case KEYCTL_SESSION_TO_PARENT: |
| 78 | return keyctl_session_to_parent(); |
| 79 | |
David Howells | fdd1b94 | 2011-03-07 15:06:09 +0000 | [diff] [blame] | 80 | case KEYCTL_REJECT: |
| 81 | return keyctl_reject_key(arg2, arg3, arg4, arg5); |
| 82 | |
David Howells | ee009e4a0 | 2011-03-07 15:06:20 +0000 | [diff] [blame] | 83 | case KEYCTL_INSTANTIATE_IOV: |
Christoph Hellwig | 5d47b39 | 2020-09-25 06:51:46 +0200 | [diff] [blame] | 84 | return keyctl_instantiate_key_iov(arg2, compat_ptr(arg3), arg4, |
| 85 | arg5); |
David Howells | ee009e4a0 | 2011-03-07 15:06:20 +0000 | [diff] [blame] | 86 | |
David Howells | fd75815 | 2012-05-11 10:56:56 +0100 | [diff] [blame] | 87 | case KEYCTL_INVALIDATE: |
| 88 | return keyctl_invalidate_key(arg2); |
| 89 | |
David Howells | f36f8c7 | 2013-09-24 10:35:19 +0100 | [diff] [blame] | 90 | case KEYCTL_GET_PERSISTENT: |
| 91 | return keyctl_get_persistent(arg2, arg3); |
| 92 | |
Mat Martineau | ddbb411 | 2016-04-12 19:54:58 +0100 | [diff] [blame] | 93 | case KEYCTL_DH_COMPUTE: |
Stephan Mueller | f1c316a | 2016-08-19 20:39:09 +0200 | [diff] [blame] | 94 | return compat_keyctl_dh_compute(compat_ptr(arg2), |
| 95 | compat_ptr(arg3), |
| 96 | arg4, compat_ptr(arg5)); |
Mat Martineau | ddbb411 | 2016-04-12 19:54:58 +0100 | [diff] [blame] | 97 | |
Mat Martineau | 6563c91 | 2017-03-01 16:44:09 -0800 | [diff] [blame] | 98 | case KEYCTL_RESTRICT_KEYRING: |
| 99 | return keyctl_restrict_keyring(arg2, compat_ptr(arg3), |
| 100 | compat_ptr(arg4)); |
| 101 | |
David Howells | 00d60fd | 2018-10-09 17:46:59 +0100 | [diff] [blame] | 102 | case KEYCTL_PKEY_QUERY: |
| 103 | if (arg3 != 0) |
| 104 | return -EINVAL; |
| 105 | return keyctl_pkey_query(arg2, |
| 106 | compat_ptr(arg4), |
| 107 | compat_ptr(arg5)); |
| 108 | |
| 109 | case KEYCTL_PKEY_ENCRYPT: |
| 110 | case KEYCTL_PKEY_DECRYPT: |
| 111 | case KEYCTL_PKEY_SIGN: |
| 112 | return keyctl_pkey_e_d_s(option, |
| 113 | compat_ptr(arg2), compat_ptr(arg3), |
| 114 | compat_ptr(arg4), compat_ptr(arg5)); |
| 115 | |
| 116 | case KEYCTL_PKEY_VERIFY: |
| 117 | return keyctl_pkey_verify(compat_ptr(arg2), compat_ptr(arg3), |
| 118 | compat_ptr(arg4), compat_ptr(arg5)); |
| 119 | |
David Howells | ed0ac5c | 2019-05-20 21:51:50 +0100 | [diff] [blame] | 120 | case KEYCTL_MOVE: |
| 121 | return keyctl_keyring_move(arg2, arg3, arg4, arg5); |
| 122 | |
David Howells | 45e0f30 | 2019-05-30 14:53:10 +0100 | [diff] [blame] | 123 | case KEYCTL_CAPABILITIES: |
| 124 | return keyctl_capabilities(compat_ptr(arg2), arg3); |
| 125 | |
David Howells | f7e4767 | 2020-01-14 17:07:11 +0000 | [diff] [blame] | 126 | case KEYCTL_WATCH_KEY: |
| 127 | return keyctl_watch_key(arg2, arg3, arg4); |
| 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | default: |
| 130 | return -EOPNOTSUPP; |
| 131 | } |
David Howells | a8b17ed | 2011-01-20 16:38:27 +0000 | [diff] [blame] | 132 | } |