Merge tag 'linux-kselftest-kunit-fixes-5.11-rc3' of git://git.kernel.org/pub/scm...
[linux/fpc-iii.git] / security / keys / compat_dh.c
blob19384e7e976c2ebafc48885f38a9dc0740c93e88
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* 32-bit compatibility syscall for 64-bit systems for DH operations
4 * Copyright (C) 2016 Stephan Mueller <smueller@chronox.de>
5 */
7 #include <linux/uaccess.h>
9 #include "internal.h"
12 * Perform the DH computation or DH based key derivation.
14 * If successful, 0 will be returned.
16 long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
17 char __user *buffer, size_t buflen,
18 struct compat_keyctl_kdf_params __user *kdf)
20 struct keyctl_kdf_params kdfcopy;
21 struct compat_keyctl_kdf_params compat_kdfcopy;
23 if (!kdf)
24 return __keyctl_dh_compute(params, buffer, buflen, NULL);
26 if (copy_from_user(&compat_kdfcopy, kdf, sizeof(compat_kdfcopy)) != 0)
27 return -EFAULT;
29 kdfcopy.hashname = compat_ptr(compat_kdfcopy.hashname);
30 kdfcopy.otherinfo = compat_ptr(compat_kdfcopy.otherinfo);
31 kdfcopy.otherinfolen = compat_kdfcopy.otherinfolen;
32 memcpy(kdfcopy.__spare, compat_kdfcopy.__spare,
33 sizeof(kdfcopy.__spare));
35 return __keyctl_dh_compute(params, buffer, buflen, &kdfcopy);