| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* 32-bit compatibility syscall for 64-bit systems |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * Written by David Howells (dhowells@redhat.com) |
|---|
| 5 | | - * |
|---|
| 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. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/syscalls.h> |
|---|
| .. | .. |
|---|
| 16 | 12 | #include "internal.h" |
|---|
| 17 | 13 | |
|---|
| 18 | 14 | /* |
|---|
| 19 | | - * Instantiate a key with the specified compatibility multipart payload and |
|---|
| 20 | | - * link the key into the destination keyring if one is given. |
|---|
| 21 | | - * |
|---|
| 22 | | - * The caller must have the appropriate instantiation permit set for this to |
|---|
| 23 | | - * work (see keyctl_assume_authority). No other permissions are required. |
|---|
| 24 | | - * |
|---|
| 25 | | - * If successful, 0 will be returned. |
|---|
| 26 | | - */ |
|---|
| 27 | | -static long compat_keyctl_instantiate_key_iov( |
|---|
| 28 | | - key_serial_t id, |
|---|
| 29 | | - const struct compat_iovec __user *_payload_iov, |
|---|
| 30 | | - unsigned ioc, |
|---|
| 31 | | - key_serial_t ringid) |
|---|
| 32 | | -{ |
|---|
| 33 | | - struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; |
|---|
| 34 | | - struct iov_iter from; |
|---|
| 35 | | - long ret; |
|---|
| 36 | | - |
|---|
| 37 | | - if (!_payload_iov) |
|---|
| 38 | | - ioc = 0; |
|---|
| 39 | | - |
|---|
| 40 | | - ret = compat_import_iovec(WRITE, _payload_iov, ioc, |
|---|
| 41 | | - ARRAY_SIZE(iovstack), &iov, |
|---|
| 42 | | - &from); |
|---|
| 43 | | - if (ret < 0) |
|---|
| 44 | | - return ret; |
|---|
| 45 | | - |
|---|
| 46 | | - ret = keyctl_instantiate_key_common(id, &from, ringid); |
|---|
| 47 | | - kfree(iov); |
|---|
| 48 | | - return ret; |
|---|
| 49 | | -} |
|---|
| 50 | | - |
|---|
| 51 | | -/* |
|---|
| 52 | 15 | * The key control system call, 32-bit compatibility version for 64-bit archs |
|---|
| 53 | | - * |
|---|
| 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() |
|---|
| 57 | | - * directly. |
|---|
| 58 | 16 | */ |
|---|
| 59 | 17 | COMPAT_SYSCALL_DEFINE5(keyctl, u32, option, |
|---|
| 60 | 18 | u32, arg2, u32, arg3, u32, arg4, u32, arg5) |
|---|
| .. | .. |
|---|
| 123 | 81 | return keyctl_reject_key(arg2, arg3, arg4, arg5); |
|---|
| 124 | 82 | |
|---|
| 125 | 83 | case KEYCTL_INSTANTIATE_IOV: |
|---|
| 126 | | - return compat_keyctl_instantiate_key_iov( |
|---|
| 127 | | - arg2, compat_ptr(arg3), arg4, arg5); |
|---|
| 84 | + return keyctl_instantiate_key_iov(arg2, compat_ptr(arg3), arg4, |
|---|
| 85 | + arg5); |
|---|
| 128 | 86 | |
|---|
| 129 | 87 | case KEYCTL_INVALIDATE: |
|---|
| 130 | 88 | return keyctl_invalidate_key(arg2); |
|---|
| .. | .. |
|---|
| 141 | 99 | return keyctl_restrict_keyring(arg2, compat_ptr(arg3), |
|---|
| 142 | 100 | compat_ptr(arg4)); |
|---|
| 143 | 101 | |
|---|
| 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 | + |
|---|
| 120 | + case KEYCTL_MOVE: |
|---|
| 121 | + return keyctl_keyring_move(arg2, arg3, arg4, arg5); |
|---|
| 122 | + |
|---|
| 123 | + case KEYCTL_CAPABILITIES: |
|---|
| 124 | + return keyctl_capabilities(compat_ptr(arg2), arg3); |
|---|
| 125 | + |
|---|
| 126 | + case KEYCTL_WATCH_KEY: |
|---|
| 127 | + return keyctl_watch_key(arg2, arg3, arg4); |
|---|
| 128 | + |
|---|
| 144 | 129 | default: |
|---|
| 145 | 130 | return -EOPNOTSUPP; |
|---|
| 146 | 131 | } |
|---|