Linux Audio

Check our new training course

Loading...
v5.9
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/* 32-bit compatibility syscall for 64-bit systems for DH operations
 3 *
 4 * Copyright (C) 2016 Stephan Mueller <smueller@chronox.de>
 
 
 
 
 
 5 */
 6
 7#include <linux/uaccess.h>
 8
 9#include "internal.h"
10
11/*
12 * Perform the DH computation or DH based key derivation.
13 *
14 * If successful, 0 will be returned.
15 */
16long 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)
19{
20	struct keyctl_kdf_params kdfcopy;
21	struct compat_keyctl_kdf_params compat_kdfcopy;
22
23	if (!kdf)
24		return __keyctl_dh_compute(params, buffer, buflen, NULL);
25
26	if (copy_from_user(&compat_kdfcopy, kdf, sizeof(compat_kdfcopy)) != 0)
27		return -EFAULT;
28
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));
34
35	return __keyctl_dh_compute(params, buffer, buflen, &kdfcopy);
36}
v4.17
 
 1/* 32-bit compatibility syscall for 64-bit systems for DH operations
 2 *
 3 * Copyright (C) 2016 Stephan Mueller <smueller@chronox.de>
 4 *
 5 * This program is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU General Public License
 7 * as published by the Free Software Foundation; either version
 8 * 2 of the License, or (at your option) any later version.
 9 */
10
11#include <linux/uaccess.h>
12
13#include "internal.h"
14
15/*
16 * Perform the DH computation or DH based key derivation.
17 *
18 * If successful, 0 will be returned.
19 */
20long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
21			      char __user *buffer, size_t buflen,
22			      struct compat_keyctl_kdf_params __user *kdf)
23{
24	struct keyctl_kdf_params kdfcopy;
25	struct compat_keyctl_kdf_params compat_kdfcopy;
26
27	if (!kdf)
28		return __keyctl_dh_compute(params, buffer, buflen, NULL);
29
30	if (copy_from_user(&compat_kdfcopy, kdf, sizeof(compat_kdfcopy)) != 0)
31		return -EFAULT;
32
33	kdfcopy.hashname = compat_ptr(compat_kdfcopy.hashname);
34	kdfcopy.otherinfo = compat_ptr(compat_kdfcopy.otherinfo);
35	kdfcopy.otherinfolen = compat_kdfcopy.otherinfolen;
36	memcpy(kdfcopy.__spare, compat_kdfcopy.__spare,
37	       sizeof(kdfcopy.__spare));
38
39	return __keyctl_dh_compute(params, buffer, buflen, &kdfcopy);
40}